diff --git a/src/Pack.cpp b/src/Pack.cpp index 746f996..fecf01e 100644 --- a/src/Pack.cpp +++ b/src/Pack.cpp @@ -224,6 +224,14 @@ Pack::~Pack() { } Result> Pack::from(std::filesystem::path const& dir) { + #ifdef GEODE_IS_WINDOWS + try { + auto test = dir.filename().string(); + } catch(const std::exception& e) { + return Err("Invalid path"); + } + #endif + if (!std::filesystem::exists(dir)) { return Err("Path does not exist"); } diff --git a/src/PackManager.cpp b/src/PackManager.cpp index 729a935..092a9f4 100644 --- a/src/PackManager.cpp +++ b/src/PackManager.cpp @@ -58,7 +58,12 @@ size_t PackManager::loadPacks() { for (auto& dir : std::filesystem::directory_iterator(packDir)) { auto packRes = Pack::from(dir); if (!packRes) { - log::warn("Unable to load pack {}: {}", dir, packRes.unwrapErr()); + // calling dir can throw an exception on windows if it contains invalid characters + #ifdef GEODE_IS_WINDOWS + log::warn("Unable to load pack {}: {}", string::wideToUtf8(dir.path().wstring()), packRes.unwrapErr()); + #else + log::warn("Unable to load pack {}: {}", dir, packRes.unwrapErr()); + #endif } else { found.push_back(packRes.unwrap()); loaded++;