mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
vfs_directory: try to fix compilation on gcc 14.1
This commit is contained in:
parent
7ac097255e
commit
5fb6be4bf6
@ -13,16 +13,17 @@
|
||||
#endif
|
||||
|
||||
#include <thread>
|
||||
#include <map>
|
||||
|
||||
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<std::pair<std::string, vfs_directory>> dirs{};
|
||||
// Virtual subdirectories
|
||||
std::map<std::string, std::unique_ptr<vfs_directory>> 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<vfs_directory> new_entry = std::make_unique<vfs_directory>();
|
||||
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<std::string>* 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<std::string>* 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user