DiscIO/DirectoryBlob: Consolidate functions that take data for ContentSource to just take a ContentSource.
This commit is contained in:
parent
7f57c24172
commit
b988ab4441
|
@ -61,18 +61,8 @@ constexpr u8 ENTRY_SIZE = 0x0c;
|
||||||
constexpr u8 FILE_ENTRY = 0;
|
constexpr u8 FILE_ENTRY = 0;
|
||||||
constexpr u8 DIRECTORY_ENTRY = 1;
|
constexpr u8 DIRECTORY_ENTRY = 1;
|
||||||
|
|
||||||
DiscContent::DiscContent(u64 offset, u64 size, const std::string& path)
|
DiscContent::DiscContent(u64 offset, u64 size, ContentSource source)
|
||||||
: m_offset(offset), m_size(size), m_content_source(path)
|
: m_offset(offset), m_size(size), m_content_source(std::move(source))
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,22 +127,10 @@ bool DiscContent::Read(u64* offset, u64* length, u8** buffer) const
|
||||||
return true;
|
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)
|
if (size != 0)
|
||||||
m_contents.emplace(offset, size, path);
|
m_contents.emplace(offset, size, std::move(source));
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 DiscContentContainer::CheckSizeAndAdd(u64 offset, const std::string& path)
|
u64 DiscContentContainer::CheckSizeAndAdd(u64 offset, const std::string& path)
|
||||||
|
|
|
@ -33,18 +33,16 @@ class DirectoryBlobReader;
|
||||||
// Returns true if the path is inside a DirectoryBlob and doesn't represent the DirectoryBlob itself
|
// Returns true if the path is inside a DirectoryBlob and doesn't represent the DirectoryBlob itself
|
||||||
bool ShouldHideFromGameList(const std::string& volume_path);
|
bool ShouldHideFromGameList(const std::string& volume_path);
|
||||||
|
|
||||||
class DiscContent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using ContentSource =
|
using ContentSource =
|
||||||
std::variant<std::string, // File
|
std::variant<std::string, // File
|
||||||
const u8*, // Memory
|
const u8*, // Memory
|
||||||
DirectoryBlobReader* // Partition (which one it is is determined by m_offset)
|
DirectoryBlobReader* // Partition (which one it is is determined by m_offset)
|
||||||
>;
|
>;
|
||||||
|
|
||||||
DiscContent(u64 offset, u64 size, const std::string& path);
|
class DiscContent
|
||||||
DiscContent(u64 offset, u64 size, const u8* data);
|
{
|
||||||
DiscContent(u64 offset, u64 size, DirectoryBlobReader* blob);
|
public:
|
||||||
|
DiscContent(u64 offset, u64 size, ContentSource source);
|
||||||
|
|
||||||
// Provided because it's convenient when searching for DiscContent in an std::set
|
// Provided because it's convenient when searching for DiscContent in an std::set
|
||||||
explicit DiscContent(u64 offset);
|
explicit DiscContent(u64 offset);
|
||||||
|
@ -75,9 +73,7 @@ public:
|
||||||
{
|
{
|
||||||
return Add(offset, vector.size() * sizeof(T), reinterpret_cast<const u8*>(vector.data()));
|
return Add(offset, vector.size() * sizeof(T), reinterpret_cast<const u8*>(vector.data()));
|
||||||
}
|
}
|
||||||
void Add(u64 offset, u64 size, const std::string& path);
|
void Add(u64 offset, u64 size, ContentSource source);
|
||||||
void Add(u64 offset, u64 size, const u8* data);
|
|
||||||
void Add(u64 offset, u64 size, DirectoryBlobReader* blob);
|
|
||||||
u64 CheckSizeAndAdd(u64 offset, const std::string& path);
|
u64 CheckSizeAndAdd(u64 offset, const std::string& path);
|
||||||
u64 CheckSizeAndAdd(u64 offset, u64 max_size, const std::string& path);
|
u64 CheckSizeAndAdd(u64 offset, u64 max_size, const std::string& path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue