From 6374f9210023933835ad0a4254ab08d98b36bc07 Mon Sep 17 00:00:00 2001 From: DH Date: Sat, 5 Apr 2025 15:59:10 +0300 Subject: [PATCH] ps3/virtual device: fix windows support iso: avoid usage of std::filesystem --- rpcs3/Utilities/File.cpp | 4 ++-- rpcs3/rpcs3/dev/iso.cpp | 20 ++++++++------------ rpcs3/rpcs3/dev/iso.hpp | 4 ++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/rpcs3/Utilities/File.cpp b/rpcs3/Utilities/File.cpp index aa298b45c..dc137cecc 100644 --- a/rpcs3/Utilities/File.cpp +++ b/rpcs3/Utilities/File.cpp @@ -837,7 +837,7 @@ namespace fs shared_ptr fs::device_manager::get_device(const std::string& path, std::string_view *device_path) { - auto prefix = path.substr(0, path.find_first_of('/', 1)); + auto prefix = path.substr(0, path.find_first_of("/\\", 1)); reader_lock lock(m_mutex); @@ -888,7 +888,7 @@ shared_ptr fs::device_manager::set_device(const std::string& na shared_ptr fs::get_virtual_device(const std::string& path, std::string_view *device_path) { // Every virtual device path must have specific name at the beginning - if (path.starts_with("/vfsv0_") && path.size() >= 8 + 22 && path[29] == '_' && path.find_first_of('/', 1) > 29) + if ((path.starts_with("/vfsv0_") || path.starts_with("\\vfsv0_")) && path.size() >= 8 + 22 && path[29] == '_' && path.find_first_of("/\\", 1) > 29) { return get_device_manager().get_device(path, device_path); } diff --git a/rpcs3/rpcs3/dev/iso.cpp b/rpcs3/rpcs3/dev/iso.cpp index 233c2bb9b..9376b36fd 100644 --- a/rpcs3/rpcs3/dev/iso.cpp +++ b/rpcs3/rpcs3/dev/iso.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -198,17 +197,14 @@ std::unique_ptr iso_dev::open_dir(const std::string& path) } std::optional -iso_dev::open_entry(const std::filesystem::path& path) +iso_dev::open_entry(std::string_view path) { - auto pathString = std::filesystem::weakly_canonical(path).string(); - - if (pathString == "/" || pathString == "\\" || pathString.empty()) + if (path == "/" || path == "\\" || path.empty()) { return m_root_dir; } auto item = m_root_dir; - auto pathView = std::string_view(pathString); auto isStringEqNoCase = [](std::string_view lhs, std::string_view rhs) { @@ -228,12 +224,12 @@ iso_dev::open_entry(const std::filesystem::path& path) return true; }; - while (!pathView.empty()) + while (!path.empty()) { - auto sepPos = pathView.find_first_of("/\\"); + auto sepPos = path.find_first_of("/\\"); if (sepPos == 0) { - pathView.remove_prefix(1); + path.remove_prefix(1); continue; } @@ -243,14 +239,14 @@ iso_dev::open_entry(const std::filesystem::path& path) return {}; } - auto dirName = pathView.substr(0, sepPos); + auto dirName = path.substr(0, sepPos); if (sepPos == std::string_view::npos) { - pathView = {}; + path = {}; } else { - pathView.remove_prefix(sepPos); + path.remove_prefix(sepPos); } auto items = read_dir(item); diff --git a/rpcs3/rpcs3/dev/iso.hpp b/rpcs3/rpcs3/dev/iso.hpp index 19800ceb4..6d7d4e36d 100644 --- a/rpcs3/rpcs3/dev/iso.hpp +++ b/rpcs3/rpcs3/dev/iso.hpp @@ -6,7 +6,7 @@ #include "util/types.hpp" #include #include -#include +#include namespace iso { @@ -236,7 +236,7 @@ public: private: bool initialize(); - std::optional open_entry(const std::filesystem::path& path); + std::optional open_entry(std::string_view path); std::pair, std::vector> read_dir(const iso::DirEntry& entry); fs::file read_file(const iso::DirEntry& entry); };