comparison src/main/macosx/SDLMain.m @ 388:4e9044b378fd

*** empty log message ***
author Sam Lantinga <slouken@libsdl.org>
date Sat, 01 Jun 2002 19:51:08 +0000
parents 50620ec9c86a
children ca655a7a9d80
comparison
equal deleted inserted replaced
387:469d5c0da01d 388:4e9044b378fd
49 @implementation SDLMain 49 @implementation SDLMain
50 50
51 /* Set the working directory to the .app's parent directory */ 51 /* Set the working directory to the .app's parent directory */
52 - (void) setupWorkingDirectory:(BOOL)shouldChdir 52 - (void) setupWorkingDirectory:(BOOL)shouldChdir
53 { 53 {
54 char parentdir[MAXPATHLEN];
55 char *c;
56
57 strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
58 c = (char*) parentdir;
59
60 while (*c != '\0') /* go to end */
61 c++;
62
63 while (*c != '/') /* back up to parent */
64 c--;
65
66 *c++ = '\0'; /* cut off last part (binary name) */
67
68 if (shouldChdir) 54 if (shouldChdir)
69 { 55 {
56 char parentdir[MAXPATHLEN];
57 char *c;
58
59 strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
60 c = (char*) parentdir;
61
62 while (*c != '\0') /* go to end */
63 c++;
64
65 while (*c != '/') /* back up to parent */
66 c--;
67
68 *c++ = '\0'; /* cut off last part (binary name) */
69
70 assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */ 70 assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
71 assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */ 71 assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
72 } 72 }
73 } 73 }
74 74