From ea5175cab546d031718e884b3d029fbcbede6924 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Thu, 12 Feb 2015 21:52:46 -0800 Subject: [PATCH] Fixing path issues for host FS. --- src/xenia/kernel/fs/devices/host_path_device.cc | 6 +++++- src/xenia/kernel/fs/devices/host_path_entry.cc | 4 ++-- src/xenia/kernel/xboxkrnl_io.cc | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/xenia/kernel/fs/devices/host_path_device.cc b/src/xenia/kernel/fs/devices/host_path_device.cc index 03efc1b97..bec4fc39f 100644 --- a/src/xenia/kernel/fs/devices/host_path_device.cc +++ b/src/xenia/kernel/fs/devices/host_path_device.cc @@ -9,6 +9,7 @@ #include "xenia/kernel/fs/devices/host_path_device.h" +#include "poly/fs.h" #include "xenia/kernel/fs/devices/host_path_entry.h" #include "xenia/kernel/objects/xfile.h" @@ -33,8 +34,11 @@ std::unique_ptr HostPathDevice::ResolvePath(const char* path) { auto full_path = poly::join_paths(local_path_, rel_path); full_path = poly::fix_path_separators(full_path); + if (!poly::fs::PathExists(full_path)) { + return nullptr; + } + // TODO(benvanik): get file info - // TODO(benvanik): fail if does not exit // TODO(benvanik): switch based on type return std::make_unique(this, path, full_path); diff --git a/src/xenia/kernel/fs/devices/host_path_entry.cc b/src/xenia/kernel/fs/devices/host_path_entry.cc index 3eddc46cf..32a0de4d2 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.cc +++ b/src/xenia/kernel/fs/devices/host_path_entry.cc @@ -74,9 +74,9 @@ X_STATUS HostPathEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length, if (handle == INVALID_HANDLE_VALUE) { std::wstring target_path = local_path_; if (!file_name) { - target_path += L"*"; + target_path = poly::join_paths(target_path, L"*"); } else { - target_path += poly::to_wstring(file_name); + target_path = poly::join_paths(target_path, poly::to_wstring(file_name)); } handle = find_file_ = FindFirstFile(target_path.c_str(), &ffd); if (handle == INVALID_HANDLE_VALUE) { diff --git a/src/xenia/kernel/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl_io.cc index bda5e37f4..fa8d30fee 100644 --- a/src/xenia/kernel/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl_io.cc @@ -117,9 +117,9 @@ X_STATUS NtCreateFile(PPCContext* ppc_state, KernelState* state, } else { // Open the file/directory. result = fs->Open(std::move(entry), state, - desired_access == FileAccess::X_GENERIC_READ - ? fs::Mode::READ - : fs::Mode::READ_WRITE, + desired_access & FileAccess::X_GENERIC_WRITE + ? fs::Mode::READ_WRITE + : fs::Mode::READ, false, // TODO(benvanik): pick async mode, if needed. &file); }