From cc6d03ab2cde5946048e84ba1aa9b346257fd260 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 9 Feb 2015 16:59:28 -0800 Subject: [PATCH] Removing unneeded fs entry type. --- src/xenia/kernel/fs/devices/disc_image_device.cc | 6 +----- src/xenia/kernel/fs/devices/disc_image_entry.cc | 4 ++-- src/xenia/kernel/fs/devices/disc_image_entry.h | 4 ++-- src/xenia/kernel/fs/devices/host_path_device.cc | 3 +-- src/xenia/kernel/fs/devices/host_path_entry.cc | 4 ++-- src/xenia/kernel/fs/devices/host_path_entry.h | 2 +- src/xenia/kernel/fs/devices/stfs_container_device.cc | 5 +---- src/xenia/kernel/fs/devices/stfs_container_entry.cc | 5 ++--- src/xenia/kernel/fs/devices/stfs_container_entry.h | 4 ++-- src/xenia/kernel/fs/entry.cc | 4 ++-- src/xenia/kernel/fs/entry.h | 9 +-------- src/xenia/kernel/objects/xuser_module.cc | 4 ---- src/xenia/kernel/xboxkrnl_io.cc | 2 +- 13 files changed, 18 insertions(+), 38 deletions(-) diff --git a/src/xenia/kernel/fs/devices/disc_image_device.cc b/src/xenia/kernel/fs/devices/disc_image_device.cc index 57a7bd0b9..fa6510dd3 100644 --- a/src/xenia/kernel/fs/devices/disc_image_device.cc +++ b/src/xenia/kernel/fs/devices/disc_image_device.cc @@ -61,11 +61,7 @@ std::unique_ptr DiscImageDevice::ResolvePath(const char* path) { } } - Entry::Type type = gdfx_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY - ? Entry::Type::DIRECTORY - : Entry::Type::FILE; - return std::make_unique(type, this, path, mmap_.get(), - gdfx_entry); + return std::make_unique(this, path, mmap_.get(), gdfx_entry); } } // namespace fs diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.cc b/src/xenia/kernel/fs/devices/disc_image_entry.cc index 10c1eeff2..707d1d82b 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.cc +++ b/src/xenia/kernel/fs/devices/disc_image_entry.cc @@ -26,9 +26,9 @@ class DiscImageMemoryMapping : public MemoryMapping { ~DiscImageMemoryMapping() override = default; }; -DiscImageEntry::DiscImageEntry(Type type, Device* device, const char* path, +DiscImageEntry::DiscImageEntry(Device* device, const char* path, poly::MappedMemory* mmap, GDFXEntry* gdfx_entry) - : Entry(type, device, path), + : Entry(device, path), mmap_(mmap), gdfx_entry_(gdfx_entry), 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 96bac1195..4fed87d15 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.h +++ b/src/xenia/kernel/fs/devices/disc_image_entry.h @@ -24,8 +24,8 @@ class GDFXEntry; class DiscImageEntry : public Entry { public: - DiscImageEntry(Type type, Device* device, const char* path, - poly::MappedMemory* mmap, GDFXEntry* gdfx_entry); + DiscImageEntry(Device* device, const char* path, poly::MappedMemory* mmap, + GDFXEntry* gdfx_entry); ~DiscImageEntry() override; poly::MappedMemory* mmap() const { return mmap_; } diff --git a/src/xenia/kernel/fs/devices/host_path_device.cc b/src/xenia/kernel/fs/devices/host_path_device.cc index faec9d8e4..056f6dfb8 100644 --- a/src/xenia/kernel/fs/devices/host_path_device.cc +++ b/src/xenia/kernel/fs/devices/host_path_device.cc @@ -37,8 +37,7 @@ std::unique_ptr HostPathDevice::ResolvePath(const char* path) { // TODO(benvanik): fail if does not exit // TODO(benvanik): switch based on type - auto type = Entry::Type::FILE; - return std::make_unique(type, this, path, full_path); + return std::make_unique(this, path, full_path); } } // namespace fs diff --git a/src/xenia/kernel/fs/devices/host_path_entry.cc b/src/xenia/kernel/fs/devices/host_path_entry.cc index ff71ecef9..56f04e3d5 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.cc +++ b/src/xenia/kernel/fs/devices/host_path_entry.cc @@ -25,9 +25,9 @@ class HostPathMemoryMapping : public MemoryMapping { std::unique_ptr mmap_; }; -HostPathEntry::HostPathEntry(Type type, Device* device, const char* path, +HostPathEntry::HostPathEntry(Device* device, const char* path, const std::wstring& local_path) - : Entry(type, device, path), + : Entry(device, path), local_path_(local_path), find_file_(INVALID_HANDLE_VALUE) {} diff --git a/src/xenia/kernel/fs/devices/host_path_entry.h b/src/xenia/kernel/fs/devices/host_path_entry.h index b55dcbcae..a495c535e 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.h +++ b/src/xenia/kernel/fs/devices/host_path_entry.h @@ -19,7 +19,7 @@ namespace fs { class HostPathEntry : public Entry { public: - HostPathEntry(Type type, Device* device, const char* path, + HostPathEntry(Device* device, const char* path, const std::wstring& local_path); ~HostPathEntry() override; diff --git a/src/xenia/kernel/fs/devices/stfs_container_device.cc b/src/xenia/kernel/fs/devices/stfs_container_device.cc index 443589dac..0951fd683 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_device.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_device.cc @@ -62,10 +62,7 @@ std::unique_ptr STFSContainerDevice::ResolvePath(const char* path) { } } - Entry::Type type = stfs_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY - ? Entry::Type::DIRECTORY - : Entry::Type::FILE; - return std::make_unique(type, this, path, mmap_.get(), + return std::make_unique(this, path, mmap_.get(), stfs_entry); } diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.cc b/src/xenia/kernel/fs/devices/stfs_container_entry.cc index d3565c95b..1119933a2 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.cc @@ -16,11 +16,10 @@ namespace xe { namespace kernel { namespace fs { -STFSContainerEntry::STFSContainerEntry(Type type, Device* device, - const char* path, +STFSContainerEntry::STFSContainerEntry(Device* device, const char* path, poly::MappedMemory* mmap, STFSEntry* stfs_entry) - : Entry(type, device, path), + : Entry(device, path), mmap_(mmap), stfs_entry_(stfs_entry), 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 1e75aef47..4b83866cd 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.h +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.h @@ -24,8 +24,8 @@ class STFSEntry; class STFSContainerEntry : public Entry { public: - STFSContainerEntry(Type type, Device* device, const char* path, - poly::MappedMemory* mmap, STFSEntry* stfs_entry); + STFSContainerEntry(Device* device, const char* path, poly::MappedMemory* mmap, + STFSEntry* stfs_entry); ~STFSContainerEntry() override; poly::MappedMemory* mmap() const { return mmap_; } diff --git a/src/xenia/kernel/fs/entry.cc b/src/xenia/kernel/fs/entry.cc index 2af001932..80d4e78a9 100644 --- a/src/xenia/kernel/fs/entry.cc +++ b/src/xenia/kernel/fs/entry.cc @@ -19,8 +19,8 @@ MemoryMapping::MemoryMapping(uint8_t* address, size_t length) MemoryMapping::~MemoryMapping() {} -Entry::Entry(Type type, Device* device, const std::string& path) - : type_(type), device_(device), path_(path) { +Entry::Entry(Device* device, const std::string& path) + : device_(device), path_(path) { assert_not_null(device); absolute_path_ = device->path() + path; // TODO(benvanik): last index of \, unless \ at end, then before that diff --git a/src/xenia/kernel/fs/entry.h b/src/xenia/kernel/fs/entry.h index 0553c53ad..bb3e9dc5a 100644 --- a/src/xenia/kernel/fs/entry.h +++ b/src/xenia/kernel/fs/entry.h @@ -53,15 +53,9 @@ class MemoryMapping { class Entry { public: - enum class Type { - FILE, - DIRECTORY, - }; - - Entry(Type type, Device* device, const std::string& path); + Entry(Device* device, const std::string& path); virtual ~Entry(); - Type type() const { return type_; } Device* device() const { return device_; } const std::string& path() const { return path_; } const std::string& absolute_path() const { return absolute_path_; } @@ -82,7 +76,6 @@ class Entry { XFile** out_file) = 0; private: - Type type_; Device* device_; std::string path_; std::string absolute_path_; diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index 29bf7f79c..23c258aad 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -41,10 +41,6 @@ X_STATUS XUserModule::LoadFromFile(const char* path) { XELOGE("File not found: %s", path); return X_STATUS_NO_SUCH_FILE; } - if (fs_entry->type() != fs::Entry::Type::FILE) { - XELOGE("Invalid file type: %s", path); - return X_STATUS_NO_SUCH_FILE; - } // If the FS supports mapping, map the file in and load from that. if (fs_entry->can_map()) { diff --git a/src/xenia/kernel/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl_io.cc index 074d82cbb..6bffae188 100644 --- a/src/xenia/kernel/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl_io.cc @@ -469,7 +469,7 @@ SHIM_CALL NtQueryFullAttributesFile_shim(PPCContext* ppc_state, // Resolve the file using the virtual file system. FileSystem* fs = state->file_system(); auto entry = fs->ResolvePath(object_name); - if (entry && entry->type() == Entry::Type::FILE) { + if (entry) { // Found. XFileInfo file_info; result = entry->QueryInfo(&file_info);