string Platform_Windows::GetPathForResourceInDirectory(const char* aFileName, const char* aFileType, const char* aDirectory)
 {
     string path = string(GetApplicationDirectory());
     path += "\\Assets\\";
     path += string(aDirectory);
     path += "\\";
     path += string(aFileName);
     path += ".";
     path += string(aFileType);
     return path;
 }
List* readDirectoryContents(const char *dirname, const char *prefix) {

  nebu_List *l;
  OSErr err;
  char *path;
  
  Str255 relPath;  
  short vRefNum;
  long  dirID;
  FSSpec spec;

  if (*dirname != ':')
    sprintf ((char*)relPath, "%c:%s", strlen(dirname) + 1, dirname);
  else
    sprintf ((char*)relPath, "%c%s", strlen(dirname) , dirname);

  err = GetApplicationDirectory (&vRefNum, &dirID);
  if (err != noErr) {
    fprintf (stderr, "GetApplicationDirectory failed\n");
    exit (-1);
  }
  
  err = FSMakeFSSpec  (vRefNum, dirID, relPath, &spec);
     
  if (err != noErr) {
    fprintf (stderr, "FSMakeFSSpec failed\n");
    exit (-1);
  }
  
  l = NULL;
  l = (nebu_List*) malloc(sizeof(nebu_List));
  if (l == NULL) {
  	fprintf (stderr, "readDirectoryContents: out of memory\n");
  	exit (-1);
  }
  l->data = NULL;
  l->next = NULL;
 
  filter_prefix = (char*)prefix;
  
  err = FSpIterateDirectory (&spec, 1, NewIterateFilterUPP(iterateProc), l);
    
  if (err != noErr)  {
    fprintf (stderr, "FSpIterateDirectory failed\n");
    exit (-1);
  }
 
  return l;
}
Esempio n. 3
0
static int itemExists ( const char* path ) {
    
  OSStatus  err;
  Str255    relPath; 
  short     vRefNum;
  long      dirID;
  FSSpec    spec;

  if (*path != ':')
   sprintf (relPath, "%c:%s", (strlen(path) + 1), path);
  else 
   sprintf (relPath, "%c%s", (strlen(path)) , path);

  err = GetApplicationDirectory (&vRefNum, &dirID);
  if (err != noErr) {
    fprintf (stderr, "GetApplicationDirectory failed\n");
    exit (-1);
  }
  
  err = FSMakeFSSpec  (vRefNum, dirID, relPath, &spec);
  
  return (err == noErr);
}
 string Platform_Windows::GetWorkingDirectory()
 {
     return GetApplicationDirectory();
 }
Void BonkEnc::GeneralSettingsDialog::OK()
{
	Directory	 outputDirectory(register_layer_encoders->GetOutputDirectory().Replace("<installdrive>", Utilities::GetInstallDrive()));

	if ((Setup::enableUnicode ? SetCurrentDirectoryW(String(outputDirectory)) : SetCurrentDirectoryA(String(outputDirectory))) == False)
	{
		Int	 selection = QuickMessage(BonkEnc::i18n->TranslateString("The output directory does not exist! Do you want to create it?"), BonkEnc::i18n->TranslateString("Error"), MB_YESNOCANCEL, IDI_QUESTION);

		if (selection == IDYES)		outputDirectory.Create();
		else if (selection == IDCANCEL)	return;
	}

	if (currentConfig->freedb_proxy_mode == 1 && register_layer_cddb->GetFreedbMode() == FREEDB_MODE_CDDBP)
	{
		Int	 selection = QuickMessage(BonkEnc::i18n->TranslateString("The freedb CDDBP protocol cannot be used over HTTP\nForward proxies!\n\nWould you like to change the protocol to HTTP?"), BonkEnc::i18n->TranslateString("Error"), MB_YESNOCANCEL, IDI_QUESTION);

		if (selection == IDYES)		currentConfig->freedb_mode = FREEDB_MODE_HTTP;
		else if (selection == IDNO)	currentConfig->freedb_mode = register_layer_cddb->GetFreedbMode();
		else if (selection == IDCANCEL)	return;
	}
	else
	{
		currentConfig->freedb_mode = register_layer_cddb->GetFreedbMode();
	}

	if (Setup::enableUnicode)	SetCurrentDirectoryW(GetApplicationDirectory());
	else				SetCurrentDirectoryA(GetApplicationDirectory());

	Bool	 valid = False;
	String	 email = register_layer_cddb->GetFreedbEMail();

	for (Int i = 0; i < email.Length(); i++) if (email[i] == '@') valid = True;

	if (currentConfig->enable_cdrip && currentConfig->cdrip_numdrives >= 1 && !valid)
	{
		Utilities::ErrorMessage("Please enter a valid eMail address.");

		return;
	}

	currentConfig->encoder = register_layer_encoders->GetSelectedEncoder();

	if (BonkEnc::i18n->GetNOfLanguages() > 1)
	{
		if (register_layer_language->IsLanguageChanged()) currentConfig->languageChanged = true;

		currentConfig->language = register_layer_language->GetSelectedLanguageID();
	}

	currentConfig->enc_outdir		= register_layer_encoders->GetOutputDirectory();
	currentConfig->enc_filePattern		= register_layer_encoders->GetFilenamePattern();
	currentConfig->enc_onTheFly		= register_layer_encoders->GetOnTheFly();
	currentConfig->writeToInputDir		= register_layer_encoders->GetUseInputDirectory();
	currentConfig->allowOverwrite		= register_layer_encoders->GetAllowOverwrite();
	currentConfig->encodeToSingleFile	= register_layer_encoders->GetEncodeToSingleFile();
	currentConfig->enc_keepWaves		= register_layer_encoders->GetKeepWaveFiles();
	currentConfig->useUnicodeNames		= register_layer_encoders->GetUnicodeFilenames();

	currentConfig->createPlaylist		= register_layer_playlists->GetCreatePlaylists();
	currentConfig->createCueSheet		= register_layer_playlists->GetCreateCueSheets();
	currentConfig->playlist_outdir		= register_layer_playlists->GetOutputDirectory();
	currentConfig->playlist_filePattern	= register_layer_playlists->GetFilenamePattern();
	currentConfig->playlist_useEncOutdir	= register_layer_playlists->GetUseEncOutdir();

	if (currentConfig->enable_cdrip && currentConfig->cdrip_numdrives >= 1) currentConfig->cdrip_activedrive = register_layer_cdrip->GetActiveDrive();

	currentConfig->cdrip_paranoia		= (register_layer_cdrip->GetCDParanoiaMode() != -1);
	currentConfig->cdrip_paranoia_mode	= (register_layer_cdrip->GetCDParanoiaMode() == -1 ? 0 : register_layer_cdrip->GetCDParanoiaMode());
	currentConfig->cdrip_speed		= register_layer_cdrip->GetSpeed();
	currentConfig->cdrip_jitter		= register_layer_cdrip->GetJitter();
	currentConfig->cdrip_swapchannels	= register_layer_cdrip->GetSwapChannels();
	currentConfig->cdrip_locktray		= register_layer_cdrip->GetLockTray();
	currentConfig->cdrip_ntscsi		= register_layer_cdrip->GetNTSCSI();
	currentConfig->cdrip_autoRead		= register_layer_cdrip->GetAutoRead();
	currentConfig->cdrip_autoRip		= register_layer_cdrip->GetAutoRip();
	currentConfig->cdrip_autoEject		= register_layer_cdrip->GetAutoEject();
	currentConfig->cdrip_read_cdtext	= register_layer_cdrip->GetReadCDText();
	currentConfig->cdrip_read_cdplayerini	= register_layer_cdrip->GetReadCDPlayerIni();

	currentConfig->enable_id3v1		= register_layer_tags->GetEnableID3V1();
	currentConfig->enable_id3v2		= register_layer_tags->GetEnableID3V2();
	currentConfig->enable_vctags		= register_layer_tags->GetEnableVCTags();
	currentConfig->enable_mp4meta		= register_layer_tags->GetEnableMP4Meta();
	currentConfig->enable_wmatags		= register_layer_tags->GetEnableWMAMeta();

	currentConfig->id3v1_encoding		= register_layer_tags->GetID3V1Encoding();
	currentConfig->id3v2_encoding		= register_layer_tags->GetID3V2Encoding();
	currentConfig->vctag_encoding		= register_layer_tags->GetVCTagEncoding();
	currentConfig->mp4meta_encoding		= register_layer_tags->GetMP4MetaEncoding();
	currentConfig->wmameta_encoding		= register_layer_tags->GetWMAMetaEncoding();

	currentConfig->overwriteComments	= register_layer_tags->GetOverwriteComments();

	currentConfig->enable_local_cddb	= register_layer_cddb->GetLocalCDDB();
	currentConfig->enable_remote_cddb	= register_layer_cddb->GetRemoteCDDB();

	currentConfig->enable_auto_cddb		= register_layer_cddb->GetCDDBAutoQuery();
	currentConfig->enable_overwrite_cdtext	= register_layer_cddb->GetCDDBOverwriteCDText();
	currentConfig->enable_cddb_cache	= register_layer_cddb->GetCDDBCache();

	currentConfig->default_comment		= register_layer_tags->GetDefaultComment();

	currentConfig->freedb_dir		= register_layer_cddb->GetLocalPath();
	currentConfig->freedb_server		= register_layer_cddb->GetFreedbServer();
	currentConfig->freedb_email		= register_layer_cddb->GetFreedbEMail();

	if (currentConfig->freedb_mode == FREEDB_MODE_CDDBP)	 currentConfig->freedb_cddbp_port = register_layer_cddb->GetFreedbPort();
	else if (currentConfig->freedb_mode == FREEDB_MODE_HTTP) currentConfig->freedb_http_port = register_layer_cddb->GetFreedbPort();

	currentConfig->output_plugin = register_layer_plugins->GetSelectedOutputPlugin();

	if (currentConfig->enc_outdir[currentConfig->enc_outdir.Length() - 1] != '\\') currentConfig->enc_outdir.Append("\\");
	if (currentConfig->playlist_outdir[currentConfig->playlist_outdir.Length() - 1] != '\\') currentConfig->playlist_outdir.Append("\\");
	if (currentConfig->freedb_dir[currentConfig->freedb_dir.Length() - 1] != '\\') currentConfig->freedb_dir.Append("\\");

	mainWnd->Close();
}