From 000dd459432e3bd0e4d41982c19a8df99910ae03 Mon Sep 17 00:00:00 2001 From: Timothee 'TTimo' Besset Date: Sun, 15 Jul 2012 10:45:23 -0500 Subject: [PATCH] QBall proposed a better solution for this --- radiant/missing.cpp | 18 ++++++++---------- radiant/preferences.cpp | 6 +----- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/radiant/missing.cpp b/radiant/missing.cpp index 02553600..c220e62e 100644 --- a/radiant/missing.cpp +++ b/radiant/missing.cpp @@ -227,17 +227,15 @@ const char* FindFiles::NextFile() { 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 ) { - struct _stat sbuf; - if ( _stat( path, &sbuf ) == -1 ) { - return PATH_FAIL; - } - if ( ( sbuf.st_mode & _S_IFDIR ) != 0 ) { - return PATH_DIRECTORY; - } - return PATH_FILE; + DWORD Attrib = GetFileAttributes( path ); + if ( Attrib == INVALID_FILE_ATTRIBUTES ) { + return PATH_FAIL; + } + if ( Attrib & FILE_ATTRIBUTE_DIRECTORY ) { + return PATH_DIRECTORY; + } + return PATH_FILE; } bool radCreateDirectory( const char *directory, bool fatal_on_error ) { diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 844e8224..cea42e43 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -3413,15 +3413,11 @@ void CGameInstall::Run() { // write out the game file Str gameFilePath = g_strAppPath.GetBuffer(); - gameFilePath += "games"; + gameFilePath += "games/"; if ( CheckFile( gameFilePath ) != PATH_DIRECTORY ) { 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 ] ) { case GAME_Q2: gameFilePath += "q2.game";