fix: Various issues with UTF-8 paths

This commit is contained in:
WerWolv
2022-06-30 19:39:06 +02:00
parent 96aa929c31
commit 3db50a690c
6 changed files with 27 additions and 8 deletions

View File

@@ -133,7 +133,7 @@ namespace hex::plugin::builtin {
if (!entry.is_regular_file())
continue;
fs::File file(entry.path().string(), fs::File::Mode::Read);
fs::File file(entry.path(), fs::File::Mode::Read);
if (!file.isValid())
continue;

View File

@@ -46,10 +46,10 @@ namespace hex::plugin::builtin {
} else {
ImGui::BeginDisabled(this->m_matching);
{
if (ImGui::BeginCombo("hex.builtin.view.yara.header.rules"_lang, this->m_rules[this->m_selectedRule].first.c_str())) {
if (ImGui::BeginCombo("hex.builtin.view.yara.header.rules"_lang, this->m_rules[this->m_selectedRule].first.string().c_str())) {
for (u32 i = 0; i < this->m_rules.size(); i++) {
const bool selected = (this->m_selectedRule == i);
if (ImGui::Selectable(this->m_rules[i].first.c_str(), selected))
if (ImGui::Selectable(this->m_rules[i].first.string().c_str(), selected))
this->m_selectedRule = i;
if (selected)
@@ -162,7 +162,7 @@ namespace hex::plugin::builtin {
std::error_code error;
for (const auto &entry : std::fs::recursive_directory_iterator(path, error)) {
if (entry.is_regular_file() && entry.path().extension() == ".yar") {
this->m_rules.emplace_back(std::fs::relative(entry.path(), std::fs::path(path)).string(), entry.path().string());
this->m_rules.emplace_back(std::fs::relative(entry.path(), path), entry.path());
}
}
}
@@ -207,7 +207,7 @@ namespace hex::plugin::builtin {
delete[] ptr;
},
this->m_rules[this->m_selectedRule].second.data());
fs::toShortPath(this->m_rules[this->m_selectedRule].second).string().data());
fs::File file(this->m_rules[this->m_selectedRule].second, fs::File::Mode::Read);