DirectoryBlob: Create a DiscContent class for use in m_virtual_disc

This commit is contained in:
JosJuice
2017-06-08 16:07:01 +02:00
parent b56214789e
commit e1321b131d
2 changed files with 88 additions and 39 deletions

View File

@ -4,9 +4,10 @@
#pragma once
#include <map>
#include <cstddef>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
@ -22,6 +23,30 @@ class IOFile;
namespace DiscIO
{
class DiscContent
{
public:
DiscContent(u64 offset, u64 size, const std::string& path);
// Provided because it's convenient when searching for DiscContent in an std::set
explicit DiscContent(u64 offset);
u64 GetOffset() const;
u64 GetSize() const;
bool Read(u64* offset, u64* length, u8** buffer) const;
bool operator==(const DiscContent& other) const { return m_offset == other.m_offset; }
bool operator!=(const DiscContent& other) const { return !(*this == other); }
bool operator<(const DiscContent& other) const { return m_offset < other.m_offset; }
bool operator>(const DiscContent& other) const { return other < *this; }
bool operator<=(const DiscContent& other) const { return !(*this < other); }
bool operator>=(const DiscContent& other) const { return !(*this > other); }
private:
u64 m_offset;
u64 m_size = 0;
std::string m_path;
};
class DirectoryBlobReader : public BlobReader
{
public:
@ -70,7 +95,7 @@ private:
std::string m_root_directory;
std::map<u64, std::string> m_virtual_disk;
std::set<DiscContent> m_virtual_disc;
bool m_is_wii = false;