mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 12:42:41 +01:00
System: make IsPathInsideDir a member function
This commit is contained in:
parent
f0e01ceb8f
commit
03a46a499e
@ -799,23 +799,17 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
|
||||
return game_boot_result::no_errors;
|
||||
}
|
||||
|
||||
// Check if path is inside the specified directory
|
||||
auto is_path_inside_path = [this](std::string_view path, std::string_view dir)
|
||||
{
|
||||
return (GetCallbacks().resolve_path(path) + '/').starts_with(GetCallbacks().resolve_path(dir) + '/');
|
||||
};
|
||||
|
||||
// Detect boot location
|
||||
constexpr usz game_dir_size = 8; // size of PS3_GAME and PS3_GMXX
|
||||
const std::string hdd0_game = vfs::get("/dev_hdd0/game/");
|
||||
const std::string hdd0_disc = vfs::get("/dev_hdd0/disc/");
|
||||
const bool from_hdd0_game = is_path_inside_path(m_path, hdd0_game);
|
||||
const bool from_dev_flash = is_path_inside_path(m_path, g_cfg.vfs.get_dev_flash());
|
||||
const bool from_hdd0_game = IsPathInsideDir(m_path, hdd0_game);
|
||||
const bool from_dev_flash = IsPathInsideDir(m_path, g_cfg.vfs.get_dev_flash());
|
||||
|
||||
#ifdef _WIN32
|
||||
// m_path might be passed from command line with differences in uppercase/lowercase on windows.
|
||||
if ((!from_hdd0_game && is_path_inside_path(fmt::to_lower(m_path), fmt::to_lower(hdd0_game))) ||
|
||||
(!from_dev_flash && is_path_inside_path(fmt::to_lower(m_path), fmt::to_lower(g_cfg.vfs.get_dev_flash()))))
|
||||
if ((!from_hdd0_game && IsPathInsideDir(fmt::to_lower(m_path), fmt::to_lower(hdd0_game))) ||
|
||||
(!from_dev_flash && IsPathInsideDir(fmt::to_lower(m_path), fmt::to_lower(g_cfg.vfs.get_dev_flash()))))
|
||||
{
|
||||
// Let's just abort to prevent errors down the line.
|
||||
sys_log.error("The boot path seems to contain incorrectly cased characters. Please adjust the path and try again.");
|
||||
@ -1796,4 +1790,9 @@ std::set<std::string> Emulator::GetGameDirs() const
|
||||
return dirs;
|
||||
}
|
||||
|
||||
bool Emulator::IsPathInsideDir(std::string_view path, std::string_view dir) const
|
||||
{
|
||||
return (GetCallbacks().resolve_path(path) + '/').starts_with(GetCallbacks().resolve_path(dir) + '/');
|
||||
};
|
||||
|
||||
Emulator Emu;
|
||||
|
@ -246,6 +246,9 @@ public:
|
||||
void ConfigurePPUCache() const;
|
||||
|
||||
std::set<std::string> GetGameDirs() const;
|
||||
|
||||
// Check if path is inside the specified directory
|
||||
bool IsPathInsideDir(std::string_view path, std::string_view dir) const;
|
||||
};
|
||||
|
||||
extern Emulator Emu;
|
||||
|
Loading…
Reference in New Issue
Block a user