Skip to content
This repository

Windows trailing \ fix for CheckFile() #88

Closed
wants to merge 1 commit into from

2 participants

QBall147 Timothee "TTimo" Besset
QBall147

Suggested fix for CheckFile()

Timothee "TTimo" Besset
Owner
TTimo commented

I don't think you realized that the CheckFile implementations are seperate for WIN32 and other OSes ..

Timothee "TTimo" Besset
Owner
TTimo commented

Replaced CheckFile with the proposed implementation, making new builds now

Timothee "TTimo" Besset TTimo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 15, 2012
QBall147 QBall147 Windows trailing '\ fix for CheckFile() ba38078
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 15 additions and 8 deletions. Show diff stats Hide diff stats

  1. +12 1 radiant/missing.cpp
  2. +3 7 radiant/preferences.cpp
13 radiant/missing.cpp
@@ -227,7 +227,17 @@ const char* FindFiles::NextFile() {
227 227 return findFileData.cFileName;
228 228 }
229 229
230   -EPathCheck CheckFile( const char *path ) {
  230 +EPathCheck CheckFile( const char *path ){
  231 +#ifdef _WIN32
  232 + DWORD Attrib = GetFileAttributes( path );
  233 + if ( Attrib == INVALID_FILE_ATTRIBUTES ) {
  234 + return PATH_FAIL;
  235 + }
  236 + if ( Attrib & FILE_ATTRIBUTE_DIRECTORY ) {
  237 + return PATH_DIRECTORY;
  238 + }
  239 +#else
  240 + // else linux/mac...
231 241 struct _stat sbuf;
232 242 if ( _stat( path, &sbuf ) == -1 ) {
233 243 return PATH_FAIL;
@@ -235,6 +245,7 @@ EPathCheck CheckFile( const char *path ) {
235 245 if ( ( sbuf.st_mode & _S_IFDIR ) != 0 ) {
236 246 return PATH_DIRECTORY;
237 247 }
  248 +#endif
238 249 return PATH_FILE;
239 250 }
240 251
10 radiant/preferences.cpp
@@ -3410,18 +3410,14 @@ void CGameInstall::Run() {
3410 3410 return;
3411 3411 }
3412 3412 Sys_Printf( "combo: %d name: %s engine: %s mod: %s\n", m_nComboSelect, m_strName.GetBuffer(), m_strEngine.GetBuffer(), m_strMod.GetBuffer() );
3413   -
  3413 +
3414 3414 // write out the game file
3415 3415 Str gameFilePath = g_strAppPath.GetBuffer();
3416   - gameFilePath += "games";
3417   - if ( CheckFile( gameFilePath ) != PATH_DIRECTORY ) {
  3416 + gameFilePath += "games/";
  3417 + if ( CheckFile( gameFilePath.GetBuffer() ) != PATH_DIRECTORY ) {
3418 3418 radCreateDirectory( gameFilePath );
3419 3419 }
3420 3420
3421   - // QB - Fix for when you have more than one game configured (before it just bombed out due to the dir already existing).
3422   - // add the slash here instead of above else CheckFile() fails hard (on windows at least :/ )
3423   - gameFilePath += "/";
3424   -
3425 3421 switch ( m_availGames[ m_nComboSelect ] ) {
3426 3422 case GAME_Q2:
3427 3423 gameFilePath += "q2.game";

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.