From ab706e1762f21a5cbb33632fc188d4de02a2747e Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 9 Mar 2011 18:51:26 +0000 Subject: [PATCH] - some code cleanup related to vc++ posix naming warnings --- source/glest_game/menu/menu_state_keysetup.cpp | 4 ++++ .../sources/platform/common/platform_common.cpp | 14 ++++++++++++++ .../sources/platform/posix/miniftpclient.cpp | 10 ++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/source/glest_game/menu/menu_state_keysetup.cpp b/source/glest_game/menu/menu_state_keysetup.cpp index 70664c74..615a55cc 100644 --- a/source/glest_game/menu/menu_state_keysetup.cpp +++ b/source/glest_game/menu/menu_state_keysetup.cpp @@ -202,7 +202,11 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){ Config &configKeys = Config::getInstance(std::pair(cfgMainKeys,cfgUserKeys)); string userKeysFile = configKeys.getFileName(true); +#ifdef WIN32 + int result = _unlink(userKeysFile.c_str()); +#else int result = unlink(userKeysFile.c_str()); +#endif SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] delete file [%s] returned %d\n",__FILE__,__FUNCTION__,__LINE__,userKeysFile.c_str(),result); configKeys.reload(); diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 7b969167..2baf8bad 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -351,7 +351,12 @@ void removeFolder(const string path) { string item = results[i]; if(isdir(item.c_str()) == false) { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] file item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str()); + +#ifdef WIN32 + int result = _unlink(item.c_str()); +#else int result = unlink(item.c_str()); +#endif SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileitem [%s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,item.c_str(),result); } } @@ -363,12 +368,21 @@ void removeFolder(const string path) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s] isdir(item.c_str()) = %d\n",__FILE__,__FUNCTION__,__LINE__,item.c_str(), isdir(item.c_str())); if(isdir(item.c_str()) == true) { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str()); +#ifdef WIN32 + int result = _rmdir(item.c_str()); +#else int result = rmdir(item.c_str()); +#endif SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,item.c_str(),result); } } +#ifdef WIN32 + int result = _rmdir(path.c_str()); +#else int result = rmdir(path.c_str()); +#endif + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),result); } diff --git a/source/shared_lib/sources/platform/posix/miniftpclient.cpp b/source/shared_lib/sources/platform/posix/miniftpclient.cpp index d8877957..d569e8e8 100644 --- a/source/shared_lib/sources/platform/posix/miniftpclient.cpp +++ b/source/shared_lib/sources/platform/posix/miniftpclient.cpp @@ -69,7 +69,11 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread CANCELLED, deleting file for writing [%s]\n",fullFilePath.c_str()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Client thread CANCELLED, deleting file for writing [%s]\n",fullFilePath.c_str()); +#ifdef WIN32 + _unlink(fullFilePath.c_str()); +#else unlink(fullFilePath.c_str()); +#endif return -1; } @@ -299,7 +303,11 @@ FTP_Client_ResultType FTPClientThread::getMapFromServer(string mapFileName, stri ftpfile.stream = NULL; } if(result != ftp_crt_SUCCESS) { +#ifdef WIN32 + _unlink(destFile.c_str()); +#else unlink(destFile.c_str()); +#endif } return result; @@ -470,7 +478,6 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName, } if(destRootFolder != "") { - //unlink(destRootFolder.c_str()); removeFolder(destRootFolder); } } @@ -502,7 +509,6 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName, result = getTilesetFromServer(tileSetName, tileSetNameSubfolder, ftpUser, ftpUserPassword, false); if(result != ftp_crt_SUCCESS) { if(destRootFolder != "") { - //unlink(destRootFolder.c_str()); removeFolder(destRootFolder); } }