QBall proposed a better solution for this

This commit is contained in:
Timothee 'TTimo' Besset 2012-07-15 10:45:23 -05:00
parent 686527fdbc
commit 000dd45943
2 changed files with 9 additions and 15 deletions

View file

@ -227,14 +227,12 @@ const char* FindFiles::NextFile() {
return findFileData.cFileName; return findFileData.cFileName;
} }
// NOTE: has a problem when trailing (back)slashes are present (different behavior than the nix implementation)
// https://github.com/TTimo/GtkRadiant/issues/87
EPathCheck CheckFile( const char *path ) { EPathCheck CheckFile( const char *path ) {
struct _stat sbuf; DWORD Attrib = GetFileAttributes( path );
if ( _stat( path, &sbuf ) == -1 ) { if ( Attrib == INVALID_FILE_ATTRIBUTES ) {
return PATH_FAIL; return PATH_FAIL;
} }
if ( ( sbuf.st_mode & _S_IFDIR ) != 0 ) { if ( Attrib & FILE_ATTRIBUTE_DIRECTORY ) {
return PATH_DIRECTORY; return PATH_DIRECTORY;
} }
return PATH_FILE; return PATH_FILE;

View file

@ -3413,15 +3413,11 @@ void CGameInstall::Run() {
// write out the game file // write out the game file
Str gameFilePath = g_strAppPath.GetBuffer(); Str gameFilePath = g_strAppPath.GetBuffer();
gameFilePath += "games"; gameFilePath += "games/";
if ( CheckFile( gameFilePath ) != PATH_DIRECTORY ) { if ( CheckFile( gameFilePath ) != PATH_DIRECTORY ) {
radCreateDirectory( gameFilePath ); radCreateDirectory( gameFilePath );
} }
// QB - Fix for when you have more than one game configured (before it just bombed out due to the dir already existing).
// add the slash here instead of above else CheckFile() fails hard (on windows at least :/ )
gameFilePath += "/";
switch ( m_availGames[ m_nComboSelect ] ) { switch ( m_availGames[ m_nComboSelect ] ) {
case GAME_Q2: case GAME_Q2:
gameFilePath += "q2.game"; gameFilePath += "q2.game";