Fix crash if no magic folder is present

This commit is contained in:
WerWolv 2020-11-12 23:08:17 +01:00
parent 8172cf28db
commit 86fdd531da
1 changed files with 21 additions and 16 deletions

View File

@ -83,10 +83,13 @@ namespace hex {
std::string magicFiles;
for (const auto &entry : std::filesystem::directory_iterator("magic")) {
std::error_code error;
for (const auto &entry : std::filesystem::directory_iterator("magic", error)) {
if (entry.is_regular_file() && entry.path().extension() == ".mgc")
magicFiles += entry.path().string() + MAGIC_PATH_SEPARATOR;
}
if (!error) {
magicFiles.pop_back();
{
@ -114,6 +117,8 @@ namespace hex {
magic_close(cookie);
}
}
this->m_shouldInvalidate = false;
}