From 5fb6be4bf627dfcd97dd21212e2250172a545f8d Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 11 May 2024 08:51:12 +0200 Subject: [PATCH] vfs_directory: try to fix compilation on gcc 14.1 --- rpcs3/Emu/VFS.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index 1c2df8b685..3f73dbbcff 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -13,16 +13,17 @@ #endif #include +#include LOG_CHANNEL(vfs_log, "VFS"); struct vfs_directory { // Real path (empty if root or not exists) - std::string path{}; + std::string path; - // Virtual subdirectories (vector because only vector allows incomplete types) - std::vector> dirs{}; + // Virtual subdirectories + std::map> dirs; }; struct vfs_manager @@ -107,13 +108,13 @@ bool vfs::mount(std::string_view vpath, std::string_view path, bool is_dir) } // Find or add - const auto last = list.back(); + vfs_directory* last = list.back(); - for (auto& dir : last->dirs) + for (auto& [path, dir] : last->dirs) { - if (dir.first == name) + if (path == name) { - list.push_back(&dir.second); + list.push_back(dir.get()); break; } } @@ -121,7 +122,9 @@ bool vfs::mount(std::string_view vpath, std::string_view path, bool is_dir) if (last == list.back()) { // Add new entry - list.push_back(&last->dirs.emplace_back(name, vfs_directory{}).second); + std::unique_ptr new_entry = std::make_unique(); + list.push_back(new_entry.get()); + last->dirs.emplace(name, std::move(new_entry)); } } } @@ -174,13 +177,13 @@ bool vfs::unmount(std::string_view vpath) // Remove the matching node if we reached the maximum depth if (depth + 1 == entry_list.size()) { - vfs_log.notice("Unmounting '%s' = '%s'", it->first, it->second.path); + vfs_log.notice("Unmounting '%s' = '%s'", it->first, it->second->path); it = dir.dirs.erase(it); continue; } // Otherwise continue searching in the next level of depth - unmount_children(it->second, depth + 1); + unmount_children(*it->second, depth + 1); } ++it; @@ -247,7 +250,7 @@ std::string vfs::get(std::string_view vpath, std::vector* out_dir, { for (auto& pair : dir->dirs) { - if (!pair.second.path.empty()) + if (!pair.second->path.empty()) { out_dir->emplace_back(pair.first); } @@ -312,13 +315,13 @@ std::string vfs::get(std::string_view vpath, std::vector* out_dir, continue; } - for (auto& dir : last->dirs) + for (auto& [path, dir] : last->dirs) { - if (dir.first == name) + if (path == name) { - list.back() = &dir.second; + list.back() = dir.get(); - if (dir.second.path == "/"sv) + if (dir->path == "/"sv) { if (vpath.size() <= 1) { @@ -409,7 +412,7 @@ std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std: { mount_path->back() = name; - if (std::string res = vfs::retrieve(path, &dir, mount_path); !res.empty()) + if (std::string res = vfs::retrieve(path, dir.get(), mount_path); !res.empty()) { // Avoid app_home // Prefer dev_bdvd over dev_hdd0 @@ -421,7 +424,7 @@ std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std: } } - if (dir.path == "/"sv) + if (dir->path == "/"sv) { host_root_name = name; }