From be3fa2fc16fa731394c7f3fa737d705099888fa7 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sun, 25 Oct 2020 19:15:28 +0100 Subject: [PATCH] Rewrotes to cache loading & added "cache" device --- src/xenia/app/xenia_main.cc | 34 ++++++++++++---------------- src/xenia/vfs/virtual_file_system.cc | 2 +- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/xenia/app/xenia_main.cc b/src/xenia/app/xenia_main.cc index f2088ea4f..0aee00245 100644 --- a/src/xenia/app/xenia_main.cc +++ b/src/xenia/app/xenia_main.cc @@ -76,7 +76,6 @@ DEFINE_path( "Storage"); DEFINE_bool(mount_scratch, false, "Enable scratch mount", "Storage"); -DEFINE_bool(mount_cache, true, "Enable cache mount", "Storage"); DEFINE_transient_path(target, "", "Specifies the target .xex or .iso to execute.", @@ -308,27 +307,22 @@ int xenia_main(const std::vector& args) { } if (cvars::mount_cache) { - auto cache0_device = - std::make_unique("\\CACHE0", "cache0", false); - if (!cache0_device->Initialize()) { - XELOGE("Unable to scan cache0 path"); - } else { - if (!emulator->file_system()->RegisterDevice(std::move(cache0_device))) { - XELOGE("Unable to register cache0 path"); - } else { - emulator->file_system()->RegisterSymbolicLink("cache0:", "\\CACHE0"); - } - } + constexpr std::pair cache_mounts[] = { + {"\\CACHE", "cache"}, {"\\CACHE0", "cache0"}, {"\\CACHE1", "cache1"}}; - auto cache1_device = - std::make_unique("\\CACHE1", "cache1", false); - if (!cache1_device->Initialize()) { - XELOGE("Unable to scan cache1 path"); - } else { - if (!emulator->file_system()->RegisterDevice(std::move(cache1_device))) { - XELOGE("Unable to register cache1 path"); + for (auto const cache_mount : cache_mounts) { + auto cache_device = std::make_unique( + cache_mount.first, cache_mount.second, false); + + if (!cache_device->Initialize()) { + XELOGE("Unable to scan {} path", cache_mount.second); } else { - emulator->file_system()->RegisterSymbolicLink("cache1:", "\\CACHE1"); + if (!emulator->file_system()->RegisterDevice(std::move(cache_device))) { + XELOGE("Unable to register {} path", cache_mount.second); + } else { + emulator->file_system()->RegisterSymbolicLink( + std::string(cache_mount.second) + ':', cache_mount.first); + } } } } diff --git a/src/xenia/vfs/virtual_file_system.cc b/src/xenia/vfs/virtual_file_system.cc index 8af6e6659..79d883f2a 100644 --- a/src/xenia/vfs/virtual_file_system.cc +++ b/src/xenia/vfs/virtual_file_system.cc @@ -13,7 +13,7 @@ #include "xenia/base/string.h" #include "xenia/kernel/xfile.h" -DEFINE_bool(mount_cache, false, "Enable cache mount", "Storage"); +DEFINE_bool(mount_cache, true, "Enable cache mount", "Storage"); namespace xe { namespace vfs {