From 4cd390ab0205c893f907bafe07ac65412916e65f Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 5 Jul 2022 00:00:00 +0200 Subject: [PATCH] fix: Various more unicode issues --- .../include/hex/api/content_registry.hpp | 6 +++ .../include/hex/ui/imgui_imhex_extensions.h | 1 + lib/libimhex/source/api/content_registry.cpp | 52 +++++++++++++++++++ lib/libimhex/source/api/plugin_manager.cpp | 2 - lib/libimhex/source/helpers/fs.cpp | 44 ++++++++-------- lib/libimhex/source/helpers/net.cpp | 4 +- .../source/helpers/project_file_handler.cpp | 6 +-- .../source/ui/imgui_imhex_extensions.cpp | 4 ++ main/source/window/window.cpp | 2 +- .../builtin/source/content/tools_entries.cpp | 31 ++++++----- .../content/views/view_pattern_editor.cpp | 4 +- .../source/content/views/view_yara.cpp | 2 +- .../builtin/source/content/welcome_screen.cpp | 8 +-- 13 files changed, 115 insertions(+), 51 deletions(-) diff --git a/lib/libimhex/include/hex/api/content_registry.hpp b/lib/libimhex/include/hex/api/content_registry.hpp index c1a15e014..ba4f22e1d 100644 --- a/lib/libimhex/include/hex/api/content_registry.hpp +++ b/lib/libimhex/include/hex/api/content_registry.hpp @@ -71,17 +71,23 @@ namespace hex { void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 defaultValue, const Callback &callback, bool requiresRestart = false); void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::string &defaultValue, const Callback &callback, bool requiresRestart = false); + void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::u8string &defaultValue, const Callback &callback, bool requiresRestart = false); void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &defaultValue, const Callback &callback, bool requiresRestart = false); + void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &defaultValue, const Callback &callback, bool requiresRestart = false); void addCategoryDescription(const std::string &unlocalizedCategory, const std::string &unlocalizedCategoryDescription); void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 value); void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::string &value); + void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::u8string &value); void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &value); + void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &value); i64 read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 defaultValue); std::string read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::string &defaultValue); + std::u8string read(const std::string &unlocalizedCategory, const std::u8string &unlocalizedName, const std::string &defaultValue); std::vector read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &defaultValue = {}); + std::vector read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &defaultValue = {}); std::map> &getEntries(); std::map &getCategoryDescriptions(); diff --git a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h index f554259d5..45c4a601e 100644 --- a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h +++ b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h @@ -130,6 +130,7 @@ namespace ImGui { } bool InputText(const char* label, std::string &buffer, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); + bool InputText(const char *label, std::u8string &buffer, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); bool InputTextMultiline(const char* label, std::string &buffer, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); bool InputScalarCallback(const char* label, ImGuiDataType data_type, void* p_data, const char* format, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data); diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index 238725728..4420a3bd3 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -80,6 +80,19 @@ namespace hex { json[unlocalizedCategory][unlocalizedName] = std::string(defaultValue); } + void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::u8string &defaultValue, const Callback &callback, bool requiresRestart) { + log::info("Registered new string setting: [{}]: {}", unlocalizedCategory, unlocalizedName); + + getCategoryEntry(unlocalizedCategory)->second.emplace_back(Entry { unlocalizedName, requiresRestart, callback }); + + auto &json = getSettingsData(); + + if (!json.contains(unlocalizedCategory)) + json[unlocalizedCategory] = nlohmann::json::object(); + if (!json[unlocalizedCategory].contains(unlocalizedName) || !json[unlocalizedCategory][unlocalizedName].is_string()) + json[unlocalizedCategory][unlocalizedName] = defaultValue; + } + void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &defaultValue, const Callback &callback, bool requiresRestart) { log::info("Registered new string array setting: [{}]: {}", unlocalizedCategory, unlocalizedName); @@ -93,6 +106,19 @@ namespace hex { json[unlocalizedCategory][unlocalizedName] = defaultValue; } + void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &defaultValue, const Callback &callback, bool requiresRestart) { + log::info("Registered new u8string array setting: [{}]: {}", unlocalizedCategory, unlocalizedName); + + getCategoryEntry(unlocalizedCategory)->second.emplace_back(Entry { unlocalizedName, requiresRestart, callback }); + + auto &json = getSettingsData(); + + if (!json.contains(unlocalizedCategory)) + json[unlocalizedCategory] = nlohmann::json::object(); + if (!json[unlocalizedCategory].contains(unlocalizedName) || !json[unlocalizedCategory][unlocalizedName].is_array()) + json[unlocalizedCategory][unlocalizedName] = defaultValue; + } + void addCategoryDescription(const std::string &unlocalizedCategory, const std::string &unlocalizedCategoryDescription) { getCategoryDescriptions()[unlocalizedCategory] = unlocalizedCategoryDescription; } @@ -124,6 +150,15 @@ namespace hex { json[unlocalizedCategory][unlocalizedName] = value; } + void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &value) { + auto &json = getSettingsData(); + + if (!json.contains(unlocalizedCategory)) + json[unlocalizedCategory] = nlohmann::json::object(); + + json[unlocalizedCategory][unlocalizedName] = value; + } + i64 read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 defaultValue) { auto &json = getSettingsData(); @@ -170,6 +205,23 @@ namespace hex { return json[unlocalizedCategory][unlocalizedName].get>(); } + std::vector read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector &defaultValue) { + auto &json = getSettingsData(); + + if (!json.contains(unlocalizedCategory)) + return defaultValue; + if (!json[unlocalizedCategory].contains(unlocalizedName)) + return defaultValue; + + if (!json[unlocalizedCategory][unlocalizedName].is_array()) + json[unlocalizedCategory][unlocalizedName] = defaultValue; + + if (!json[unlocalizedCategory][unlocalizedName].array().empty() && !json[unlocalizedCategory][unlocalizedName][0].is_string()) + json[unlocalizedCategory][unlocalizedName] = defaultValue; + + return json[unlocalizedCategory][unlocalizedName].get>(); + } + std::map> &getEntries() { static std::map> entries; diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index 95c3f120a..6bc78d3f5 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -24,8 +24,6 @@ namespace hex { } #endif - auto pluginName = std::fs::path(path).stem().string(); - this->m_initializePluginFunction = getPluginFunction("initializePlugin"); this->m_getPluginNameFunction = getPluginFunction("getPluginName"); this->m_getPluginAuthorFunction = getPluginFunction("getPluginAuthor"); diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index 25ecf024f..6a23849e5 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -205,39 +205,39 @@ namespace hex::fs { switch (path) { case ImHexPath::Patterns: - result.push_back((applicationSupportDirPath / "patterns").string()); + result.push_back(applicationSupportDirPath / "patterns"); break; case ImHexPath::PatternsInclude: - result.push_back((applicationSupportDirPath / "includes").string()); + result.push_back(applicationSupportDirPath / "includes"); break; case ImHexPath::Magic: - result.push_back((applicationSupportDirPath / "magic").string()); + result.push_back(applicationSupportDirPath / "magic"); break; case ImHexPath::Python: - result.push_back((applicationSupportDirPath / "python").string()); + result.push_back(applicationSupportDirPath / "python"); break; case ImHexPath::Plugins: std::transform(paths.begin(), paths.end(), std::back_inserter(result), [](auto &path) { - return (path / "plugins").string(); + return path / "plugins"; }); break; case ImHexPath::Yara: - result.push_back((applicationSupportDirPath / "yara").string()); + result.push_back(applicationSupportDirPath / "yara"); break; case ImHexPath::Config: - result.push_back((applicationSupportDirPath / "config").string()); + result.push_back(applicationSupportDirPath / "config"); break; case ImHexPath::Resources: - result.push_back((applicationSupportDirPath / "resources").string()); + result.push_back(applicationSupportDirPath / "resources"); break; case ImHexPath::Constants: - result.push_back((applicationSupportDirPath / "constants").string()); + result.push_back(applicationSupportDirPath / "constants"); break; case ImHexPath::Encodings: - result.push_back((applicationSupportDirPath / "encodings").string()); + result.push_back(applicationSupportDirPath / "encodings"); break; case ImHexPath::Logs: - result.push_back((applicationSupportDirPath / "logs").string()); + result.push_back(applicationSupportDirPath / "logs"); break; default: hex::unreachable(); @@ -258,43 +258,43 @@ namespace hex::fs { switch (path) { case ImHexPath::Patterns: addUserDirs(dataDirs); - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "patterns").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "patterns"; }); break; case ImHexPath::PatternsInclude: addUserDirs(dataDirs); - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "includes").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "includes"; }); break; case ImHexPath::Magic: addUserDirs(dataDirs); - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "magic").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "magic"; }); break; case ImHexPath::Python: addUserDirs(dataDirs); - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p).string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p; }); break; case ImHexPath::Plugins: - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "plugins").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "plugins"; }); break; case ImHexPath::Yara: addUserDirs(dataDirs); - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "yara").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "yara"; }); break; case ImHexPath::Config: - std::transform(configDirs.begin(), configDirs.end(), std::back_inserter(result), [](auto p) { return (p / "imhex").string(); }); + std::transform(configDirs.begin(), configDirs.end(), std::back_inserter(result), [](auto p) { return p / "imhex"; }); break; case ImHexPath::Resources: - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "resources").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "resources"; }); break; case ImHexPath::Constants: addUserDirs(dataDirs); - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "constants").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "constants"; }); break; case ImHexPath::Encodings: addUserDirs(dataDirs); - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "encodings").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "encodings"; }); break; case ImHexPath::Logs: - std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "logs").string(); }); + std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return p / "logs"; }); break; default: hex::unreachable(); diff --git a/lib/libimhex/source/helpers/net.cpp b/lib/libimhex/source/helpers/net.cpp index 3c930fb02..9ec22e8de 100644 --- a/lib/libimhex/source/helpers/net.cpp +++ b/lib/libimhex/source/helpers/net.cpp @@ -180,7 +180,7 @@ namespace hex { ON_SCOPE_EXIT { this->m_transmissionActive.unlock(); }; - fs::File file(filePath.string(), fs::File::Mode::Read); + fs::File file(filePath, fs::File::Mode::Read); if (!file.isValid()) return Response { 400, {} }; @@ -218,7 +218,7 @@ namespace hex { ON_SCOPE_EXIT { this->m_transmissionActive.unlock(); }; - fs::File file(filePath.string(), fs::File::Mode::Create); + fs::File file(filePath, fs::File::Mode::Create); if (!file.isValid()) return Response { 400 }; diff --git a/lib/libimhex/source/helpers/project_file_handler.cpp b/lib/libimhex/source/helpers/project_file_handler.cpp index c3c71b0ce..e3605e150 100644 --- a/lib/libimhex/source/helpers/project_file_handler.cpp +++ b/lib/libimhex/source/helpers/project_file_handler.cpp @@ -52,10 +52,10 @@ namespace hex { json projectFileData; try { - std::ifstream projectFile(filePath.c_str()); + std::ifstream projectFile(filePath); projectFile >> projectFileData; - ProjectFile::s_filePath = std::fs::path(projectFileData["filePath"].get()); + ProjectFile::s_filePath = std::fs::path(projectFileData["filePath"].get()); ProjectFile::s_pattern = projectFileData["pattern"]; ProjectFile::s_patches = projectFileData["patches"].get(); ProjectFile::s_dataProcessorContent = projectFileData["dataProcessor"]; @@ -89,7 +89,7 @@ namespace hex { filePath = ProjectFile::s_currProjectFilePath; try { - projectFileData["filePath"] = ProjectFile::s_filePath.string(); + projectFileData["filePath"] = ProjectFile::s_filePath.u8string(); projectFileData["pattern"] = ProjectFile::s_pattern; projectFileData["patches"] = ProjectFile::s_patches; projectFileData["dataProcessor"] = ProjectFile::s_dataProcessorContent; diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 354d32e7e..d74f9808a 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -553,6 +553,10 @@ namespace ImGui { return ImGui::InputText(label, buffer.data(), buffer.size() + 1, ImGuiInputTextFlags_CallbackResize | flags, ImGui::UpdateStringSizeCallback, &buffer); } + bool InputText(const char *label, std::u8string &buffer, ImGuiInputTextFlags flags) { + return ImGui::InputText(label, reinterpret_cast(buffer.data()), buffer.size() + 1, ImGuiInputTextFlags_CallbackResize | flags, ImGui::UpdateStringSizeCallback, &buffer); + } + bool InputTextMultiline(const char *label, std::string &buffer, const ImVec2 &size, ImGuiInputTextFlags flags) { return ImGui::InputTextMultiline(label, buffer.data(), buffer.size() + 1, size, ImGuiInputTextFlags_CallbackResize | flags, ImGui::UpdateStringSizeCallback, &buffer); } diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index a48e7c454..082ca85dc 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -118,7 +118,7 @@ namespace hex { return; for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Config)) { - if (ProjectFile::store((std::fs::path(path) / CrashBackupFileName).string())) + if (ProjectFile::store(std::fs::path(path) / CrashBackupFileName)) break; } }); diff --git a/plugins/builtin/source/content/tools_entries.cpp b/plugins/builtin/source/content/tools_entries.cpp index ee8b25bdb..a1281c7cb 100644 --- a/plugins/builtin/source/content/tools_entries.cpp +++ b/plugins/builtin/source/content/tools_entries.cpp @@ -739,7 +739,7 @@ namespace hex::plugin::builtin { void drawFileToolShredder() { static bool shredding = false; - static auto selectedFile = [] { std::string s; s.reserve(0x1000); return s; }(); + static std::u8string selectedFile; static bool fastMode = false; ImGui::TextUnformatted("hex.builtin.tools.file_tools.shredder.warning"_lang); @@ -754,7 +754,7 @@ namespace hex::plugin::builtin { ImGui::SameLine(); if (ImGui::Button("...")) { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { - selectedFile = path.string(); + selectedFile = path.u8string(); }); } @@ -883,11 +883,11 @@ namespace hex::plugin::builtin { 1 }; - static bool splitting = false; - static auto selectedFile = [] { std::string s; s.reserve(0x1000); return s; }(); - static auto baseOutputPath = [] { std::string s; s.reserve(0x1000); return s; }(); - static u64 splitSize = sizes[0]; - static int selectedItem = 0; + static bool splitting = false; + static std::u8string selectedFile; + static std::u8string baseOutputPath; + static u64 splitSize = sizes[0]; + static int selectedItem = 0; if (ImGui::BeginChild("split_settings", { 0, ImGui::GetTextLineHeightWithSpacing() * 7 }, true, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) { ImGui::BeginDisabled(splitting); @@ -896,7 +896,7 @@ namespace hex::plugin::builtin { ImGui::SameLine(); if (ImGui::Button("...##input")) { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { - selectedFile = path.string(); + selectedFile = path.u8string(); }); } ImGui::SameLine(); @@ -906,7 +906,7 @@ namespace hex::plugin::builtin { ImGui::SameLine(); if (ImGui::Button("...##output")) { fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) { - baseOutputPath = path.string(); + baseOutputPath = path.u8string(); }); } ImGui::SameLine(); @@ -960,7 +960,10 @@ namespace hex::plugin::builtin { for (u64 offset = 0; offset < file.getSize(); offset += splitSize) { task.update(offset); - fs::File partFile(baseOutputPath + hex::format(".{:05}", index), fs::File::Mode::Create); + std::fs::path path = baseOutputPath; + path += hex::format(".{:05}", index); + + fs::File partFile(path, fs::File::Mode::Create); if (!partFile.isValid()) { View::showErrorPopup(hex::format("hex.builtin.tools.file_tools.splitter.error.create"_lang, index)); @@ -986,8 +989,8 @@ namespace hex::plugin::builtin { void drawFileToolCombiner() { static bool combining = false; - static std::vector files; - static auto outputPath = [] { std::string s; s.reserve(0x1000); return s; }(); + static std::vector files; + static std::u8string outputPath; static u32 selectedIndex; if (ImGui::BeginTable("files_table", 2, ImGuiTableFlags_SizingStretchProp)) { @@ -1035,7 +1038,7 @@ namespace hex::plugin::builtin { { if (ImGui::Button("hex.builtin.tools.file_tools.combiner.add"_lang)) { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { - files.push_back(path.string()); + files.push_back(path); }); } ImGui::SameLine(); @@ -1059,7 +1062,7 @@ namespace hex::plugin::builtin { ImGui::SameLine(); if (ImGui::Button("...")) { fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) { - outputPath = path.string(); + outputPath = path.u8string(); }); } ImGui::SameLine(); diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index cd90a4f70..603869579 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -185,7 +185,7 @@ namespace hex::plugin::builtin { } ContentRegistry::FileHandler::add({ ".hexpat", ".pat" }, [](const std::fs::path &path) -> bool { - fs::File file(path.string(), fs::File::Mode::Read); + fs::File file(path, fs::File::Mode::Read); if (file.isValid()) { EventManager::post(file.readString()); @@ -619,7 +619,7 @@ namespace hex::plugin::builtin { confirmButtons( "hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang, [this] { - this->loadPatternFile(this->m_possiblePatternFiles[this->m_selectedPatternFile].string()); + this->loadPatternFile(this->m_possiblePatternFiles[this->m_selectedPatternFile]); ImGui::CloseCurrentPopup(); }, [] { ImGui::CloseCurrentPopup(); }); if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) diff --git a/plugins/builtin/source/content/views/view_yara.cpp b/plugins/builtin/source/content/views/view_yara.cpp index 0fca028e5..2762e1afa 100644 --- a/plugins/builtin/source/content/views/view_yara.cpp +++ b/plugins/builtin/source/content/views/view_yara.cpp @@ -191,7 +191,7 @@ namespace hex::plugin::builtin { [](const char *includeName, const char *, const char *, void *userData) -> const char * { auto currFilePath = static_cast(userData); - fs::File file((std::fs::path(currFilePath).parent_path() / includeName).string(), fs::File::Mode::Read); + fs::File file(std::fs::path(currFilePath).parent_path() / includeName, fs::File::Mode::Read); if (!file.isValid()) return nullptr; diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index 4a05effca..6e1315e6c 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -84,7 +84,7 @@ namespace hex::plugin::builtin { auto width = ImGui::GetWindowWidth(); ImGui::SetCursorPosX(width / 9); if (ImGui::Button("hex.builtin.welcome.safety_backup.restore"_lang, ImVec2(width / 3, 0))) { - ProjectFile::load(s_safetyBackupPath.string()); + ProjectFile::load(s_safetyBackupPath); ProjectFile::markDirty(); ProjectFile::clearProjectFilePath(); @@ -403,9 +403,9 @@ namespace hex::plugin::builtin { } { - std::vector recentFilesVector; + std::vector recentFilesVector; for (const auto &recentPath : s_recentFilePaths) - recentFilesVector.push_back(recentPath.string()); + recentFilesVector.push_back(recentPath.u8string()); ContentRegistry::Settings::write("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files", recentFilesVector); } @@ -450,7 +450,7 @@ namespace hex::plugin::builtin { } } - for (const auto &pathString : ContentRegistry::Settings::read("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files")) { + for (const auto &pathString : ContentRegistry::Settings::read("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files", std::vector{ })) { std::fs::path path = std::u8string(pathString.begin(), pathString.end()); if (fs::exists(path)) s_recentFilePaths.emplace_back(path);