src/main/win32/SDL_win32_main.c
changeset 1286 d7bca8c8161e
parent 766 ed57c876700d
child 1336 3692456e7b0f
     1.1 --- a/src/main/win32/SDL_win32_main.c	Sun Jan 29 08:19:27 2006 +0000
     1.2 +++ b/src/main/win32/SDL_win32_main.c	Sun Jan 29 08:39:35 2006 +0000
     1.3 @@ -266,6 +266,12 @@
     1.4  	char **argv;
     1.5  	int argc;
     1.6  	char *cmdline;
     1.7 +	DWORD pathlen;
     1.8 +#ifdef _WIN32_WCE
     1.9 +	wchar_t path[MAX_PATH];
    1.10 +#else
    1.11 +	char path[MAX_PATH];
    1.12 +#endif
    1.13  #ifdef _WIN32_WCE
    1.14  	wchar_t *bufp;
    1.15  	int nLen;
    1.16 @@ -286,7 +292,13 @@
    1.17  	}
    1.18  
    1.19  #ifndef NO_STDIO_REDIRECT
    1.20 -	_getcwd( stdoutPath, sizeof( stdoutPath ) );
    1.21 +	pathlen = GetModuleFileName(NULL, path, SDL_TABLESIZE(path));
    1.22 +	while ( pathlen > 0 && path[pathlen] != '\\' ) {
    1.23 +		--pathlen;
    1.24 +	}
    1.25 +	path[pathlen] = '\0';
    1.26 +
    1.27 +	strcpy( stdoutPath, path );
    1.28  	strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE );
    1.29      
    1.30  	/* Redirect standard input and standard output */
    1.31 @@ -305,7 +317,7 @@
    1.32  	}
    1.33  #endif /* _WIN32_WCE */
    1.34  
    1.35 -	_getcwd( stderrPath, sizeof( stderrPath ) );
    1.36 +	strcpy( stderrPath, path );
    1.37  	strcat( stderrPath, DIR_SEPERATOR STDERR_FILE );
    1.38  
    1.39  	newfp = freopen(stderrPath, TEXT("w"), stderr);