Commit 6c967b93 authored by Sam Lantinga's avatar Sam Lantinga

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).

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40856
parent eeed686a
...@@ -65,27 +65,20 @@ int SDL_InitBeApp(void) ...@@ -65,27 +65,20 @@ int SDL_InitBeApp(void)
return(-1); return(-1);
} }
/* Check if we started from Terminal or Tracker... */ /* Change working to directory to that of executable */
/* Based on code posted to BeDevTalk by Marco Nelissen */ app_info info;
char *cmd = getenv("_"); if (B_OK == be_app->GetAppInfo(&info)) {
if(!(cmd == NULL || strlen(cmd) < 7) && entry_ref ref = info.ref;
(!strcmp(cmd + strlen(cmd) - 7 , "Tracker"))) { BEntry entry;
if (B_OK == entry.SetTo(&ref)) {
/* Change working to directory to that of executable */ BPath path;
app_info info; if (B_OK == path.SetTo(&entry)) {
if (B_OK == be_app->GetAppInfo(&info)) { if (B_OK == path.GetParent(&path)) {
entry_ref ref = info.ref; chdir(path.Path());
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 { do {
SDL_Delay(10); SDL_Delay(10);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment