From 38304da947c6b593ef94449894dc018aac633344 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 2 Aug 2017 18:16:56 +0200 Subject: DiscIO: Use Common::Lazy for loading filesystems This simplifies FileMonitor a lot and also lets us clean up FilesystemPanel. --- Source/Core/DiscIO/VolumeWii.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWii.cpp') diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index bce96822e7..0ed2200f14 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -26,6 +26,7 @@ #include "DiscIO/Blob.h" #include "DiscIO/DiscExtractor.h" #include "DiscIO/Enums.h" +#include "DiscIO/FileSystemGCWii.h" #include "DiscIO/Filesystem.h" #include "DiscIO/Volume.h" @@ -111,10 +112,17 @@ VolumeWii::VolumeWii(std::unique_ptr reader) return aes_context; }; + auto get_file_system = [this, partition]() -> std::unique_ptr { + auto file_system = std::make_unique(this, partition); + return file_system->IsValid() ? std::move(file_system) : nullptr; + }; + m_partitions.emplace( partition, PartitionDetails{Common::Lazy>(get_key), Common::Lazy(get_ticket), - Common::Lazy(get_tmd), *partition_type}); + Common::Lazy(get_tmd), + Common::Lazy>(get_file_system), + *partition_type}); } } } @@ -220,6 +228,12 @@ const IOS::ES::TMDReader& VolumeWii::GetTMD(const Partition& partition) const return it != m_partitions.end() ? *it->second.tmd : INVALID_TMD; } +const FileSystem* VolumeWii::GetFileSystem(const Partition& partition) const +{ + auto it = m_partitions.find(partition); + return it != m_partitions.end() ? it->second.file_system->get() : nullptr; +} + u64 VolumeWii::PartitionOffsetToRawOffset(u64 offset, const Partition& partition) { if (partition == PARTITION_NONE) @@ -287,13 +301,8 @@ std::string VolumeWii::GetInternalName(const Partition& partition) const std::map VolumeWii::GetLongNames() const { - std::unique_ptr file_system(CreateFileSystem(this, GetGamePartition())); - if (!file_system) - return {}; - std::vector opening_bnr(NAMES_TOTAL_BYTES); - std::unique_ptr file_info = file_system->FindFileInfo("opening.bnr"); - opening_bnr.resize(ReadFile(*this, GetGamePartition(), file_info.get(), opening_bnr.data(), + opening_bnr.resize(ReadFile(*this, GetGamePartition(), "opening.bnr", opening_bnr.data(), opening_bnr.size(), 0x5C)); return ReadWiiNames(opening_bnr); } -- cgit v1.2.3