diff --git a/lib/external/libwolv b/lib/external/libwolv index a344d3968..97af34721 160000 --- a/lib/external/libwolv +++ b/lib/external/libwolv @@ -1 +1 @@ -Subproject commit a344d3968fc3cbe8a47a3fe28706985b39d0a4af +Subproject commit 97af34721993330697aa6ae76f6e99567918f687 diff --git a/lib/external/pattern_language b/lib/external/pattern_language index 545253e3d..1a2b1109b 160000 --- a/lib/external/pattern_language +++ b/lib/external/pattern_language @@ -1 +1 @@ -Subproject commit 545253e3d9be890a5e079d737b33bc00c41d6a0a +Subproject commit 1a2b1109bf671c25118106a0268e27a703dd57f8 diff --git a/lib/libimhex/source/helpers/tar.cpp b/lib/libimhex/source/helpers/tar.cpp index d7dee42f6..df401f471 100644 --- a/lib/libimhex/source/helpers/tar.cpp +++ b/lib/libimhex/source/helpers/tar.cpp @@ -90,11 +90,7 @@ namespace hex { bool Tar::contains(const std::fs::path &path) const { mtar_header_t header; - auto fixedPath = path.string(); - #if defined(OS_WINDOWS) - std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/'); - #endif - + const auto fixedPath = wolv::io::fs::toNormalizedPathString(path); return mtar_find(m_ctx.get(), fixedPath.c_str(), &header) == MTAR_ESUCCESS; } @@ -115,10 +111,7 @@ namespace hex { std::vector Tar::readVector(const std::fs::path &path) const { mtar_header_t header; - auto fixedPath = path.string(); - #if defined(OS_WINDOWS) - std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/'); - #endif + const auto fixedPath = wolv::io::fs::toNormalizedPathString(path); int ret = mtar_find(m_ctx.get(), fixedPath.c_str(), &header); if (ret != MTAR_ESUCCESS){ log::debug("Failed to read vector from path {} in tarred file {}: {}", @@ -143,18 +136,12 @@ namespace hex { for (const auto &part : path.parent_path()) { pathPart /= part; - auto fixedPath = pathPart.string(); - #if defined(OS_WINDOWS) - std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/'); - #endif + auto fixedPath = wolv::io::fs::toNormalizedPathString(pathPart); mtar_write_dir_header(m_ctx.get(), fixedPath.c_str()); } } - auto fixedPath = path.string(); - #if defined(OS_WINDOWS) - std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/'); - #endif + const auto fixedPath = wolv::io::fs::toNormalizedPathString(path); mtar_write_file_header(m_ctx.get(), fixedPath.c_str(), data.size()); mtar_write_data(m_ctx.get(), data.data(), data.size()); } diff --git a/main/gui/source/crash_handlers.cpp b/main/gui/source/crash_handlers.cpp index 2657c50d3..59987984d 100644 --- a/main/gui/source/crash_handlers.cpp +++ b/main/gui/source/crash_handlers.cpp @@ -44,8 +44,8 @@ namespace hex::crash { log::fatal(message); nlohmann::json crashData { - { "logFile", wolv::util::toUTF8String(hex::log::impl::getFile().getPath()) }, - { "project", wolv::util::toUTF8String(ProjectFile::getPath()) }, + { "logFile", wolv::io::fs::toNormalizedPathString(hex::log::impl::getFile().getPath()) }, + { "project", wolv::io::fs::toNormalizedPathString(ProjectFile::getPath()) }, }; for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Config)) { diff --git a/plugins/builtin/source/content/providers/disk_provider.cpp b/plugins/builtin/source/content/providers/disk_provider.cpp index 2920fab49..b9409808a 100644 --- a/plugins/builtin/source/content/providers/disk_provider.cpp +++ b/plugins/builtin/source/content/providers/disk_provider.cpp @@ -369,9 +369,9 @@ namespace hex::plugin::builtin { std::vector DiskProvider::getDataDescription() const { return { - { "hex.builtin.provider.disk.selected_disk"_lang, wolv::util::toUTF8String(m_path) }, - { "hex.builtin.provider.disk.disk_size"_lang, hex::toByteString(m_diskSize) }, - { "hex.builtin.provider.disk.sector_size"_lang, hex::toByteString(m_sectorSize) } + { "hex.builtin.provider.disk.selected_disk"_lang, wolv::util::toUTF8String(m_path) }, + { "hex.builtin.provider.disk.disk_size"_lang, hex::toByteString(m_diskSize) }, + { "hex.builtin.provider.disk.sector_size"_lang, hex::toByteString(m_sectorSize) } }; } @@ -497,7 +497,7 @@ namespace hex::plugin::builtin { } nlohmann::json DiskProvider::storeSettings(nlohmann::json settings) const { - settings["path"] = wolv::util::toUTF8String(m_path); + settings["path"] = wolv::io::fs::toNormalizedPathString(m_path); settings["friendly_name"] = m_friendlyName; @@ -527,7 +527,7 @@ namespace hex::plugin::builtin { std::variant DiskProvider::queryInformation(const std::string &category, const std::string &argument) { if (category == "file_path") - return wolv::util::toUTF8String(m_path); + return wolv::io::fs::toNormalizedPathString(m_path); else if (category == "sector_size") return m_sectorSize; else if (category == "friendly_name") diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index e1995c602..aaf28cb68 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -147,11 +147,11 @@ namespace hex::plugin::builtin { std::variant FileProvider::queryInformation(const std::string &category, const std::string &argument) { if (category == "file_path") - return wolv::util::toUTF8String(m_path); + return wolv::io::fs::toNormalizedPathString(m_path); else if (category == "file_name") - return wolv::util::toUTF8String(m_path.filename()); + return wolv::io::fs::toNormalizedPathString(m_path.filename()); else if (category == "file_extension") - return wolv::util::toUTF8String(m_path.extension()); + return wolv::io::fs::toNormalizedPathString(m_path.extension()); else if (category == "creation_time") return m_fileStats->st_ctime; else if (category == "access_time") @@ -279,9 +279,9 @@ namespace hex::plugin::builtin { nlohmann::json FileProvider::storeSettings(nlohmann::json settings) const { std::string path; if (auto projectPath = ProjectFile::getPath(); !projectPath.empty()) - path = wolv::util::toUTF8String(std::fs::proximate(m_path, projectPath.parent_path())); + path = wolv::io::fs::toNormalizedPathString(std::fs::proximate(m_path, projectPath.parent_path())); if (path.empty()) - path = wolv::util::toUTF8String(m_path); + path = wolv::io::fs::toNormalizedPathString(m_path); settings["path"] = path; diff --git a/plugins/builtin/source/content/providers/intel_hex_provider.cpp b/plugins/builtin/source/content/providers/intel_hex_provider.cpp index 634a3c360..6f4d902d5 100644 --- a/plugins/builtin/source/content/providers/intel_hex_provider.cpp +++ b/plugins/builtin/source/content/providers/intel_hex_provider.cpp @@ -282,7 +282,7 @@ namespace hex::plugin::builtin { } nlohmann::json IntelHexProvider::storeSettings(nlohmann::json settings) const { - settings["path"] = wolv::util::toUTF8String(m_sourceFilePath); + settings["path"] = wolv::io::fs::toNormalizedPathString(m_sourceFilePath); return Provider::storeSettings(settings); } diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index fee3873d9..1b560ed88 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -152,7 +152,7 @@ namespace hex::plugin::builtin { std::vector pathStrings; for (const auto &path : m_paths) { - pathStrings.push_back(wolv::util::toUTF8String(path)); + pathStrings.push_back(wolv::io::fs::toNormalizedPathString(path)); } return pathStrings; diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 8fa51beb5..bde4ce9cf 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -141,7 +141,7 @@ namespace hex::plugin::builtin { for (const auto &file : virtualFiles) { const auto &path = file->path; - auto currSegment = wolv::util::toUTF8String(*std::next(path.begin(), level)); + auto currSegment = wolv::io::fs::toNormalizedPathString(*std::next(path.begin(), level)); if (std::distance(path.begin(), path.end()) == ptrdiff_t(level + 1)) { ImGui::TableNextRow(); ImGui::TableNextColumn();