Use the executable directory, not the current directory, for stdio output files
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401289
This commit is contained in:
parent
baaae734d7
commit
16857d624d
1 changed files with 14 additions and 2 deletions
|
@ -266,6 +266,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
|
||||||
char **argv;
|
char **argv;
|
||||||
int argc;
|
int argc;
|
||||||
char *cmdline;
|
char *cmdline;
|
||||||
|
DWORD pathlen;
|
||||||
|
#ifdef _WIN32_WCE
|
||||||
|
wchar_t path[MAX_PATH];
|
||||||
|
#else
|
||||||
|
char path[MAX_PATH];
|
||||||
|
#endif
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
wchar_t *bufp;
|
wchar_t *bufp;
|
||||||
int nLen;
|
int nLen;
|
||||||
|
@ -286,7 +292,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_STDIO_REDIRECT
|
#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 );
|
strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE );
|
||||||
|
|
||||||
/* Redirect standard input and standard output */
|
/* Redirect standard input and standard output */
|
||||||
|
@ -305,7 +317,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
|
||||||
}
|
}
|
||||||
#endif /* _WIN32_WCE */
|
#endif /* _WIN32_WCE */
|
||||||
|
|
||||||
_getcwd( stderrPath, sizeof( stderrPath ) );
|
strcpy( stderrPath, path );
|
||||||
strcat( stderrPath, DIR_SEPERATOR STDERR_FILE );
|
strcat( stderrPath, DIR_SEPERATOR STDERR_FILE );
|
||||||
|
|
||||||
newfp = freopen(stderrPath, TEXT("w"), stderr);
|
newfp = freopen(stderrPath, TEXT("w"), stderr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue