[VFS] Return more proper error codes in OpenFile

- Added handling for opening file with directory flag
This commit is contained in:
Gliniak
2026-04-21 21:58:49 +02:00
parent e3e57bdb47
commit e91faca1c4
2 changed files with 11 additions and 5 deletions

View File

@@ -230,7 +230,7 @@ X_STATUS VirtualFileSystem::OpenFile(Entry* root_entry,
: root_entry->ResolvePath(base_path);
if (!parent_entry) {
*out_action = FileAction::kDoesNotExist;
return X_STATUS_NO_SUCH_FILE;
return X_STATUS_OBJECT_PATH_NOT_FOUND;
}
auto file_name = xe::utf8::find_name_from_guest_path(path);
@@ -244,13 +244,17 @@ X_STATUS VirtualFileSystem::OpenFile(Entry* root_entry,
return X_STATUS_FILE_IS_A_DIRECTORY;
}
if (!(entry->attributes() & kFileAttributeDirectory) && is_directory) {
return X_STATUS_NOT_A_DIRECTORY;
}
// If the entry does not exist on the host then remove the cached entry
if (parent_entry) {
const xe::vfs::HostPathEntry* host_Path =
const xe::vfs::HostPathEntry* host_path =
dynamic_cast<const xe::vfs::HostPathEntry*>(parent_entry);
if (host_Path) {
auto const file_path = host_Path->host_path() / entry->name();
if (host_path) {
auto const file_path = host_path->host_path() / entry->name();
if (!std::filesystem::exists(file_path)) {
// Remove cached entry
@@ -268,7 +272,7 @@ X_STATUS VirtualFileSystem::OpenFile(Entry* root_entry,
// Must exist.
if (!entry) {
*out_action = FileAction::kDoesNotExist;
return X_STATUS_NO_SUCH_FILE;
return X_STATUS_OBJECT_NAME_NOT_FOUND;
}
break;
case FileDisposition::kCreate: