mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 16:01:42 +12:00
Fix lv2_fs_object::name
Recreate path from actual decoded components.
This commit is contained in:
parent
5534c9e27c
commit
28fb0d1741
3 changed files with 44 additions and 9 deletions
|
@ -84,7 +84,7 @@ bool vfs::mount(std::string_view vpath, std::string_view path)
|
|||
}
|
||||
|
||||
// Go back one level
|
||||
list.resize(list.size() - 1);
|
||||
list.pop_back();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ bool vfs::mount(std::string_view vpath, std::string_view path)
|
|||
}
|
||||
}
|
||||
|
||||
std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir)
|
||||
std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir, std::string* out_path)
|
||||
{
|
||||
const auto table = g_fxo->get<vfs_manager>();
|
||||
|
||||
|
@ -127,6 +127,14 @@ std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir)
|
|||
vpath = ".";
|
||||
}
|
||||
|
||||
// Fragments for out_path
|
||||
std::vector<std::string_view> name_list;
|
||||
|
||||
if (out_path)
|
||||
{
|
||||
name_list.reserve(vpath.size() / 2);
|
||||
}
|
||||
|
||||
for (std::vector<const vfs_directory*> list{&table->root};;)
|
||||
{
|
||||
// Skip one or more '/'
|
||||
|
@ -196,14 +204,24 @@ std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir)
|
|||
}
|
||||
|
||||
// Go back one level
|
||||
list.resize(list.size() - 1);
|
||||
result.resize(result.size() - 1);
|
||||
if (out_path)
|
||||
{
|
||||
name_list.pop_back();
|
||||
}
|
||||
|
||||
list.pop_back();
|
||||
result.pop_back();
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto last = list.back();
|
||||
list.push_back(nullptr);
|
||||
|
||||
if (out_path)
|
||||
{
|
||||
name_list.push_back(name);
|
||||
}
|
||||
|
||||
result.push_back(name);
|
||||
|
||||
if (!last)
|
||||
|
@ -225,6 +243,13 @@ std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir)
|
|||
}
|
||||
|
||||
// Handle /host_root (not escaped, not processed)
|
||||
if (out_path)
|
||||
{
|
||||
*out_path = "/";
|
||||
*out_path += fmt::merge(name_list, "/");
|
||||
*out_path += vpath;
|
||||
}
|
||||
|
||||
return std::string{vpath.substr(1)};
|
||||
}
|
||||
|
||||
|
@ -240,6 +265,12 @@ std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir)
|
|||
}
|
||||
|
||||
// Escape and merge path fragments
|
||||
if (out_path)
|
||||
{
|
||||
*out_path = "/";
|
||||
*out_path += fmt::merge(name_list, "/");
|
||||
}
|
||||
|
||||
return std::string{result_base} + vfs::escape(fmt::merge(result, "/"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue