Skip to content

Commit

Permalink
I noticed MacOSX SDL sets up working directory to parent of executable.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
slouken committed Feb 24, 2004
1 parent 14ac58e commit 64b6d78
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/main/beos/SDL_BeApp.cc
Expand Up @@ -65,27 +65,20 @@ int SDL_InitBeApp(void)
return(-1);
}

/* Check if we started from Terminal or Tracker... */
/* Based on code posted to BeDevTalk by Marco Nelissen */
char *cmd = getenv("_");
if(!(cmd == NULL || strlen(cmd) < 7) &&
(!strcmp(cmd + strlen(cmd) - 7 , "Tracker"))) {

/* Change working to directory to that of executable */
app_info info;
if (B_OK == be_app->GetAppInfo(&info)) {
entry_ref ref = info.ref;
BEntry entry;
if (B_OK == entry.SetTo(&ref)) {
BPath path;
if (B_OK == path.SetTo(&entry)) {
if (B_OK == path.GetParent(&path)) {
chdir(path.Path());
}
/* Change working to directory to that of executable */
app_info info;
if (B_OK == be_app->GetAppInfo(&info)) {
entry_ref ref = info.ref;
BEntry entry;
if (B_OK == entry.SetTo(&ref)) {
BPath path;
if (B_OK == path.SetTo(&entry)) {
if (B_OK == path.GetParent(&path)) {
chdir(path.Path());
}
}
}
} /* else started from Terminal */
}
}

do {
SDL_Delay(10);
Expand Down

0 comments on commit 64b6d78

Please sign in to comment.