diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index 327f314b7..0da4f011d 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -131,6 +131,7 @@ bool StartsWith(const std::string &str, const std::string &key); bool EndsWith(const string &str, const string& key); string replaceAll(string& context, const string& from, const string& to); +void removeFolder(const string path); int getScreenW(); int getScreenH(); diff --git a/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c b/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c index 055ea2f26..ad30dd43c 100644 --- a/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c +++ b/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c @@ -415,7 +415,8 @@ int ftpSelect(int poll) if(poll) { - struct timeval t = {0}; + struct timeval t = {0}; + t.tv_usec = 10000; return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t); } else diff --git a/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c b/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c index e4c91b339..49668482e 100644 --- a/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c +++ b/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c @@ -446,7 +446,8 @@ int ftpSelect(int poll) if(poll) { - struct timeval t = {0}; + struct timeval t = {0}; + t.tv_usec = 10000; return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t); } else diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index a2d4d481f..244cf4054 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -335,22 +335,38 @@ bool isdir(const char *path) return ret; } -/* void removeFolder(const string path) { - path += "*"; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); + + string deletePath = path + "*"; vector results; - findAll(path, vector &results, false, false); + findAll(deletePath, results, false, false); + + // First delete files for(int i = results.size() -1; i >= 0; --i) { string item = results[i]; - if(isdir(item) == true) { + if(isdir(item.c_str()) == true) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str()); rmdir(item.c_str()); } else { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str()); + unlink(item.c_str()); + } + } + // Now delete folders + for(int i = results.size() -1; i >= 0; --i) { + string item = results[i]; + if(isdir(item.c_str()) == true) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str()); + rmdir(item.c_str()); + } + else { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] item [%s]\n",__FILE__,__FUNCTION__,__LINE__,item.c_str()); unlink(item.c_str()); } } } -*/ bool StartsWith(const std::string &str, const std::string &key) { return str.find(key) == 0; diff --git a/source/shared_lib/sources/platform/posix/miniftpclient.cpp b/source/shared_lib/sources/platform/posix/miniftpclient.cpp index bb81dbd14..5aafcebb1 100644 --- a/source/shared_lib/sources/platform/posix/miniftpclient.cpp +++ b/source/shared_lib/sources/platform/posix/miniftpclient.cpp @@ -228,7 +228,7 @@ FTP_Client_ResultType FTPClientThread::getMapFromServer(string mapFileName, stri CURLcode res = curl_easy_perform(curl); if(CURLE_OK != res) { // we failed - printf("curl FAILED with: %d\n", res); + printf("curl FAILED with: %d [%s]\n", res,curl_easy_strerror(res)); } else { result = ftp_crt_SUCCESS; @@ -383,10 +383,11 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName, if(CURLE_OK != res) { // we failed - printf("curl FAILED with: %d\n", res); + printf("curl FAILED with: %d [%s]\n", res,curl_easy_strerror(res)); if(destRootFolder != "") { - unlink(destRootFolder.c_str()); + //unlink(destRootFolder.c_str()); + removeFolder(destRootFolder); } } else { diff --git a/source/shared_lib/sources/platform/posix/miniftpserver.cpp b/source/shared_lib/sources/platform/posix/miniftpserver.cpp index 6a5e691d3..d7d6a26bf 100644 --- a/source/shared_lib/sources/platform/posix/miniftpserver.cpp +++ b/source/shared_lib/sources/platform/posix/miniftpserver.cpp @@ -130,7 +130,7 @@ void FTPServerThread::execute() { while(this->getQuitStatus() == false) { int processedWork = ftpExecute(); if(processedWork == 0) { - sleep(25); + //sleep(25); } } ftpShutdown();