[VFS] Add support for loading ZArchive files

This commit is contained in:
Romain Tisserand
2023-05-21 21:33:10 +02:00
committed by Radosław Gliński
parent e191f2d8d0
commit 2cd2d1d620
14 changed files with 541 additions and 2 deletions

View File

@@ -50,6 +50,7 @@
#include "xenia/ui/windowed_app_context.h"
#include "xenia/vfs/device.h"
#include "xenia/vfs/devices/disc_image_device.h"
#include "xenia/vfs/devices/disc_zarchive_device.h"
#include "xenia/vfs/devices/host_path_device.h"
#include "xenia/vfs/devices/null_device.h"
#include "xenia/vfs/virtual_file_system.h"
@@ -420,6 +421,9 @@ X_STATUS Emulator::LaunchPath(const std::filesystem::path& path) {
// Treat as a naked xex file.
MountPath(path, "\\Device\\Harddisk0\\Partition1");
return LaunchXexFile(path);
} else if (extension == ".zar") {
// Assume a disc image.
return LaunchDiscArchive(path);
} else {
// Assume a disc image.
MountPath(path, "\\Device\\Cdrom0");
@@ -447,6 +451,29 @@ X_STATUS Emulator::LaunchDiscImage(const std::filesystem::path& path) {
return CompleteLaunch(path, module_path);
}
X_STATUS Emulator::LaunchDiscArchive(const std::filesystem::path& path) {
auto mount_path = "\\Device\\Cdrom0";
// Register the disc image in the virtual filesystem.
auto device = std::make_unique<vfs::DiscZarchiveDevice>(mount_path, path);
if (!device->Initialize()) {
xe::FatalError("Unable to mount disc image; file not found or corrupt.");
return X_STATUS_NO_SUCH_FILE;
}
if (!file_system_->RegisterDevice(std::move(device))) {
xe::FatalError("Unable to register disc image.");
return X_STATUS_NO_SUCH_FILE;
}
// Create symlinks to the device.
file_system_->RegisterSymbolicLink("game:", mount_path);
file_system_->RegisterSymbolicLink("d:", mount_path);
// Launch the game.
auto module_path(FindLaunchModule());
return CompleteLaunch(path, module_path);
}
X_STATUS Emulator::LaunchStfsContainer(const std::filesystem::path& path) {
auto module_path(FindLaunchModule());
return CompleteLaunch(path, module_path);