impr: Only store paths with forward slashes in project files

Fixes #1657
This commit is contained in:
WerWolv
2024-05-08 21:30:20 +02:00
parent adbcc48de7
commit 19c02be673
9 changed files with 21 additions and 34 deletions

View File

@@ -369,9 +369,9 @@ namespace hex::plugin::builtin {
std::vector<DiskProvider::Description> 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<std::string, i128> 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")

View File

@@ -147,11 +147,11 @@ namespace hex::plugin::builtin {
std::variant<std::string, i128> 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;

View File

@@ -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);
}

View File

@@ -152,7 +152,7 @@ namespace hex::plugin::builtin {
std::vector<std::string> pathStrings;
for (const auto &path : m_paths) {
pathStrings.push_back(wolv::util::toUTF8String(path));
pathStrings.push_back(wolv::io::fs::toNormalizedPathString(path));
}
return pathStrings;

View File

@@ -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();