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; |