From a1207646aa5e712d53a96ce2ea5015ac98bbb4ad Mon Sep 17 00:00:00 2001 From: hakasapl Date: Mon, 22 Jul 2024 23:16:27 -0400 Subject: [PATCH] Fixed non ASCII characters in loose file extension causing crashes --- CHANGELOG.md | 4 +++ CMakeLists.txt | 2 +- .../BethesdaDirectory/BethesdaDirectory.hpp | 10 +++---- src/BethesdaDirectory/BethesdaDirectory.cpp | 29 +++++++------------ src/main/main.cpp | 28 ++++++++++-------- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcae904..98d5252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [0.4.4] - UNRELEASED + +- Fixed non ASCII characters in loose file extension causing crashes + ## [0.4.3] - 2024-07-22 - Fixed parallax being applied on soft and rim lighting diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e963f6..6c31029 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ set(PROJECT_NAME "ParallaxGen") set(PROJECT_URI "com.github.hakasapl.ParallaxGen") # Initialize Project -set(PARALLAXGEN_VERSION 0.4.3) +set(PARALLAXGEN_VERSION 0.4.4) project(${PROJECT_NAME} VERSION ${PARALLAXGEN_VERSION}) # Define preprocessor macro with the version number diff --git a/include/BethesdaDirectory/BethesdaDirectory.hpp b/include/BethesdaDirectory/BethesdaDirectory.hpp index ac5a062..46ec0c8 100644 --- a/include/BethesdaDirectory/BethesdaDirectory.hpp +++ b/include/BethesdaDirectory/BethesdaDirectory.hpp @@ -52,11 +52,11 @@ class BethesdaDirectory { // any file that ends with these strings will be ignored // allowed BSAs etc. to be hidden from the file map since this object is an abstraction // of the data directory that no longer factors BSAs for downstream users - std::vector extension_blocklist = { - ".bsa", - ".esp", - ".esl", - ".esm" + std::vector extension_blocklist = { + L".bsa", + L".esp", + L".esl", + L".esm" }; public: diff --git a/src/BethesdaDirectory/BethesdaDirectory.cpp b/src/BethesdaDirectory/BethesdaDirectory.cpp index d10ae64..6515de5 100644 --- a/src/BethesdaDirectory/BethesdaDirectory.cpp +++ b/src/BethesdaDirectory/BethesdaDirectory.cpp @@ -202,27 +202,20 @@ void BethesdaDirectory::addLooseFilesToMap() } for (const auto& entry : fs::recursive_directory_iterator(data_dir, fs::directory_options::skip_permission_denied)) { - try{ - if (entry.is_regular_file()) { - const fs::path file_path = entry.path(); - fs::path relative_path = file_path.lexically_relative(data_dir); - - // check type of file, skip BSAs and ESPs - if (!file_allowed(file_path)) { - continue; - } - - if (logging) { - spdlog::trace(L"Adding loose file to map: {}", relative_path.wstring()); - } + if (entry.is_regular_file()) { + const fs::path file_path = entry.path(); + fs::path relative_path = file_path.lexically_relative(data_dir); - updateFileMap(relative_path, nullptr); + // check type of file, skip BSAs and ESPs + if (!file_allowed(file_path)) { + continue; } - } catch (const std::exception& e) { + if (logging) { - spdlog::warn(L"Failed to add loose file to map, skipping {}: {}", entry.path().wstring(), convertToWstring(e.what())); + spdlog::trace(L"Adding loose file to map: {}", relative_path.wstring()); } - continue; + + updateFileMap(relative_path, nullptr); } } } @@ -523,7 +516,7 @@ vector BethesdaDirectory::findBSAFilesFromPluginName(const vector GAME_TYPE_MAP = { {"enderalse", BethesdaGame::GameType::ENDERAL_SE} }; -int main(int argc, char** argv) { +void mainRunner(int argc, char** argv) +{ // Find location of ParallaxGen.exe const filesystem::path EXE_PATH = getExecutablePath().parent_path(); @@ -280,3 +275,12 @@ int main(int argc, char** argv) { // Close Console exitWithUserInput(0); } + +int main(int argc, char** argv) { + try { + mainRunner(argc, argv); + } catch (const exception& ex) { + spdlog::critical("An unhandled exception occured, provide this message in your bug report: {}", ex.what()); + exitWithUserInput(1); + } +}