Show file format details in game properties

This commit is contained in:
JosJuice
2020-06-21 20:41:50 +02:00
parent 9982251899
commit d494e0230c
26 changed files with 342 additions and 17 deletions

View File

@ -12,6 +12,7 @@
#include "Common/CDUtils.h"
#include "Common/CommonTypes.h"
#include "Common/File.h"
#include "Common/MsgHandler.h"
#include "DiscIO/Blob.h"
#include "DiscIO/CISOBlob.h"
@ -25,6 +26,35 @@
namespace DiscIO
{
std::string GetName(BlobType blob_type, bool translate)
{
const auto translate_str = [translate](const std::string& str) {
return translate ? Common::GetStringT(str.c_str()) : str;
};
switch (blob_type)
{
case BlobType::PLAIN:
return "ISO";
case BlobType::DIRECTORY:
return translate_str("Directory");
case BlobType::GCZ:
return "GCZ";
case BlobType::CISO:
return "CISO";
case BlobType::WBFS:
return "WBFS";
case BlobType::TGC:
return "TGC";
case BlobType::WIA:
return "WIA";
case BlobType::RVZ:
return "RVZ";
default:
return "";
}
}
void SectorReader::SetSectorSize(int blocksize)
{
m_block_size = std::max(blocksize, 0);

View File

@ -41,6 +41,8 @@ enum class BlobType
RVZ,
};
std::string GetName(BlobType blob_type, bool translate);
class BlobReader
{
public:
@ -55,6 +57,7 @@ public:
// Returns 0 if the format does not use blocks
virtual u64 GetBlockSize() const = 0;
virtual bool HasFastRandomAccessInBlock() const = 0;
virtual std::string GetCompressionMethod() const = 0;
// NOT thread-safe - can't call this from multiple threads.
virtual bool Read(u64 offset, u64 size, u8* out_ptr) = 0;

View File

@ -46,6 +46,7 @@ public:
u64 GetBlockSize() const override { return m_block_size; }
bool HasFastRandomAccessInBlock() const override { return true; }
std::string GetCompressionMethod() const override { return {}; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;

View File

@ -58,6 +58,7 @@ public:
u64 GetBlockSize() const override { return m_header.block_size; }
bool HasFastRandomAccessInBlock() const override { return false; }
std::string GetCompressionMethod() const override { return "Deflate"; }
u64 GetBlockCompressedSize(u64 block_num) const;
bool GetBlock(u64 block_num, u8* out_ptr) override;

View File

@ -168,6 +168,7 @@ public:
u64 GetBlockSize() const override { return 0; }
bool HasFastRandomAccessInBlock() const override { return true; }
std::string GetCompressionMethod() const override { return {}; }
private:
struct PartitionWithType

View File

@ -32,6 +32,7 @@ public:
u64 GetBlockSize() const override { return ECC_BLOCK_SIZE; }
bool HasFastRandomAccessInBlock() const override { return false; }
std::string GetCompressionMethod() const override { return {}; }
private:
DriveReader(const std::string& drive);

View File

@ -27,6 +27,7 @@ public:
u64 GetBlockSize() const override { return 0; }
bool HasFastRandomAccessInBlock() const override { return true; }
std::string GetCompressionMethod() const override { return {}; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;

View File

@ -30,6 +30,10 @@ public:
{
return m_blob_reader->HasFastRandomAccessInBlock();
}
std::string GetCompressionMethod() const override
{
return m_blob_reader->GetCompressionMethod();
}
bool Read(u64 offset, u64 size, u8* out_ptr) override;

View File

@ -50,6 +50,7 @@ public:
u64 GetBlockSize() const override { return 0; }
bool HasFastRandomAccessInBlock() const override { return true; }
std::string GetCompressionMethod() const override { return {}; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;

View File

@ -54,6 +54,11 @@ bool VolumeFileBlobReader::HasFastRandomAccessInBlock() const
return m_volume.GetBlobReader().HasFastRandomAccessInBlock();
}
std::string VolumeFileBlobReader::GetCompressionMethod() const
{
return m_volume.GetBlobReader().GetCompressionMethod();
}
bool VolumeFileBlobReader::Read(u64 offset, u64 length, u8* out_ptr)
{
if (offset + length > m_file_info->GetSize())

View File

@ -30,6 +30,7 @@ public:
u64 GetBlockSize() const override;
bool HasFastRandomAccessInBlock() const override;
std::string GetCompressionMethod() const override;
bool Read(u64 offset, u64 length, u8* out_ptr) override;

View File

@ -290,6 +290,26 @@ BlobType WIARVZFileReader<RVZ>::GetBlobType() const
return RVZ ? BlobType::RVZ : BlobType::WIA;
}
template <bool RVZ>
std::string WIARVZFileReader<RVZ>::GetCompressionMethod() const
{
switch (m_compression_type)
{
case WIARVZCompressionType::Purge:
return "Purge";
case WIARVZCompressionType::Bzip2:
return "bzip2";
case WIARVZCompressionType::LZMA:
return "LZMA";
case WIARVZCompressionType::LZMA2:
return "LZMA2";
case WIARVZCompressionType::Zstd:
return "Zstandard";
default:
return {};
}
}
template <bool RVZ>
bool WIARVZFileReader<RVZ>::Read(u64 offset, u64 size, u8* out_ptr)
{

View File

@ -56,6 +56,7 @@ public:
u64 GetBlockSize() const override { return Common::swap32(m_header_2.chunk_size); }
bool HasFastRandomAccessInBlock() const override { return false; }
std::string GetCompressionMethod() const override;
bool Read(u64 offset, u64 size, u8* out_ptr) override;
bool SupportsReadWiiDecrypted() const override;

View File

@ -34,6 +34,7 @@ public:
u64 GetBlockSize() const override { return m_wbfs_sector_size; }
bool HasFastRandomAccessInBlock() const override { return true; }
std::string GetCompressionMethod() const override { return {}; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;