From 31363fd41bb0ca50547326732c279ff6a5d853dc Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 17 Aug 2010 20:58:30 +0000 Subject: [PATCH] - bugfix for press screen shot hotkey in windows --- source/glest_game/main/main.cpp | 2 ++ .../platform/common/platform_common.cpp | 28 ++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 0c6d0223..a418322a 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -677,8 +677,10 @@ int glestMain(int argc, char** argv){ gameInitialized = true; string screenShotsPath = GameConstants::folder_path_screenshots; + //printf("In [%s::%s Line: %d] screenShotsPath [%s]\n",__FILE__,__FUNCTION__,__LINE__,screenShotsPath.c_str()); if(isdir(screenShotsPath.c_str()) == false) { createDirectoryPaths(screenShotsPath); + //printf("In [%s::%s Line: %d] screenShotsPath [%s]\n",__FILE__,__FUNCTION__,__LINE__,screenShotsPath.c_str()); } if(config.getBool("AllowGameDataSynchCheck","false") == true) { diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 6b91937d..91eb2b7c 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -272,9 +272,28 @@ void findAll(const string &path, vector &results, bool cutExtension, boo bool isdir(const char *path) { - struct stat stats; + string friendly_path = path; - bool ret = stat (path, &stats) == 0 && S_ISDIR(stats.st_mode); +#ifdef WIN32 + replaceAll(friendly_path, "/", "\\"); + if(EndsWith(friendly_path, "\\") == true) { + friendly_path.erase(friendly_path.begin() + friendly_path.length() -1); + } +#endif + + struct stat stats; + int result = stat(friendly_path.c_str(), &stats); + bool ret = (result == 0); + if(ret == true) { + ret = S_ISDIR(stats.st_mode); // #define S_ISDIR(mode) ((mode) & _S_IFDIR) + + if(ret == false) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s] ret = %d\n",__FILE__,__FUNCTION__,__LINE__,friendly_path.c_str(),ret); + } + } + else { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s] ret = %d, result = %d, errno = %d\n",__FILE__,__FUNCTION__,__LINE__,friendly_path.c_str(),ret,result,errno); + } //if(ret == false) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] NOT a path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path); return ret; @@ -595,12 +614,13 @@ void createDirectoryPaths(string Path) //if (':' != *(path-1)) { #ifdef WIN32 - _mkdir(DirName); + int result = _mkdir(DirName); #elif defined(__GNUC__) - mkdir(DirName, S_IRWXU | S_IRWXO | S_IRWXG); + int result = mkdir(DirName, S_IRWXU | S_IRWXO | S_IRWXG); #else #error "Your compiler needs to support mkdir!" #endif + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] DirName [%s] result = %d, errno = %d\n",__FILE__,__FUNCTION__,__LINE__,DirName,result,errno); } } *dirName++ = *path++;