fix: File provider not erroring out correctly when selecting a folder to open

(cherry picked from commit 8e7bd4b98a)
This commit is contained in:
WerWolv
2025-12-23 10:51:52 +01:00
parent b55e71e0a6
commit c51f68d0fb
2 changed files with 4 additions and 0 deletions

View File

@@ -431,6 +431,7 @@
"hex.builtin.provider.file": "Regular File",
"hex.builtin.provider.file.error.open": "Failed to open file {}: {}",
"hex.builtin.provider.file.error.already_open": "Same file is already open",
"hex.builtin.provider.file.error.is_directory": "Selected entry '{}' is a directory",
"hex.builtin.provider.file.access": "Last access time",
"hex.builtin.provider.file.creation": "Creation time",
"hex.builtin.provider.file.menu.direct_access": "Direct access file",

View File

@@ -230,6 +230,9 @@ namespace hex::plugin::builtin {
m_readable = true;
m_writable = true;
if (wolv::io::fs::isDirectory(m_path))
return OpenResult::failure(fmt::format("hex.builtin.provider.file.error.is_directory"_lang, m_path.string()));
wolv::io::File file(m_path, wolv::io::File::Mode::Write);
if (!file.isValid()) {
m_writable = false;