ps3: initial iso support

This commit is contained in:
DH 2025-04-04 23:32:55 +03:00
parent bcfa070aa4
commit 788dbfbf49
9 changed files with 1054 additions and 952 deletions

View file

@ -205,7 +205,7 @@ namespace fs
std::unordered_map<std::string, shared_ptr<device_base>> m_map{};
public:
shared_ptr<device_base> get_device(const std::string& path);
shared_ptr<device_base> get_device(const std::string& path, std::string_view *device_path = nullptr);
shared_ptr<device_base> set_device(const std::string& name, shared_ptr<device_base>);
};
@ -835,19 +835,23 @@ namespace fs
#endif
}
shared_ptr<fs::device_base> fs::device_manager::get_device(const std::string& 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));
reader_lock lock(m_mutex);
const usz prefix = path.find_first_of('_', 7) + 1;
const auto found = m_map.find(path.substr(prefix, path.find_first_of('/', 1) - prefix));
const auto found = m_map.find(prefix);
if (found == m_map.end() || !path.starts_with(found->second->fs_prefix))
{
return null_ptr;
}
if (device_path != nullptr)
{
*device_path = std::string_view(path).substr(prefix.size());
}
return found->second;
}
@ -881,12 +885,12 @@ shared_ptr<fs::device_base> fs::device_manager::set_device(const std::string& na
return null_ptr;
}
shared_ptr<fs::device_base> fs::get_virtual_device(const std::string& 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
if (path.starts_with("/vfsv0_") && path.size() >= 8 + 22 && path[29] == '_' && path.find_first_of('/', 1) > 29)
{
return get_device_manager().get_device(path);
return get_device_manager().get_device(path, device_path);
}
return null_ptr;
@ -953,9 +957,9 @@ bool fs::get_stat(const std::string& path, stat_t& info)
// Ensure consistent information on failure
info = {};
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
return device->stat(path, info);
return device->stat(std::string(dev_path), info);
}
#ifdef _WIN32
@ -1122,9 +1126,9 @@ bool fs::is_symlink(const std::string& path)
bool fs::statfs(const std::string& path, fs::device_stat& info)
{
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
return device->statfs(path, info);
return device->statfs(std::string(dev_path), info);
}
#ifdef _WIN32
@ -1181,9 +1185,9 @@ bool fs::statfs(const std::string& path, fs::device_stat& info)
bool fs::create_dir(const std::string& path)
{
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
return device->create_dir(path);
return device->create_dir(std::string(dev_path));
}
#ifdef _WIN32
@ -1244,9 +1248,9 @@ bool fs::remove_dir(const std::string& path)
return false;
}
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
return device->remove_dir(path);
return device->remove_dir(std::string(dev_path));
}
#ifdef _WIN32
@ -1268,9 +1272,9 @@ bool fs::remove_dir(const std::string& path)
bool fs::create_symlink(const std::string& path, const std::string& target)
{
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
return device->create_symlink(path);
return device->create_symlink(std::string(dev_path));
}
#ifdef _WIN32
@ -1302,16 +1306,17 @@ bool fs::rename(const std::string& from, const std::string& to, bool overwrite)
return false;
}
const auto device = get_virtual_device(from);
std::string_view device_from, device_to;
const auto device = get_virtual_device(from, &device_from);
if (device != get_virtual_device(to))
if (device != get_virtual_device(to, &device_to))
{
fmt::throw_exception("fs::rename() between different devices not implemented.\nFrom: %s\nTo: %s", from, to);
}
if (device)
{
return device->rename(from, to);
return device->rename(std::string(device_from), std::string(device_to));
}
#ifdef _WIN32
@ -1379,9 +1384,10 @@ bool fs::rename(const std::string& from, const std::string& to, bool overwrite)
bool fs::copy_file(const std::string& from, const std::string& to, bool overwrite)
{
const auto device = get_virtual_device(from);
std::string_view device_from, device_to;
const auto device = get_virtual_device(from, &device_from);
if (device != get_virtual_device(to) || device) // TODO
if (device != get_virtual_device(to, &device_to) || device) // TODO
{
fmt::throw_exception("fs::copy_file() for virtual devices not implemented.\nFrom: %s\nTo: %s", from, to);
}
@ -1479,9 +1485,9 @@ bool fs::copy_file(const std::string& from, const std::string& to, bool overwrit
bool fs::remove_file(const std::string& path)
{
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
return device->remove(path);
return device->remove(std::string(dev_path));
}
#ifdef _WIN32
@ -1505,9 +1511,9 @@ bool fs::remove_file(const std::string& path)
bool fs::truncate_file(const std::string& path, u64 length)
{
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
return device->trunc(path, length);
return device->trunc(std::string(dev_path), length);
}
#ifdef _WIN32
@ -1544,9 +1550,9 @@ bool fs::truncate_file(const std::string& path, u64 length)
bool fs::utime(const std::string& path, s64 atime, s64 mtime)
{
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
return device->utime(path, atime, mtime);
return device->utime(std::string(dev_path), atime, mtime);
}
#ifdef _WIN32
@ -1634,9 +1640,9 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
return;
}
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
if (auto&& _file = device->open(path, mode))
if (auto&& _file = device->open(std::string(dev_path), mode))
{
m_file = std::move(_file);
return;
@ -1884,9 +1890,9 @@ bool fs::dir::open(const std::string& path)
return false;
}
if (auto device = get_virtual_device(path))
if (std::string_view dev_path; auto device = get_virtual_device(path, &dev_path))
{
if (auto&& _dir = device->open_dir(path))
if (auto&& _dir = device->open_dir(std::string(dev_path)))
{
m_dir = std::move(_dir);
return true;

View file

@ -185,7 +185,7 @@ namespace fs
constexpr struct pod_tag_t{} pod_tag;
// Get virtual device for specified path (nullptr for real path)
shared_ptr<device_base> get_virtual_device(const std::string& path);
shared_ptr<device_base> get_virtual_device(const std::string& path, std::string_view *device_path);
// Set virtual device with specified name (nullptr for deletion)
shared_ptr<device_base> set_virtual_device(const std::string& name, shared_ptr<device_base> device);

View file

@ -105,6 +105,7 @@ if (NOT ANDROID)
Input/sdl_pad_handler.cpp
Input/skateboard_pad_handler.cpp
Input/xinput_pad_handler.cpp
Input/virtual_pad_handler.cpp
)
set_target_properties(rpcs3

File diff suppressed because it is too large Load diff

View file

@ -409,7 +409,7 @@ public:
return emulation_state_guard_t{this};
}
game_boot_result BootGame(const std::string& path, const std::string& title_id = "", bool direct = false, cfg_mode config_mode = cfg_mode::custom, const std::string& config_path = "");
game_boot_result BootGame(std::string path, const std::string& title_id = "", bool direct = false, cfg_mode config_mode = cfg_mode::custom, const std::string& config_path = "");
bool BootRsxCapture(const std::string& path);
void SetForceBoot(bool force_boot);

View file

@ -149,7 +149,7 @@ bool iso_dev::statfs(const std::string& path, fs::device_stat& info)
std::unique_ptr<fs::file_base> iso_dev::open(const std::string& path, bs_t<fs::open_mode> mode)
{
if (mode != fs::open_mode::read)
if (mode & fs::write)
{
fs::g_tls_error = fs::error::acces;
return {};

View file

@ -342,7 +342,14 @@ EmuCallbacks main_application::CreateCallbacks()
callbacks.resolve_path = [](std::string_view sv)
{
// May result in an empty string if path does not exist
return QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();
auto result = QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();
if (!result.empty())
{
return result;
}
return std::filesystem::weakly_canonical(sv).string();
};
callbacks.get_font_dirs = []()

View file

@ -576,7 +576,8 @@ void main_window::BootElf()
"SELF files (EBOOT.BIN *.self);;"
"BOOT files (*BOOT.BIN);;"
"BIN files (*.bin);;"
"All executable files (*.SAVESTAT.zst *.SAVESTAT.gz *.SAVESTAT *.sprx *.SPRX *.self *.SELF *.bin *.BIN *.prx *.PRX *.elf *.ELF *.o *.O);;"
"ISO files (*.iso *.ISO);;"
"All executable files (*.SAVESTAT.zst *.SAVESTAT.gz *.SAVESTAT *.sprx *.SPRX *.self *.SELF *.bin *.BIN *.prx *.PRX *.elf *.ELF *.iso *.ISO *.o *.O);;"
"All files (*.*)"),
Q_NULLPTR, QFileDialog::DontResolveSymlinks);

View file

@ -156,7 +156,7 @@
<bool>true</bool>
</property>
<property name="title">
<string>Boot (S)Elf</string>
<string>Boot File</string>
</property>
<property name="toolTipsVisible">
<bool>true</bool>
@ -465,7 +465,7 @@
</widget>
<action name="bootElfAct">
<property name="text">
<string>Boot SELF/ELF</string>
<string>Boot SELF/ELF/ISO</string>
</property>
</action>
<action name="bootTestAct">
@ -475,7 +475,7 @@
</action>
<action name="bootGameAct">
<property name="text">
<string>Boot Game</string>
<string>Boot Game Folder</string>
</property>
</action>
<action name="bootSavestateAct">