diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index ee6336b6..63e8a57f 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -259,12 +259,10 @@ namespace Components #pragma warning(pop) // Check if folder exists && crash-helper exists - if (PathIsDirectoryA("minidumps\\") && Utils::IO::FileExists("crash-helper.exe")) + + if (Utils::IO::DirectoryExists("minidumps\\") && Utils::IO::FileExists("crash-helper.exe")) { - // Walk through directory and search for valid minidumps - WIN32_FIND_DATAA ffd; - HANDLE hFind = FindFirstFileA(Utils::String::VA("%s\\*.dmp", "minidumps"), &ffd); - if (hFind != INVALID_HANDLE_VALUE) + if (!Utils::IO::DirectoryIsEmpty("minidumps\\")) { STARTUPINFOA sInfo; PROCESS_INFORMATION pInfo; diff --git a/src/Utils/IO.cpp b/src/Utils/IO.cpp index 0c62fec6..fa9eba97 100644 --- a/src/Utils/IO.cpp +++ b/src/Utils/IO.cpp @@ -83,6 +83,16 @@ namespace Utils return std::experimental::filesystem::create_directories(dir); } + bool DirectoryExists(std::string directory) + { + return std::experimental::filesystem::is_directory(directory); + } + + bool DirectoryIsEmpty(std::string directory) + { + return std::experimental::filesystem::is_empty(directory); + } + std::vector ListFiles(std::string dir) { std::vector files; diff --git a/src/Utils/IO.hpp b/src/Utils/IO.hpp index 85a8ab9d..2d0f4c9e 100644 --- a/src/Utils/IO.hpp +++ b/src/Utils/IO.hpp @@ -10,6 +10,8 @@ namespace Utils std::string ReadFile(std::string file); size_t FileSize(std::string file); bool CreateDir(std::string dir); + bool DirectoryExists(std::string file); + bool DirectoryIsEmpty(std::string file); std::vector ListFiles(std::string dir); } }