From b988ab44419560e511e587e2473b0f259d434f83 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Tue, 21 Sep 2021 07:58:41 +0200 Subject: [PATCH] DiscIO/DirectoryBlob: Consolidate functions that take data for ContentSource to just take a ContentSource. --- Source/Core/DiscIO/DirectoryBlob.cpp | 30 ++++------------------------ Source/Core/DiscIO/DirectoryBlob.h | 20 ++++++++----------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index 778adf7e3c..f731e9b13f 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -61,18 +61,8 @@ constexpr u8 ENTRY_SIZE = 0x0c; constexpr u8 FILE_ENTRY = 0; constexpr u8 DIRECTORY_ENTRY = 1; -DiscContent::DiscContent(u64 offset, u64 size, const std::string& path) - : m_offset(offset), m_size(size), m_content_source(path) -{ -} - -DiscContent::DiscContent(u64 offset, u64 size, const u8* data) - : m_offset(offset), m_size(size), m_content_source(data) -{ -} - -DiscContent::DiscContent(u64 offset, u64 size, DirectoryBlobReader* blob) - : m_offset(offset), m_size(size), m_content_source(blob) +DiscContent::DiscContent(u64 offset, u64 size, ContentSource source) + : m_offset(offset), m_size(size), m_content_source(std::move(source)) { } @@ -137,22 +127,10 @@ bool DiscContent::Read(u64* offset, u64* length, u8** buffer) const return true; } -void DiscContentContainer::Add(u64 offset, u64 size, const std::string& path) +void DiscContentContainer::Add(u64 offset, u64 size, ContentSource source) { if (size != 0) - m_contents.emplace(offset, size, path); -} - -void DiscContentContainer::Add(u64 offset, u64 size, const u8* data) -{ - if (size != 0) - m_contents.emplace(offset, size, data); -} - -void DiscContentContainer::Add(u64 offset, u64 size, DirectoryBlobReader* blob) -{ - if (size != 0) - m_contents.emplace(offset, size, blob); + m_contents.emplace(offset, size, std::move(source)); } u64 DiscContentContainer::CheckSizeAndAdd(u64 offset, const std::string& path) diff --git a/Source/Core/DiscIO/DirectoryBlob.h b/Source/Core/DiscIO/DirectoryBlob.h index 5a27791477..4281c7159c 100644 --- a/Source/Core/DiscIO/DirectoryBlob.h +++ b/Source/Core/DiscIO/DirectoryBlob.h @@ -33,18 +33,16 @@ class DirectoryBlobReader; // Returns true if the path is inside a DirectoryBlob and doesn't represent the DirectoryBlob itself bool ShouldHideFromGameList(const std::string& volume_path); +using ContentSource = + std::variant; + class DiscContent { public: - using ContentSource = - std::variant; - - DiscContent(u64 offset, u64 size, const std::string& path); - DiscContent(u64 offset, u64 size, const u8* data); - DiscContent(u64 offset, u64 size, DirectoryBlobReader* blob); + DiscContent(u64 offset, u64 size, ContentSource source); // Provided because it's convenient when searching for DiscContent in an std::set explicit DiscContent(u64 offset); @@ -75,9 +73,7 @@ public: { return Add(offset, vector.size() * sizeof(T), reinterpret_cast(vector.data())); } - void Add(u64 offset, u64 size, const std::string& path); - void Add(u64 offset, u64 size, const u8* data); - void Add(u64 offset, u64 size, DirectoryBlobReader* blob); + void Add(u64 offset, u64 size, ContentSource source); u64 CheckSizeAndAdd(u64 offset, const std::string& path); u64 CheckSizeAndAdd(u64 offset, u64 max_size, const std::string& path);