From c7276454d7777babb81d93f5ee42458fcbd48fe3 Mon Sep 17 00:00:00 2001 From: gibbed Date: Sun, 19 Jan 2014 02:05:51 -0800 Subject: [PATCH] Added file_name argument to QueryDirectory. --- src/xenia/kernel/fs/devices/disc_image_entry.cc | 2 +- src/xenia/kernel/fs/devices/disc_image_entry.h | 3 ++- src/xenia/kernel/fs/devices/disc_image_file.cc | 6 +++--- src/xenia/kernel/fs/devices/disc_image_file.h | 2 +- src/xenia/kernel/fs/devices/host_path_entry.cc | 2 +- src/xenia/kernel/fs/devices/host_path_entry.h | 3 ++- src/xenia/kernel/fs/devices/host_path_file.cc | 5 +++-- src/xenia/kernel/fs/devices/host_path_file.h | 2 +- .../kernel/fs/devices/stfs_container_entry.cc | 2 +- .../kernel/fs/devices/stfs_container_entry.h | 3 ++- .../kernel/fs/devices/stfs_container_file.cc | 6 +++--- .../kernel/fs/devices/stfs_container_file.h | 2 +- src/xenia/kernel/fs/entry.h | 3 ++- src/xenia/kernel/objects/xfile.h | 3 ++- src/xenia/kernel/xboxkrnl_io.cc | 17 +++++++++-------- 15 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.cc b/src/xenia/kernel/fs/devices/disc_image_entry.cc index ead4fd58d..42518c648 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.cc +++ b/src/xenia/kernel/fs/devices/disc_image_entry.cc @@ -65,7 +65,7 @@ X_STATUS DiscImageEntry::QueryInfo(XFileInfo* out_info) { } X_STATUS DiscImageEntry::QueryDirectory( - XDirectoryInfo* out_info, size_t length, bool restart) { + XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart) { XEASSERTNOTNULL(out_info); if (restart == true && gdfx_entry_iterator_ != gdfx_entry_->children.end()) { diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.h b/src/xenia/kernel/fs/devices/disc_image_entry.h index 7f40920ef..4ed31b5ef 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.h +++ b/src/xenia/kernel/fs/devices/disc_image_entry.h @@ -33,7 +33,8 @@ public: GDFXEntry* gdfx_entry() const { return gdfx_entry_; } virtual X_STATUS QueryInfo(XFileInfo* out_info); - virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, bool restart); + virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, + size_t length, const char* file_name, bool restart); virtual bool can_map() { return true; } virtual MemoryMapping* CreateMemoryMapping( diff --git a/src/xenia/kernel/fs/devices/disc_image_file.cc b/src/xenia/kernel/fs/devices/disc_image_file.cc index 8f16a1276..11f1d5bc3 100644 --- a/src/xenia/kernel/fs/devices/disc_image_file.cc +++ b/src/xenia/kernel/fs/devices/disc_image_file.cc @@ -44,9 +44,9 @@ X_STATUS DiscImageFile::QueryInfo(XFileInfo* out_info) { return entry_->QueryInfo(out_info); } -X_STATUS DiscImageFile::QueryDirectory( - XDirectoryInfo* out_info, size_t length, bool restart) { - return entry_->QueryDirectory(out_info, length, restart); +X_STATUS DiscImageFile::QueryDirectory(XDirectoryInfo* out_info, + size_t length, const char* file_name, bool restart) { + return entry_->QueryDirectory(out_info, length, file_name, restart); } X_STATUS DiscImageFile::ReadSync( diff --git a/src/xenia/kernel/fs/devices/disc_image_file.h b/src/xenia/kernel/fs/devices/disc_image_file.h index 0383801e0..2671e0420 100644 --- a/src/xenia/kernel/fs/devices/disc_image_file.h +++ b/src/xenia/kernel/fs/devices/disc_image_file.h @@ -35,7 +35,7 @@ public: virtual X_STATUS QueryInfo(XFileInfo* out_info); virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, - size_t length, bool restart); + size_t length, const char* file_name, bool restart); protected: virtual X_STATUS ReadSync( diff --git a/src/xenia/kernel/fs/devices/host_path_entry.cc b/src/xenia/kernel/fs/devices/host_path_entry.cc index 98db20b96..2f98317ad 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.cc +++ b/src/xenia/kernel/fs/devices/host_path_entry.cc @@ -74,7 +74,7 @@ X_STATUS HostPathEntry::QueryInfo(XFileInfo* out_info) { } X_STATUS HostPathEntry::QueryDirectory( - XDirectoryInfo* out_info, size_t length, bool restart) { + XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart) { XEASSERTNOTNULL(out_info); WIN32_FIND_DATA ffd; diff --git a/src/xenia/kernel/fs/devices/host_path_entry.h b/src/xenia/kernel/fs/devices/host_path_entry.h index 727f62493..3406033b0 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.h +++ b/src/xenia/kernel/fs/devices/host_path_entry.h @@ -30,7 +30,8 @@ public: const xechar_t* local_path() { return local_path_; } virtual X_STATUS QueryInfo(XFileInfo* out_info); - virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, bool restart); + virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, + size_t length, const char* file_name, bool restart); virtual bool can_map() { return true; } virtual MemoryMapping* CreateMemoryMapping( diff --git a/src/xenia/kernel/fs/devices/host_path_file.cc b/src/xenia/kernel/fs/devices/host_path_file.cc index 072855a9d..4dda9cb0b 100644 --- a/src/xenia/kernel/fs/devices/host_path_file.cc +++ b/src/xenia/kernel/fs/devices/host_path_file.cc @@ -44,8 +44,9 @@ X_STATUS HostPathFile::QueryInfo(XFileInfo* out_info) { return entry_->QueryInfo(out_info); } -X_STATUS HostPathFile::QueryDirectory(XDirectoryInfo* out_info, size_t length, bool restart) { - return entry_->QueryDirectory(out_info, length, restart); +X_STATUS HostPathFile::QueryDirectory(XDirectoryInfo* out_info, + size_t length, const char* file_name, bool restart) { + return entry_->QueryDirectory(out_info, length, file_name, restart); } X_STATUS HostPathFile::ReadSync( diff --git a/src/xenia/kernel/fs/devices/host_path_file.h b/src/xenia/kernel/fs/devices/host_path_file.h index dce537f8e..797ee552b 100644 --- a/src/xenia/kernel/fs/devices/host_path_file.h +++ b/src/xenia/kernel/fs/devices/host_path_file.h @@ -35,7 +35,7 @@ public: virtual X_STATUS QueryInfo(XFileInfo* out_info); virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, - size_t length, bool restart); + size_t length, const char* file_name, bool restart); protected: virtual X_STATUS ReadSync( diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.cc b/src/xenia/kernel/fs/devices/stfs_container_entry.cc index 897dfe060..05fb7752d 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.cc @@ -44,7 +44,7 @@ X_STATUS STFSContainerEntry::QueryInfo(XFileInfo* out_info) { } X_STATUS STFSContainerEntry::QueryDirectory( - XDirectoryInfo* out_info, size_t length, bool restart) { + XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart) { XEASSERTNOTNULL(out_info); if (restart && stfs_entry_iterator_ != stfs_entry_->children.end()) { diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.h b/src/xenia/kernel/fs/devices/stfs_container_entry.h index b35573672..2f9129595 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.h +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.h @@ -33,7 +33,8 @@ public: STFSEntry* stfs_entry() const { return stfs_entry_; } virtual X_STATUS QueryInfo(XFileInfo* out_info); - virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, bool restart); + virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, + size_t length, const char* file_name, bool restart); virtual X_STATUS Open( KernelState* kernel_state, diff --git a/src/xenia/kernel/fs/devices/stfs_container_file.cc b/src/xenia/kernel/fs/devices/stfs_container_file.cc index b260dc001..dba66e10c 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_file.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_file.cc @@ -44,9 +44,9 @@ X_STATUS STFSContainerFile::QueryInfo(XFileInfo* out_info) { return entry_->QueryInfo(out_info); } -X_STATUS STFSContainerFile::QueryDirectory( - XDirectoryInfo* out_info, size_t length, bool restart) { - return entry_->QueryDirectory(out_info, length, restart); +X_STATUS STFSContainerFile::QueryDirectory(XDirectoryInfo* out_info, + size_t length, const char* file_name, bool restart) { + return entry_->QueryDirectory(out_info, length, file_name, restart); } X_STATUS STFSContainerFile::ReadSync( diff --git a/src/xenia/kernel/fs/devices/stfs_container_file.h b/src/xenia/kernel/fs/devices/stfs_container_file.h index 52933e26a..3f3bc30b1 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_file.h +++ b/src/xenia/kernel/fs/devices/stfs_container_file.h @@ -35,7 +35,7 @@ public: virtual X_STATUS QueryInfo(XFileInfo* out_info); virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, - size_t length, bool restart); + size_t length, const char* file_name, bool restart); protected: virtual X_STATUS ReadSync( diff --git a/src/xenia/kernel/fs/entry.h b/src/xenia/kernel/fs/entry.h index 0e33d94e4..29a7ba341 100644 --- a/src/xenia/kernel/fs/entry.h +++ b/src/xenia/kernel/fs/entry.h @@ -60,7 +60,8 @@ public: const char* name() const { return name_; } virtual X_STATUS QueryInfo(XFileInfo* out_info) = 0; - virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, bool restart) = 0; + virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, + size_t length, const char* file_name, bool restart) = 0; virtual bool can_map() { return false; } virtual MemoryMapping* CreateMemoryMapping( diff --git a/src/xenia/kernel/objects/xfile.h b/src/xenia/kernel/objects/xfile.h index 635342e3d..5213e6fdd 100644 --- a/src/xenia/kernel/objects/xfile.h +++ b/src/xenia/kernel/objects/xfile.h @@ -95,7 +95,8 @@ public: void set_position(size_t value) { position_ = value; } virtual X_STATUS QueryInfo(XFileInfo* out_info) = 0; - virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, bool restart) = 0; + virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, + size_t length, const char* file_name, bool restart) = 0; X_STATUS Read(void* buffer, size_t buffer_length, size_t byte_offset, size_t* out_bytes_read); diff --git a/src/xenia/kernel/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl_io.cc index ea80b0db4..374ad7619 100644 --- a/src/xenia/kernel/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl_io.cc @@ -60,6 +60,9 @@ SHIM_CALL NtCreateFile_shim( uint32_t info = X_FILE_DOES_NOT_EXIST; uint32_t handle; + FileSystem* fs = state->file_system(); + Entry* entry; + XFile* root_file = NULL; if (attrs.root_directory != 0xFFFFFFFD) { // ObDosDevices result = state->object_table()->GetObject( @@ -70,8 +73,7 @@ SHIM_CALL NtCreateFile_shim( } // Resolve the file using the virtual file system. - FileSystem* fs = state->file_system(); - Entry* entry = fs->ResolvePath(attrs.object_name.buffer); + entry = fs->ResolvePath(attrs.object_name.buffer); XFile* file = NULL; if (entry && entry->type() == Entry::kTypeFile) { // Open the file. @@ -513,15 +515,14 @@ SHIM_CALL NtQueryDirectoryFile_shim( return; } - /* + const char* file_name = NULL; if (file_name_ptr != 0) { + // it's a PANSI_STRING or whatever. if (SHIM_MEM_16(file_name_ptr + 0) != 0 || - SHIM_MEM_16(file_name_ptr + 2) != 0) { - const char* file_name = (const char *)SHIM_MEM_ADDR(SHIM_MEM_32(file_name_ptr + 4)); - XEASSERT(strcmp(file_name, "*.*") == 0); + SHIM_MEM_16(file_name_ptr + 2) != 0) { + file_name = (const char*)SHIM_MEM_ADDR(SHIM_MEM_32(file_name_ptr + 4)); } } - */ X_STATUS result = X_STATUS_UNSUCCESSFUL; uint32_t info = 0; @@ -531,7 +532,7 @@ SHIM_CALL NtQueryDirectoryFile_shim( file_handle, (XObject**)&file); if (XSUCCEEDED(result)) { XDirectoryInfo* dir_info = (XDirectoryInfo*)xe_calloc(length); - result = file->QueryDirectory(dir_info, length, restart_scan != 0); + result = file->QueryDirectory(dir_info, length, file_name, restart_scan != 0); if (XSUCCEEDED(result)) { dir_info->Write(SHIM_MEM_BASE, file_info_ptr); info = length;