correct initial path setting from argv

This commit is contained in:
Dave Murphy 2008-05-23 10:37:33 +00:00
parent 25b615836f
commit a839587b4d

View File

@ -112,14 +112,17 @@ bool fatInit (u32 cacheSize, bool setAsDefaultDevice) {
char filePath[MAXPATHLEN * 2] = "fat:/"; char filePath[MAXPATHLEN * 2] = "fat:/";
#ifndef GBA #ifndef GBA
if ( __system_argv->argvMagic == ARGV_MAGIC && __system_argv->argc >= 1 ) { if ( __system_argv->argvMagic == ARGV_MAGIC && __system_argv->argc >= 1 ) {
char ch, *ptr = filePath, *lastSlash = NULL;
strcpy(filePath, __system_argv->argv[0]); if ( !strncasecmp( __system_argv->argv[0], "fat", 3)) {
do {
ch = *(ptr); strcpy(filePath, __system_argv->argv[0]);
if (ch == '/') lastSlash=ptr; char *lastSlash = strrchr( filePath, '/' );
ptr++;
} while (ch); if ( NULL != lastSlash) {
if ( NULL != lastSlash) *lastSlash = 0; if ( *(lastSlash - 1) == ':') lastSlash++;
*lastSlash = 0;
}
}
} }
#endif #endif
chdir (filePath); chdir (filePath);