I noticed MacOSX SDL sets up working directory to parent of executable.
authorSam Lantinga <slouken@libsdl.org>
Tue, 24 Feb 2004 18:58:40 +0000
changeset 855aa4ac9e65d92
parent 854 59a93320f326
child 856 d3165b90ee42
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).
src/main/beos/SDL_BeApp.cc
     1.1 --- a/src/main/beos/SDL_BeApp.cc	Tue Feb 24 16:21:19 2004 +0000
     1.2 +++ b/src/main/beos/SDL_BeApp.cc	Tue Feb 24 18:58:40 2004 +0000
     1.3 @@ -65,27 +65,20 @@
     1.4  			return(-1);
     1.5  		}
     1.6  		
     1.7 -		/* Check if we started from Terminal or Tracker... */
     1.8 -		/* Based on code posted to BeDevTalk by Marco Nelissen */
     1.9 -		char *cmd = getenv("_"); 
    1.10 -		if(!(cmd == NULL || strlen(cmd) < 7) && 
    1.11 -			(!strcmp(cmd + strlen(cmd) - 7 , "Tracker"))) { 
    1.12 -	
    1.13 -			/* Change working to directory to that of executable */
    1.14 -			app_info info;
    1.15 -			if (B_OK == be_app->GetAppInfo(&info)) {
    1.16 -				entry_ref ref = info.ref;
    1.17 -				BEntry entry;
    1.18 -				if (B_OK == entry.SetTo(&ref)) {
    1.19 -					BPath path;
    1.20 -					if (B_OK == path.SetTo(&entry)) {
    1.21 -						if (B_OK == path.GetParent(&path)) {
    1.22 -							chdir(path.Path());
    1.23 -						}
    1.24 +		/* Change working to directory to that of executable */
    1.25 +		app_info info;
    1.26 +		if (B_OK == be_app->GetAppInfo(&info)) {
    1.27 +			entry_ref ref = info.ref;
    1.28 +			BEntry entry;
    1.29 +			if (B_OK == entry.SetTo(&ref)) {
    1.30 +				BPath path;
    1.31 +				if (B_OK == path.SetTo(&entry)) {
    1.32 +					if (B_OK == path.GetParent(&path)) {
    1.33 +						chdir(path.Path());
    1.34  					}
    1.35  				}
    1.36 -			}	
    1.37 -		} /* else started from Terminal */
    1.38 +			}
    1.39 +		}	
    1.40  		
    1.41  		do {
    1.42  			SDL_Delay(10);