Mercurial > sdl-ios-xcode
comparison src/main/beos/SDL_BeApp.cc @ 855:aa4ac9e65d92
I noticed MacOSX SDL sets up working directory to parent of executable.
On BeOS is should setup it the same way, but it only does when Tracker
wasn't restarted.
I checked code and it looks like a hack to me :(
It looks for env variable and than comapres it to default when OpenTracker
was started after boot, and wasn't restarted. That's probably ok, for that
exact case. Unfortunetly that variable isn't always like that. For
example, after Tracker crashes and is restarted, env variable most
probably is different (depends on how Tracker was restarted, by what
application, etc... for example: i have launcher application from which i
can restart Tracker, and after that nev variable points to that
application's directory, not Tracker's).
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 24 Feb 2004 18:58:40 +0000 |
parents | b8d311d90021 |
children | c9b51268668f |
comparison
equal
deleted
inserted
replaced
854:59a93320f326 | 855:aa4ac9e65d92 |
---|---|
63 if ( SDL_AppThread == NULL ) { | 63 if ( SDL_AppThread == NULL ) { |
64 SDL_SetError("Couldn't create BApplication thread"); | 64 SDL_SetError("Couldn't create BApplication thread"); |
65 return(-1); | 65 return(-1); |
66 } | 66 } |
67 | 67 |
68 /* Check if we started from Terminal or Tracker... */ | 68 /* Change working to directory to that of executable */ |
69 /* Based on code posted to BeDevTalk by Marco Nelissen */ | 69 app_info info; |
70 char *cmd = getenv("_"); | 70 if (B_OK == be_app->GetAppInfo(&info)) { |
71 if(!(cmd == NULL || strlen(cmd) < 7) && | 71 entry_ref ref = info.ref; |
72 (!strcmp(cmd + strlen(cmd) - 7 , "Tracker"))) { | 72 BEntry entry; |
73 | 73 if (B_OK == entry.SetTo(&ref)) { |
74 /* Change working to directory to that of executable */ | 74 BPath path; |
75 app_info info; | 75 if (B_OK == path.SetTo(&entry)) { |
76 if (B_OK == be_app->GetAppInfo(&info)) { | 76 if (B_OK == path.GetParent(&path)) { |
77 entry_ref ref = info.ref; | 77 chdir(path.Path()); |
78 BEntry entry; | |
79 if (B_OK == entry.SetTo(&ref)) { | |
80 BPath path; | |
81 if (B_OK == path.SetTo(&entry)) { | |
82 if (B_OK == path.GetParent(&path)) { | |
83 chdir(path.Path()); | |
84 } | |
85 } | 78 } |
86 } | 79 } |
87 } | 80 } |
88 } /* else started from Terminal */ | 81 } |
89 | 82 |
90 do { | 83 do { |
91 SDL_Delay(10); | 84 SDL_Delay(10); |
92 } while ( (be_app == NULL) || be_app->IsLaunching() ); | 85 } while ( (be_app == NULL) || be_app->IsLaunching() ); |
93 | 86 |