diff --git a/Common/FileUtil.cpp b/Common/FileUtil.cpp index 9cced3871..c6fbd73ef 100644 --- a/Common/FileUtil.cpp +++ b/Common/FileUtil.cpp @@ -652,7 +652,6 @@ bool DeleteDirRecursively(const std::string &directory) if (hFind == INVALID_HANDLE_VALUE) { - FindClose(hFind); return false; } @@ -671,7 +670,6 @@ bool DeleteDirRecursively(const std::string &directory) { const std::string virtualName = result->d_name; #endif - // check for "." and ".." if (((virtualName[0] == '.') && (virtualName[1] == '\0')) || ((virtualName[0] == '.') && (virtualName[1] == '.') && @@ -683,10 +681,11 @@ bool DeleteDirRecursively(const std::string &directory) { if (!DeleteDirRecursively(newPath)) { - #ifndef _WIN32 +#ifndef _WIN32 closedir(dirp); - #endif - +#else + FindClose(hFind); +#endif return false; } } @@ -694,10 +693,11 @@ bool DeleteDirRecursively(const std::string &directory) { if (!File::Delete(newPath)) { - #ifndef _WIN32 +#ifndef _WIN32 closedir(dirp); - #endif - +#else + FindClose(hFind); +#endif return false; } } @@ -709,8 +709,7 @@ bool DeleteDirRecursively(const std::string &directory) } closedir(dirp); #endif - File::DeleteDir(directory); - return true; + return File::DeleteDir(directory); #endif } diff --git a/ext/native/file/file_util.cpp b/ext/native/file/file_util.cpp index 6cf0ae760..0882213e9 100644 --- a/ext/native/file/file_util.cpp +++ b/ext/native/file/file_util.cpp @@ -230,7 +230,6 @@ size_t getFilesInDir(const char *directory, std::vector *files, const WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFileEx((ConvertUTF8ToWString(directory) + L"\\*").c_str(), FindExInfoStandard, &ffd, FindExSearchNameMatch, NULL, 0); if (hFind == INVALID_HANDLE_VALUE) { - FindClose(hFind); return 0; } // windows loop