Skip to content

Commit

Permalink
Use the executable directory, not the current directory, for stdio ou…
Browse files Browse the repository at this point in the history
…tput files
  • Loading branch information
slouken committed Jan 29, 2006
1 parent 9b07eb3 commit b60b9f0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/win32/SDL_win32_main.c
Expand Up @@ -266,6 +266,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
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;
Expand All @@ -286,7 +292,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
}

#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 */
Expand All @@ -305,7 +317,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
}
#endif /* _WIN32_WCE */

_getcwd( stderrPath, sizeof( stderrPath ) );
strcpy( stderrPath, path );
strcat( stderrPath, DIR_SEPERATOR STDERR_FILE );

newfp = freopen(stderrPath, TEXT("w"), stderr);
Expand Down

0 comments on commit b60b9f0

Please sign in to comment.