mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
[Emulator] Better handling of failed device mounting
This commit is contained in:
parent
6e13258ad4
commit
2385cc53a9
|
|
@ -226,7 +226,6 @@ class EmulatorWindow {
|
||||||
void GamepadHotKeys();
|
void GamepadHotKeys();
|
||||||
void ToggleGPUSetting(gpu_cvar index);
|
void ToggleGPUSetting(gpu_cvar index);
|
||||||
bool IsUseNexusForGameBarEnabled();
|
bool IsUseNexusForGameBarEnabled();
|
||||||
std::string BoolToString(bool value);
|
|
||||||
void DisplayHotKeysConfig();
|
void DisplayHotKeysConfig();
|
||||||
|
|
||||||
void RunPreviouslyPlayedTitle();
|
void RunPreviouslyPlayedTitle();
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ const std::unique_ptr<vfs::Device> Emulator::CreateVfsDeviceBasedOnPath(
|
||||||
xe::ShowSimpleMessageBox(
|
xe::ShowSimpleMessageBox(
|
||||||
xe::SimpleMessageBoxType::Error,
|
xe::SimpleMessageBoxType::Error,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Unsupported format!"
|
"Unsupported format!\n"
|
||||||
"Xenia does not support running software in an archived format."));
|
"Xenia does not support running software in an archived format."));
|
||||||
}
|
}
|
||||||
return std::make_unique<vfs::DiscImageDevice>(mount_path, path);
|
return std::make_unique<vfs::DiscImageDevice>(mount_path, path);
|
||||||
|
|
@ -387,15 +387,15 @@ void Emulator::SetPersistentEmulatorFlags(uint64_t new_flags) {
|
||||||
X_STATUS Emulator::MountPath(const std::filesystem::path& path,
|
X_STATUS Emulator::MountPath(const std::filesystem::path& path,
|
||||||
const std::string_view mount_path) {
|
const std::string_view mount_path) {
|
||||||
auto device = CreateVfsDeviceBasedOnPath(path, mount_path);
|
auto device = CreateVfsDeviceBasedOnPath(path, mount_path);
|
||||||
if (!device->Initialize()) {
|
if (!device || !device->Initialize()) {
|
||||||
xe::FatalError(
|
XELOGE(
|
||||||
"Unable to mount the selected file, it is an unsupported format or "
|
"Unable to mount the selected file, it is an unsupported format or "
|
||||||
"corrupted.");
|
"corrupted.");
|
||||||
return X_STATUS_NO_SUCH_FILE;
|
return X_STATUS_NO_SUCH_FILE;
|
||||||
}
|
}
|
||||||
if (!file_system_->RegisterDevice(std::move(device))) {
|
if (!file_system_->RegisterDevice(std::move(device))) {
|
||||||
xe::FatalError(fmt::format("Unable to register the input file to {}.",
|
XELOGE("Unable to register the input file to {}.",
|
||||||
xe::path_to_utf8(mount_path)));
|
xe::path_to_utf8(mount_path));
|
||||||
return X_STATUS_NO_SUCH_FILE;
|
return X_STATUS_NO_SUCH_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -413,24 +413,27 @@ X_STATUS Emulator::MountPath(const std::filesystem::path& path,
|
||||||
X_STATUS Emulator::LaunchPath(const std::filesystem::path& path) {
|
X_STATUS Emulator::LaunchPath(const std::filesystem::path& path) {
|
||||||
// Launch based on file type.
|
// Launch based on file type.
|
||||||
// This is a silly guess based on file extension.
|
// This is a silly guess based on file extension.
|
||||||
|
|
||||||
|
X_STATUS mount_result = X_STATUS_SUCCESS;
|
||||||
|
|
||||||
if (!path.has_extension()) {
|
if (!path.has_extension()) {
|
||||||
// Likely an STFS container.
|
// Likely an STFS container.
|
||||||
MountPath(path, "\\Device\\Cdrom0");
|
mount_result = MountPath(path, "\\Device\\Cdrom0");
|
||||||
return LaunchStfsContainer(path);
|
return mount_result ? mount_result : LaunchStfsContainer(path);
|
||||||
};
|
};
|
||||||
auto extension = xe::utf8::lower_ascii(xe::path_to_utf8(path.extension()));
|
auto extension = xe::utf8::lower_ascii(xe::path_to_utf8(path.extension()));
|
||||||
if (extension == ".xex" || extension == ".elf" || extension == ".exe") {
|
if (extension == ".xex" || extension == ".elf" || extension == ".exe") {
|
||||||
// Treat as a naked xex file.
|
// Treat as a naked xex file.
|
||||||
MountPath(path, "\\Device\\Harddisk0\\Partition1");
|
mount_result = MountPath(path, "\\Device\\Harddisk0\\Partition1");
|
||||||
return LaunchXexFile(path);
|
return mount_result ? mount_result : LaunchXexFile(path);
|
||||||
} else if (extension == ".zar") {
|
} else if (extension == ".zar") {
|
||||||
// Assume a disc image.
|
// Assume a disc image.
|
||||||
MountPath(path, "\\Device\\Cdrom0");
|
mount_result = MountPath(path, "\\Device\\Cdrom0");
|
||||||
return LaunchDiscArchive(path);
|
return mount_result ? mount_result : LaunchDiscArchive(path);
|
||||||
} else {
|
} else {
|
||||||
// Assume a disc image.
|
// Assume a disc image.
|
||||||
MountPath(path, "\\Device\\Cdrom0");
|
mount_result = MountPath(path, "\\Device\\Cdrom0");
|
||||||
return LaunchDiscImage(path);
|
return mount_result ? mount_result : LaunchDiscImage(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -495,7 +498,7 @@ X_STATUS Emulator::LaunchDefaultModule(const std::filesystem::path& path) {
|
||||||
X_STATUS Emulator::InstallContentPackage(const std::filesystem::path& path) {
|
X_STATUS Emulator::InstallContentPackage(const std::filesystem::path& path) {
|
||||||
std::unique_ptr<vfs::Device> device =
|
std::unique_ptr<vfs::Device> device =
|
||||||
vfs::XContentContainerDevice::CreateContentDevice("", path);
|
vfs::XContentContainerDevice::CreateContentDevice("", path);
|
||||||
if (!device->Initialize()) {
|
if (!device || !device->Initialize()) {
|
||||||
XELOGE("Failed to initialize device");
|
XELOGE("Failed to initialize device");
|
||||||
return X_STATUS_INVALID_PARAMETER;
|
return X_STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
DEFINE_bool(
|
DEFINE_bool(
|
||||||
allow_plugins, false,
|
allow_plugins, false,
|
||||||
"Allows loading of plugins/trainers from plugins\\title_id\\plugin.xex."
|
"Allows loading of plugins/trainers from plugins\\title_id\\plugin.xex. "
|
||||||
"Plugin are homebrew xex modules which can be used for making mods "
|
"Plugin are homebrew xex modules which can be used for making mods. "
|
||||||
"This feature is experimental.",
|
"This feature is experimental.",
|
||||||
"General");
|
"General");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue