summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2017-07-04 15:37:41 +0200
committerLéo Lam <leo@innovatetechnologi.es>2017-08-10 23:47:18 +0800
commitca0438e26db13ed8f7579cff11ccd7db618abfc3 (patch)
treeab394ecfde2c1766882702fc4f65bc19d044f497 /Source/Core/DiscIO
parent5976d3934dd46f79887938c4396f253ece3ec486 (diff)
WiiWad: Allow using WiiWad with more than just files
This adds a WiiWad constructor that takes a BlobReader, so that the class can be used with more than just files from the host filesystem. Required for using WiiWad with WADs from update partitions.
Diffstat (limited to 'Source/Core/DiscIO')
-rw-r--r--Source/Core/DiscIO/WiiWad.cpp15
-rw-r--r--Source/Core/DiscIO/WiiWad.h3
2 files changed, 8 insertions, 10 deletions
diff --git a/Source/Core/DiscIO/WiiWad.cpp b/Source/Core/DiscIO/WiiWad.cpp
index 1b04f3e68d..8d6272d3a8 100644
--- a/Source/Core/DiscIO/WiiWad.cpp
+++ b/Source/Core/DiscIO/WiiWad.cpp
@@ -44,21 +44,18 @@ bool IsWiiWAD(BlobReader& reader)
}
} // Anonymous namespace
-WiiWAD::WiiWAD(const std::string& name) : m_reader(CreateBlobReader(name))
+WiiWAD::WiiWAD(const std::string& name) : WiiWAD(CreateBlobReader(name))
{
- if (m_reader == nullptr)
- {
- m_valid = false;
- return;
- }
-
- m_valid = ParseWAD();
}
-WiiWAD::~WiiWAD()
+WiiWAD::WiiWAD(std::unique_ptr<BlobReader> blob_reader) : m_reader(std::move(blob_reader))
{
+ if (m_reader)
+ m_valid = ParseWAD();
}
+WiiWAD::~WiiWAD() = default;
+
bool WiiWAD::ParseWAD()
{
if (!IsWiiWAD(*m_reader))
diff --git a/Source/Core/DiscIO/WiiWad.h b/Source/Core/DiscIO/WiiWad.h
index 1c29d77ff4..6f3f4a97bc 100644
--- a/Source/Core/DiscIO/WiiWad.h
+++ b/Source/Core/DiscIO/WiiWad.h
@@ -19,6 +19,7 @@ class WiiWAD
{
public:
explicit WiiWAD(const std::string& name);
+ explicit WiiWAD(std::unique_ptr<BlobReader> blob_reader);
~WiiWAD();
bool IsValid() const { return m_valid; }
@@ -32,7 +33,7 @@ public:
private:
bool ParseWAD();
- bool m_valid;
+ bool m_valid = false;
std::unique_ptr<BlobReader> m_reader;