summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/VolumeWii.cpp
diff options
context:
space:
mode:
authorLeo Lam <leolino.lam@gmail.com>2017-09-15 19:30:05 +0200
committerGitHub <noreply@github.com>2017-09-15 19:30:05 +0200
commit7cb8d6612c6df51073037b56ebc866f180aecd71 (patch)
tree634e4c4d34472c6f2e49fbd48bebb6bb5f82de63 /Source/Core/DiscIO/VolumeWii.cpp
parent7caf44c8b5a8a435ad1d9db3b2444db614d329eb (diff)
parentf294599e734f2391db9e74b6454752e75fdf368c (diff)
Merge pull request #5870 from JosJuice/lazy-filesystem
DiscIO: Use Common::Lazy more
Diffstat (limited to 'Source/Core/DiscIO/VolumeWii.cpp')
-rw-r--r--Source/Core/DiscIO/VolumeWii.cpp23
1 files changed, 16 insertions, 7 deletions
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<BlobReader> reader)
return aes_context;
};
+ auto get_file_system = [this, partition]() -> std::unique_ptr<FileSystem> {
+ auto file_system = std::make_unique<FileSystemGCWii>(this, partition);
+ return file_system->IsValid() ? std::move(file_system) : nullptr;
+ };
+
m_partitions.emplace(
partition, PartitionDetails{Common::Lazy<std::unique_ptr<mbedtls_aes_context>>(get_key),
Common::Lazy<IOS::ES::TicketReader>(get_ticket),
- Common::Lazy<IOS::ES::TMDReader>(get_tmd), *partition_type});
+ Common::Lazy<IOS::ES::TMDReader>(get_tmd),
+ Common::Lazy<std::unique_ptr<FileSystem>>(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<Language, std::string> VolumeWii::GetLongNames() const
{
- std::unique_ptr<FileSystem> file_system(CreateFileSystem(this, GetGamePartition()));
- if (!file_system)
- return {};
-
std::vector<u8> opening_bnr(NAMES_TOTAL_BYTES);
- std::unique_ptr<FileInfo> 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);
}