mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
fs: Add get_parent_dir_view
string view version of the argument path, use with care.
This commit is contained in:
parent
bcbce5dd48
commit
09f83e48ff
@ -385,7 +385,7 @@ shared_ptr<fs::device_base> fs::set_virtual_device(const std::string& name, shar
|
|||||||
return get_device_manager().set_device(name, std::move(device));
|
return get_device_manager().set_device(name, std::move(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fs::get_parent_dir(std::string_view path, u32 parent_level)
|
std::string_view fs::get_parent_dir_view(std::string_view path, u32 parent_level)
|
||||||
{
|
{
|
||||||
std::string_view result = path;
|
std::string_view result = path;
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ std::string fs::get_parent_dir(std::string_view path, u32 parent_level)
|
|||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string{result};
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fs::stat(const std::string& path, stat_t& info)
|
bool fs::stat(const std::string& path, stat_t& info)
|
||||||
|
@ -166,7 +166,13 @@ namespace fs
|
|||||||
shared_ptr<device_base> set_virtual_device(const std::string& name, shared_ptr<device_base> device);
|
shared_ptr<device_base> set_virtual_device(const std::string& name, shared_ptr<device_base> device);
|
||||||
|
|
||||||
// Try to get parent directory
|
// Try to get parent directory
|
||||||
std::string get_parent_dir(std::string_view path, u32 parent_level = 1);
|
std::string_view get_parent_dir_view(std::string_view path, u32 parent_level = 1);
|
||||||
|
|
||||||
|
// String (typical use) version
|
||||||
|
inline std::string get_parent_dir(std::string_view path, u32 parent_level = 1)
|
||||||
|
{
|
||||||
|
return std::string{get_parent_dir_view(path, parent_level)};
|
||||||
|
}
|
||||||
|
|
||||||
// Get file information
|
// Get file information
|
||||||
bool stat(const std::string& path, stat_t& info);
|
bool stat(const std::string& path, stat_t& info);
|
||||||
|
Loading…
Reference in New Issue
Block a user