# HG changeset patch # User Sam Lantinga # Date 1138523975 0 # Node ID d7bca8c8161e894abef0167ad1d23797fab6194c # Parent c9ae23d221eae1eb553fc5bfba5d5b91f6bf2f5d Use the executable directory, not the current directory, for stdio output files diff -r c9ae23d221ea -r d7bca8c8161e src/main/win32/SDL_win32_main.c --- a/src/main/win32/SDL_win32_main.c Sun Jan 29 08:19:27 2006 +0000 +++ b/src/main/win32/SDL_win32_main.c Sun Jan 29 08:39:35 2006 +0000 @@ -266,6 +266,12 @@ char **argv; int argc; char *cmdline; + DWORD pathlen; +#ifdef _WIN32_WCE + wchar_t path[MAX_PATH]; +#else + char path[MAX_PATH]; +#endif #ifdef _WIN32_WCE wchar_t *bufp; int nLen; @@ -286,7 +292,13 @@ } #ifndef NO_STDIO_REDIRECT - _getcwd( stdoutPath, sizeof( stdoutPath ) ); + pathlen = GetModuleFileName(NULL, path, SDL_TABLESIZE(path)); + while ( pathlen > 0 && path[pathlen] != '\\' ) { + --pathlen; + } + path[pathlen] = '\0'; + + strcpy( stdoutPath, path ); strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE ); /* Redirect standard input and standard output */ @@ -305,7 +317,7 @@ } #endif /* _WIN32_WCE */ - _getcwd( stderrPath, sizeof( stderrPath ) ); + strcpy( stderrPath, path ); strcat( stderrPath, DIR_SEPERATOR STDERR_FILE ); newfp = freopen(stderrPath, TEXT("w"), stderr);