src/fileio.cpp
branchnoai
changeset 9629 66dde6412125
parent 9628 b5c2449616b5
child 9694 e72987579514
equal deleted inserted replaced
9628:b5c2449616b5 9629:66dde6412125
   408  * @param exe the path to the executable
   408  * @param exe the path to the executable
   409  */
   409  */
   410 void DetermineBasePaths(const char *exe)
   410 void DetermineBasePaths(const char *exe)
   411 {
   411 {
   412 	char tmp[MAX_PATH];
   412 	char tmp[MAX_PATH];
   413 #ifdef WITH_PERSONAL_DIR
   413 #if defined(__MORPHOS__) || defined(__AMIGA__) || !defined(WITH_PERSONAL_DIR)
       
   414 	_searchpaths[SP_PERSONAL_DIR] = NULL;
       
   415 #else
   414 	const char *homedir = getenv("HOME");
   416 	const char *homedir = getenv("HOME");
   415 
   417 
   416 	if (homedir == NULL) {
   418 	if (homedir == NULL) {
   417 		const struct passwd *pw = getpwuid(getuid());
   419 		const struct passwd *pw = getpwuid(getuid());
   418 		homedir = (pw == NULL) ? "" : pw->pw_dir;
   420 		homedir = (pw == NULL) ? "" : pw->pw_dir;
   420 
   422 
   421 	snprintf(tmp, MAX_PATH, "%s" PATHSEP "%s", homedir, PERSONAL_DIR);
   423 	snprintf(tmp, MAX_PATH, "%s" PATHSEP "%s", homedir, PERSONAL_DIR);
   422 	AppendPathSeparator(tmp, MAX_PATH);
   424 	AppendPathSeparator(tmp, MAX_PATH);
   423 
   425 
   424 	_searchpaths[SP_PERSONAL_DIR] = strdup(tmp);
   426 	_searchpaths[SP_PERSONAL_DIR] = strdup(tmp);
       
   427 #endif
       
   428 	_searchpaths[SP_SHARED_DIR] = NULL;
       
   429 
       
   430 #if defined(__MORPHOS__) || defined(__AMIGA__)
       
   431 	_searchpaths[SP_WORKING_DIR] = NULL;
   425 #else
   432 #else
   426 	_searchpaths[SP_PERSONAL_DIR] = NULL;
       
   427 #endif
       
   428 	_searchpaths[SP_SHARED_DIR] = NULL;
       
   429 
       
   430 	getcwd(tmp, MAX_PATH);
   433 	getcwd(tmp, MAX_PATH);
   431 	AppendPathSeparator(tmp, MAX_PATH);
   434 	AppendPathSeparator(tmp, MAX_PATH);
   432 	_searchpaths[SP_WORKING_DIR] = strdup(tmp);
   435 	_searchpaths[SP_WORKING_DIR] = strdup(tmp);
       
   436 #endif
   433 
   437 
   434 	/* Change the working directory to that one of the executable */
   438 	/* Change the working directory to that one of the executable */
   435 	ChangeWorkingDirectory((char*)exe);
   439 	ChangeWorkingDirectory((char*)exe);
   436 	getcwd(tmp, MAX_PATH);
   440 	getcwd(tmp, MAX_PATH);
   437 	AppendPathSeparator(tmp, MAX_PATH);
   441 	AppendPathSeparator(tmp, MAX_PATH);
   438 	_searchpaths[SP_BINARY_DIR] = strdup(tmp);
   442 	_searchpaths[SP_BINARY_DIR] = strdup(tmp);
   439 
   443 
       
   444 #if defined(__MORPHOS__) || defined(__AMIGA__)
       
   445 	_searchpaths[SP_INSTALLATION_DIR] = NULL;
       
   446 #else
   440 	snprintf(tmp, MAX_PATH, "%s", GLOBAL_DATA_DIR);
   447 	snprintf(tmp, MAX_PATH, "%s", GLOBAL_DATA_DIR);
   441 	AppendPathSeparator(tmp, MAX_PATH);
   448 	AppendPathSeparator(tmp, MAX_PATH);
   442 	_searchpaths[SP_INSTALLATION_DIR] = strdup(tmp);
   449 	_searchpaths[SP_INSTALLATION_DIR] = strdup(tmp);
       
   450 #endif
   443 #ifdef WITH_COCOA
   451 #ifdef WITH_COCOA
   444 extern void cocoaSetApplicationBundleDir();
   452 extern void cocoaSetApplicationBundleDir();
   445 	cocoaSetApplicationBundleDir();
   453 	cocoaSetApplicationBundleDir();
   446 #else
   454 #else
   447 	_searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL;
   455 	_searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL;
   522 	for (; *filename != '\0'; filename++) {
   530 	for (; *filename != '\0'; filename++) {
   523 		switch (*filename) {
   531 		switch (*filename) {
   524 			/* The following characters are not allowed in filenames
   532 			/* The following characters are not allowed in filenames
   525 			 * on at least one of the supported operating systems: */
   533 			 * on at least one of the supported operating systems: */
   526 			case ':': case '\\': case '*': case '?': case '/':
   534 			case ':': case '\\': case '*': case '?': case '/':
       
   535 			case '<': case '>': case '|': case '"':
   527 				*filename = '_';
   536 				*filename = '_';
   528 				break;
   537 				break;
   529 		}
   538 		}
   530 	}
   539 	}
   531 }
   540 }