mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-10 07:24:54 +01:00
Some checks are pending
Generate Translation Template / Generate Translation Template (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux-aarch64.sh, gcc, rpcs3/rpcs3-ci-jammy-aarch64:1.8, ubuntu-24.04-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.8, ubuntu-24.04) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.8, ubuntu-24.04-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.8, ubuntu-24.04) (push) Waiting to run
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (0, 51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, Intel) (push) Waiting to run
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (1, 8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, Apple Silicon) (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (aarch64, clang, clangarm64, ARM64, windows-11-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (x86_64, clang, clang64, X64, windows-2025) (push) Waiting to run
Build RPCS3 / RPCS3 FreeBSD (push) Waiting to run
On empty mounted drives CreateFileW may return a valid handle even if the drive is not usable. We have to check the file handle early. Otherwise other functions may fail later as a result.
122 lines
2.6 KiB
C++
122 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include "Loader/PSF.h"
|
|
|
|
#include "Utilities/File.h"
|
|
#include "util/types.hpp"
|
|
|
|
bool is_file_iso(const std::string& path);
|
|
bool is_file_iso(const fs::file& path);
|
|
|
|
void load_iso(const std::string& path);
|
|
void unload_iso();
|
|
|
|
struct iso_extent_info
|
|
{
|
|
u64 start = 0;
|
|
u64 size = 0;
|
|
};
|
|
|
|
struct iso_fs_metadata
|
|
{
|
|
std::string name;
|
|
s64 time = 0;
|
|
bool is_directory = false;
|
|
bool has_multiple_extents = false;
|
|
std::vector<iso_extent_info> extents;
|
|
|
|
u64 size() const;
|
|
};
|
|
|
|
struct iso_fs_node
|
|
{
|
|
iso_fs_metadata metadata {};
|
|
std::vector<std::unique_ptr<iso_fs_node>> children;
|
|
};
|
|
|
|
class iso_file : public fs::file_base
|
|
{
|
|
private:
|
|
fs::file m_file;
|
|
iso_fs_metadata m_meta {};
|
|
u64 m_pos = 0;
|
|
|
|
std::pair<u64, iso_extent_info> get_extent_pos(u64 pos) const;
|
|
u64 file_offset(u64 pos) const;
|
|
u64 local_extent_remaining(u64 pos) const;
|
|
u64 local_extent_size(u64 pos) const;
|
|
|
|
public:
|
|
iso_file(fs::file&& iso_handle, const iso_fs_node& node);
|
|
|
|
fs::stat_t get_stat() override;
|
|
bool trunc(u64 length) override;
|
|
u64 read(void* buffer, u64 size) override;
|
|
u64 read_at(u64 offset, void* buffer, u64 size) override;
|
|
u64 write(const void* buffer, u64 size) override;
|
|
u64 seek(s64 offset, fs::seek_mode whence) override;
|
|
u64 size() override;
|
|
|
|
void release() override;
|
|
};
|
|
|
|
class iso_dir : public fs::dir_base
|
|
{
|
|
private:
|
|
const iso_fs_node& m_node;
|
|
u64 m_pos = 0;
|
|
|
|
public:
|
|
iso_dir(const iso_fs_node& node)
|
|
: m_node(node)
|
|
{}
|
|
|
|
bool read(fs::dir_entry&) override;
|
|
void rewind() override;
|
|
};
|
|
|
|
// represents the .iso file itself.
|
|
class iso_archive
|
|
{
|
|
private:
|
|
std::string m_path;
|
|
iso_fs_node m_root {};
|
|
fs::file m_file;
|
|
|
|
public:
|
|
iso_archive(const std::string& path);
|
|
|
|
iso_fs_node* retrieve(const std::string& path);
|
|
bool exists(const std::string& path);
|
|
bool is_file(const std::string& path);
|
|
|
|
iso_file open(const std::string& path);
|
|
|
|
psf::registry open_psf(const std::string& path);
|
|
};
|
|
|
|
class iso_device : public fs::device_base
|
|
{
|
|
private:
|
|
iso_archive m_archive;
|
|
std::string iso_path;
|
|
|
|
public:
|
|
inline static std::string virtual_device_name = "/vfsv0_virtual_iso_overlay_fs_dev";
|
|
|
|
iso_device(const std::string& iso_path, const std::string& device_name = virtual_device_name)
|
|
: m_archive(iso_path), iso_path(iso_path)
|
|
{
|
|
fs_prefix = device_name;
|
|
}
|
|
~iso_device() override = default;
|
|
|
|
const std::string& get_loaded_iso() const { return iso_path; }
|
|
|
|
bool stat(const std::string& path, fs::stat_t& info) override;
|
|
bool statfs(const std::string& path, fs::device_stat& info) override;
|
|
|
|
std::unique_ptr<fs::file_base> open(const std::string& path, bs_t<fs::open_mode> mode) override;
|
|
std::unique_ptr<fs::dir_base> open_dir(const std::string& path) override;
|
|
};
|