ps3/virtual device: fix windows support

iso: avoid usage of std::filesystem
This commit is contained in:
DH 2025-04-05 15:59:10 +03:00
parent ccde87c17f
commit 6374f92100
3 changed files with 12 additions and 16 deletions

View file

@ -837,7 +837,7 @@ namespace fs
shared_ptr<fs::device_base> fs::device_manager::get_device(const std::string& path, std::string_view *device_path) shared_ptr<fs::device_base> 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); reader_lock lock(m_mutex);
@ -888,7 +888,7 @@ shared_ptr<fs::device_base> fs::device_manager::set_device(const std::string& na
shared_ptr<fs::device_base> fs::get_virtual_device(const std::string& path, std::string_view *device_path) shared_ptr<fs::device_base> fs::get_virtual_device(const std::string& path, std::string_view *device_path)
{ {
// Every virtual device path must have specific name at the beginning // 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); return get_device_manager().get_device(path, device_path);
} }

View file

@ -9,7 +9,6 @@
#include <cstdint> #include <cstdint>
#include <cstdio> #include <cstdio>
#include <ctime> #include <ctime>
#include <filesystem>
#include <memory> #include <memory>
#include <string> #include <string>
@ -198,17 +197,14 @@ std::unique_ptr<fs::dir_base> iso_dev::open_dir(const std::string& path)
} }
std::optional<iso::DirEntry> std::optional<iso::DirEntry>
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 (path == "/" || path == "\\" || path.empty())
if (pathString == "/" || pathString == "\\" || pathString.empty())
{ {
return m_root_dir; return m_root_dir;
} }
auto item = m_root_dir; auto item = m_root_dir;
auto pathView = std::string_view(pathString);
auto isStringEqNoCase = [](std::string_view lhs, std::string_view rhs) 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; return true;
}; };
while (!pathView.empty()) while (!path.empty())
{ {
auto sepPos = pathView.find_first_of("/\\"); auto sepPos = path.find_first_of("/\\");
if (sepPos == 0) if (sepPos == 0)
{ {
pathView.remove_prefix(1); path.remove_prefix(1);
continue; continue;
} }
@ -243,14 +239,14 @@ iso_dev::open_entry(const std::filesystem::path& path)
return {}; return {};
} }
auto dirName = pathView.substr(0, sepPos); auto dirName = path.substr(0, sepPos);
if (sepPos == std::string_view::npos) if (sepPos == std::string_view::npos)
{ {
pathView = {}; path = {};
} }
else else
{ {
pathView.remove_prefix(sepPos); path.remove_prefix(sepPos);
} }
auto items = read_dir(item); auto items = read_dir(item);

View file

@ -6,7 +6,7 @@
#include "util/types.hpp" #include "util/types.hpp"
#include <bit> #include <bit>
#include <optional> #include <optional>
#include <filesystem> #include <string_view>
namespace iso namespace iso
{ {
@ -236,7 +236,7 @@ public:
private: private:
bool initialize(); bool initialize();
std::optional<iso::DirEntry> open_entry(const std::filesystem::path& path); std::optional<iso::DirEntry> open_entry(std::string_view path);
std::pair<std::vector<iso::DirEntry>, std::vector<std::string>> read_dir(const iso::DirEntry& entry); std::pair<std::vector<iso::DirEntry>, std::vector<std::string>> read_dir(const iso::DirEntry& entry);
fs::file read_file(const iso::DirEntry& entry); fs::file read_file(const iso::DirEntry& entry);
}; };