From d3937253531f4f9dc917af9456fa4f1c61093be5 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sat, 2 Nov 2024 19:44:28 +0100 Subject: [PATCH] Revert "[VFS] Fixed crash on filename extraction from path." This reverts commit 02f5316562bb56c0a687948d19b0b13269614b9d. It's not needed anymore thanks to 6cba5ba7e6565fa06cc093ccd177a1b2954063fe --- src/xenia/vfs/devices/disc_image_device.cc | 2 +- src/xenia/vfs/devices/disc_image_entry.cc | 8 +++----- src/xenia/vfs/devices/disc_image_entry.h | 2 +- src/xenia/vfs/devices/disc_zarchive_device.cc | 8 +++----- src/xenia/vfs/devices/disc_zarchive_entry.cc | 7 +++---- src/xenia/vfs/devices/disc_zarchive_entry.h | 3 +-- src/xenia/vfs/devices/host_path_device.cc | 2 +- src/xenia/vfs/devices/host_path_entry.cc | 6 ++---- src/xenia/vfs/devices/host_path_entry.h | 1 - src/xenia/vfs/devices/null_device.cc | 2 +- src/xenia/vfs/devices/null_entry.cc | 7 +++---- src/xenia/vfs/devices/null_entry.h | 3 +-- src/xenia/vfs/devices/xcontent_container_entry.cc | 7 +++---- src/xenia/vfs/devices/xcontent_container_entry.h | 3 +-- .../vfs/devices/xcontent_devices/stfs_container_device.cc | 2 +- .../vfs/devices/xcontent_devices/svod_container_device.cc | 2 +- src/xenia/vfs/entry.cc | 5 ++--- src/xenia/vfs/entry.h | 3 +-- 18 files changed, 29 insertions(+), 44 deletions(-) diff --git a/src/xenia/vfs/devices/disc_image_device.cc b/src/xenia/vfs/devices/disc_image_device.cc index 4ab72d1fb..9e126bfde 100644 --- a/src/xenia/vfs/devices/disc_image_device.cc +++ b/src/xenia/vfs/devices/disc_image_device.cc @@ -112,7 +112,7 @@ bool DiscImageDevice::VerifyMagic(ParseState* state, size_t offset) { DiscImageDevice::Error DiscImageDevice::ReadAllEntries( ParseState* state, const uint8_t* root_buffer) { - auto root_entry = new DiscImageEntry(this, nullptr, "", "", mmap_.get()); + auto root_entry = new DiscImageEntry(this, nullptr, "", mmap_.get()); root_entry->attributes_ = kFileAttributeDirectory; root_entry_ = std::unique_ptr(root_entry); diff --git a/src/xenia/vfs/devices/disc_image_entry.cc b/src/xenia/vfs/devices/disc_image_entry.cc index 80ecf95b0..0d251dff5 100644 --- a/src/xenia/vfs/devices/disc_image_entry.cc +++ b/src/xenia/vfs/devices/disc_image_entry.cc @@ -18,9 +18,8 @@ namespace xe { namespace vfs { DiscImageEntry::DiscImageEntry(Device* device, Entry* parent, - const std::string_view path, - const std::string_view name, MappedMemory* mmap) - : Entry(device, parent, path, name), + const std::string_view path, MappedMemory* mmap) + : Entry(device, parent, path), mmap_(mmap), data_offset_(0), data_size_(0) {} @@ -31,8 +30,7 @@ std::unique_ptr DiscImageEntry::Create( Device* device, Entry* parent, const std::string_view name, MappedMemory* mmap) { auto path = xe::utf8::join_guest_paths(parent->path(), name); - auto entry = - std::make_unique(device, parent, path, name, mmap); + auto entry = std::make_unique(device, parent, path, mmap); return std::move(entry); } diff --git a/src/xenia/vfs/devices/disc_image_entry.h b/src/xenia/vfs/devices/disc_image_entry.h index b5bf5a675..f955e345f 100644 --- a/src/xenia/vfs/devices/disc_image_entry.h +++ b/src/xenia/vfs/devices/disc_image_entry.h @@ -24,7 +24,7 @@ class DiscImageDevice; class DiscImageEntry : public Entry { public: DiscImageEntry(Device* device, Entry* parent, const std::string_view path, - const std::string_view name, MappedMemory* mmap); + MappedMemory* mmap); ~DiscImageEntry() override; static std::unique_ptr Create(Device* device, Entry* parent, diff --git a/src/xenia/vfs/devices/disc_zarchive_device.cc b/src/xenia/vfs/devices/disc_zarchive_device.cc index 14da08b19..0f81e4bdd 100644 --- a/src/xenia/vfs/devices/disc_zarchive_device.cc +++ b/src/xenia/vfs/devices/disc_zarchive_device.cc @@ -36,7 +36,7 @@ bool DiscZarchiveDevice::Initialize() { const std::string root_path = std::string("/"); const ZArchiveNodeHandle handle = reader_->LookUp(root_path); - auto root_entry = new DiscZarchiveEntry(this, nullptr, root_path, ""); + auto root_entry = new DiscZarchiveEntry(this, nullptr, root_path); root_entry->attributes_ = kFileAttributeDirectory; root_entry->handle_ = static_cast(handle); root_entry->name_ = root_path; @@ -79,8 +79,7 @@ bool DiscZarchiveDevice::ReadAllEntries(const std::string& path, } if (reader_->IsFile(handle)) { - auto entry = new DiscZarchiveEntry( - this, parent, path, xe::utf8::find_name_from_guest_path(path)); + auto entry = new DiscZarchiveEntry(this, parent, path); entry->attributes_ = kFileAttributeReadOnly; entry->handle_ = static_cast(handle); entry->parent_ = parent; @@ -104,8 +103,7 @@ bool DiscZarchiveDevice::ReadAllEntries(const std::string& path, return false; } - auto entry = - new DiscZarchiveEntry(this, parent, full_path, dirEntry.name); + auto entry = new DiscZarchiveEntry(this, parent, full_path); entry->handle_ = static_cast(fileHandle); entry->data_offset_ = 0; diff --git a/src/xenia/vfs/devices/disc_zarchive_entry.cc b/src/xenia/vfs/devices/disc_zarchive_entry.cc index 6a874bf82..828ab597c 100644 --- a/src/xenia/vfs/devices/disc_zarchive_entry.cc +++ b/src/xenia/vfs/devices/disc_zarchive_entry.cc @@ -20,9 +20,8 @@ namespace xe { namespace vfs { DiscZarchiveEntry::DiscZarchiveEntry(Device* device, Entry* parent, - const std::string_view path, - const std::string_view name) - : Entry(device, parent, path, name), + const std::string_view path) + : Entry(device, parent, path), data_offset_(0), data_size_(0), handle_(ZARCHIVE_INVALID_NODE) {} @@ -32,7 +31,7 @@ DiscZarchiveEntry::~DiscZarchiveEntry() = default; std::unique_ptr DiscZarchiveEntry::Create( Device* device, Entry* parent, const std::string_view name) { auto path = name; // xe::utf8::join_guest_paths(parent->path(), name); - auto entry = std::make_unique(device, parent, path, name); + auto entry = std::make_unique(device, parent, path); return std::move(entry); } diff --git a/src/xenia/vfs/devices/disc_zarchive_entry.h b/src/xenia/vfs/devices/disc_zarchive_entry.h index 5fcf9b319..3b01b25a9 100644 --- a/src/xenia/vfs/devices/disc_zarchive_entry.h +++ b/src/xenia/vfs/devices/disc_zarchive_entry.h @@ -23,8 +23,7 @@ class DiscZarchiveDevice; class DiscZarchiveEntry : public Entry { public: - DiscZarchiveEntry(Device* device, Entry* parent, const std::string_view path, - const std::string_view name); + DiscZarchiveEntry(Device* device, Entry* parent, const std::string_view path); ~DiscZarchiveEntry() override; static std::unique_ptr Create(Device* device, diff --git a/src/xenia/vfs/devices/host_path_device.cc b/src/xenia/vfs/devices/host_path_device.cc index 20b4b5cb0..33aee1b7a 100644 --- a/src/xenia/vfs/devices/host_path_device.cc +++ b/src/xenia/vfs/devices/host_path_device.cc @@ -39,7 +39,7 @@ bool HostPathDevice::Initialize() { } } - auto root_entry = new HostPathEntry(this, nullptr, "", "", host_path_); + auto root_entry = new HostPathEntry(this, nullptr, "", host_path_); root_entry->attributes_ = kFileAttributeDirectory; root_entry_ = std::unique_ptr(root_entry); PopulateEntry(root_entry); diff --git a/src/xenia/vfs/devices/host_path_entry.cc b/src/xenia/vfs/devices/host_path_entry.cc index dd9e2927d..8d3ede134 100644 --- a/src/xenia/vfs/devices/host_path_entry.cc +++ b/src/xenia/vfs/devices/host_path_entry.cc @@ -23,9 +23,8 @@ namespace vfs { HostPathEntry::HostPathEntry(Device* device, Entry* parent, const std::string_view path, - const std::string_view name, const std::filesystem::path& host_path) - : Entry(device, parent, path, name), host_path_(host_path) {} + : Entry(device, parent, path), host_path_(host_path) {} HostPathEntry::~HostPathEntry() = default; @@ -34,8 +33,7 @@ HostPathEntry* HostPathEntry::Create(Device* device, Entry* parent, xe::filesystem::FileInfo file_info) { auto path = xe::utf8::join_guest_paths(parent->path(), xe::path_to_utf8(file_info.name)); - auto entry = new HostPathEntry(device, parent, path, - xe::path_to_utf8(file_info.name), full_path); + auto entry = new HostPathEntry(device, parent, path, full_path); entry->create_timestamp_ = file_info.create_timestamp; entry->access_timestamp_ = file_info.access_timestamp; diff --git a/src/xenia/vfs/devices/host_path_entry.h b/src/xenia/vfs/devices/host_path_entry.h index f93b494e7..85ce94d8b 100644 --- a/src/xenia/vfs/devices/host_path_entry.h +++ b/src/xenia/vfs/devices/host_path_entry.h @@ -23,7 +23,6 @@ class HostPathDevice; class HostPathEntry : public Entry { public: HostPathEntry(Device* device, Entry* parent, const std::string_view path, - const std::string_view name, const std::filesystem::path& host_path); ~HostPathEntry() override; diff --git a/src/xenia/vfs/devices/null_device.cc b/src/xenia/vfs/devices/null_device.cc index ab53d70f6..79490376b 100644 --- a/src/xenia/vfs/devices/null_device.cc +++ b/src/xenia/vfs/devices/null_device.cc @@ -26,7 +26,7 @@ NullDevice::NullDevice(const std::string& mount_path, NullDevice::~NullDevice() = default; bool NullDevice::Initialize() { - auto root_entry = new NullEntry(this, nullptr, mount_path_, ""); + auto root_entry = new NullEntry(this, nullptr, mount_path_); root_entry->attributes_ = kFileAttributeDirectory; root_entry_ = std::unique_ptr(root_entry); diff --git a/src/xenia/vfs/devices/null_entry.cc b/src/xenia/vfs/devices/null_entry.cc index 7a751c948..45b511c40 100644 --- a/src/xenia/vfs/devices/null_entry.cc +++ b/src/xenia/vfs/devices/null_entry.cc @@ -20,15 +20,14 @@ namespace xe { namespace vfs { -NullEntry::NullEntry(Device* device, Entry* parent, std::string path, - const std::string_view name) - : Entry(device, parent, path, name) {} +NullEntry::NullEntry(Device* device, Entry* parent, std::string path) + : Entry(device, parent, path) {} NullEntry::~NullEntry() = default; NullEntry* NullEntry::Create(Device* device, Entry* parent, const std::string& path) { - auto entry = new NullEntry(device, parent, path, ""); + auto entry = new NullEntry(device, parent, path); entry->create_timestamp_ = 0; entry->access_timestamp_ = 0; diff --git a/src/xenia/vfs/devices/null_entry.h b/src/xenia/vfs/devices/null_entry.h index 2efcd5b91..84f01cb95 100644 --- a/src/xenia/vfs/devices/null_entry.h +++ b/src/xenia/vfs/devices/null_entry.h @@ -22,8 +22,7 @@ class NullDevice; class NullEntry : public Entry { public: - NullEntry(Device* device, Entry* parent, std::string path, - const std::string_view name); + NullEntry(Device* device, Entry* parent, std::string path); ~NullEntry() override; static NullEntry* Create(Device* device, Entry* parent, diff --git a/src/xenia/vfs/devices/xcontent_container_entry.cc b/src/xenia/vfs/devices/xcontent_container_entry.cc index eecfce4d2..1f264dfec 100644 --- a/src/xenia/vfs/devices/xcontent_container_entry.cc +++ b/src/xenia/vfs/devices/xcontent_container_entry.cc @@ -17,9 +17,8 @@ namespace vfs { XContentContainerEntry::XContentContainerEntry(Device* device, Entry* parent, const std::string_view path, - const std::string_view name, MultiFileHandles* files) - : Entry(device, parent, path, name), + : Entry(device, parent, path), files_(files), data_offset_(0), data_size_(0), @@ -31,8 +30,8 @@ std::unique_ptr XContentContainerEntry::Create( Device* device, Entry* parent, const std::string_view name, MultiFileHandles* files) { auto path = xe::utf8::join_guest_paths(parent->path(), name); - auto entry = std::make_unique(device, parent, path, - name, files); + auto entry = + std::make_unique(device, parent, path, files); return std::move(entry); } diff --git a/src/xenia/vfs/devices/xcontent_container_entry.h b/src/xenia/vfs/devices/xcontent_container_entry.h index 93238bc97..8022a088a 100644 --- a/src/xenia/vfs/devices/xcontent_container_entry.h +++ b/src/xenia/vfs/devices/xcontent_container_entry.h @@ -26,8 +26,7 @@ class XContentContainerDevice; class XContentContainerEntry : public Entry { public: XContentContainerEntry(Device* device, Entry* parent, - const std::string_view path, - const std::string_view name, MultiFileHandles* files); + const std::string_view path, MultiFileHandles* files); ~XContentContainerEntry() override; static std::unique_ptr Create( diff --git a/src/xenia/vfs/devices/xcontent_devices/stfs_container_device.cc b/src/xenia/vfs/devices/xcontent_devices/stfs_container_device.cc index a8d9e62de..f08077e20 100644 --- a/src/xenia/vfs/devices/xcontent_devices/stfs_container_device.cc +++ b/src/xenia/vfs/devices/xcontent_devices/stfs_container_device.cc @@ -53,7 +53,7 @@ XContentContainerDevice::Result StfsContainerDevice::LoadHostFiles( StfsContainerDevice::Result StfsContainerDevice::Read() { auto& file = files_.at(0); - auto root_entry = new XContentContainerEntry(this, nullptr, "", "", &files_); + auto root_entry = new XContentContainerEntry(this, nullptr, "", &files_); root_entry->attributes_ = kFileAttributeDirectory; root_entry_ = std::unique_ptr(root_entry); diff --git a/src/xenia/vfs/devices/xcontent_devices/svod_container_device.cc b/src/xenia/vfs/devices/xcontent_devices/svod_container_device.cc index 8ec80ebf2..1af0d4d6a 100644 --- a/src/xenia/vfs/devices/xcontent_devices/svod_container_device.cc +++ b/src/xenia/vfs/devices/xcontent_devices/svod_container_device.cc @@ -99,7 +99,7 @@ XContentContainerDevice::Result SvodContainerDevice::Read() { const uint64_t root_creation_timestamp = decode_fat_timestamp(root_data.creation_date, root_data.creation_time); - auto root_entry = new XContentContainerEntry(this, nullptr, "", "", &files_); + auto root_entry = new XContentContainerEntry(this, nullptr, "", &files_); root_entry->attributes_ = kFileAttributeDirectory; root_entry->access_timestamp_ = root_creation_timestamp; root_entry->create_timestamp_ = root_creation_timestamp; diff --git a/src/xenia/vfs/entry.cc b/src/xenia/vfs/entry.cc index 4d1ec00e4..da2a7b939 100644 --- a/src/xenia/vfs/entry.cc +++ b/src/xenia/vfs/entry.cc @@ -16,12 +16,10 @@ namespace xe { namespace vfs { -Entry::Entry(Device* device, Entry* parent, const std::string_view path, - const std::string_view name) +Entry::Entry(Device* device, Entry* parent, const std::string_view path) : device_(device), parent_(parent), path_(path), - name_(name), attributes_(0), size_(0), allocation_size_(0), @@ -31,6 +29,7 @@ Entry::Entry(Device* device, Entry* parent, const std::string_view path, delete_on_close_(false) { assert_not_null(device); absolute_path_ = xe::utf8::join_guest_paths(device->mount_path(), path); + name_ = xe::utf8::find_name_from_guest_path(path); } Entry::~Entry() = default; diff --git a/src/xenia/vfs/entry.h b/src/xenia/vfs/entry.h index b0bf33857..3b80c25cb 100644 --- a/src/xenia/vfs/entry.h +++ b/src/xenia/vfs/entry.h @@ -134,8 +134,7 @@ class Entry { virtual void update() { return; } protected: - Entry(Device* device, Entry* parent, const std::string_view path, - const std::string_view name); + Entry(Device* device, Entry* parent, const std::string_view path); virtual std::unique_ptr CreateEntryInternal( const std::string_view name, uint32_t attributes) {