DiscIO: Add way of checking whether blob data size is accurate

This commit is contained in:
JosJuice 2019-03-21 22:20:23 +01:00
parent 0bce1c509d
commit 3014dadfa8
16 changed files with 34 additions and 6 deletions

View File

@ -44,6 +44,7 @@ public:
virtual BlobType GetBlobType() const = 0; virtual BlobType GetBlobType() const = 0;
virtual u64 GetRawSize() const = 0; virtual u64 GetRawSize() const = 0;
virtual u64 GetDataSize() const = 0; virtual u64 GetDataSize() const = 0;
virtual bool IsDataSizeAccurate() const = 0;
// NOT thread-safe - can't call this from multiple threads. // NOT thread-safe - can't call this from multiple threads.
virtual bool Read(u64 offset, u64 size, u8* out_ptr) = 0; virtual bool Read(u64 offset, u64 size, u8* out_ptr) = 0;

View File

@ -40,6 +40,7 @@ public:
// The CISO format does not save the original file size. // The CISO format does not save the original file size.
// This function returns an upper bound. // This function returns an upper bound.
u64 GetDataSize() const override; u64 GetDataSize() const override;
bool IsDataSizeAccurate() const override { return false; }
u64 GetRawSize() const override; u64 GetRawSize() const override;
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;

View File

@ -49,8 +49,9 @@ public:
~CompressedBlobReader(); ~CompressedBlobReader();
const CompressedBlobHeader& GetHeader() const { return m_header; } const CompressedBlobHeader& GetHeader() const { return m_header; }
BlobType GetBlobType() const override { return BlobType::GCZ; } BlobType GetBlobType() const override { return BlobType::GCZ; }
u64 GetDataSize() const override { return m_header.data_size; }
u64 GetRawSize() const override { return m_file_size; } u64 GetRawSize() const override { return m_file_size; }
u64 GetDataSize() const override { return m_header.data_size; }
bool IsDataSizeAccurate() const override { return true; }
u64 GetBlockCompressedSize(u64 block_num) const; u64 GetBlockCompressedSize(u64 block_num) const;
bool GetBlock(u64 block_num, u8* out_ptr) override; bool GetBlock(u64 block_num, u8* out_ptr) override;

View File

@ -146,6 +146,7 @@ public:
BlobType GetBlobType() const override; BlobType GetBlobType() const override;
u64 GetRawSize() const override; u64 GetRawSize() const override;
u64 GetDataSize() const override; u64 GetDataSize() const override;
bool IsDataSizeAccurate() const override { return true; }
private: private:
struct PartitionWithType struct PartitionWithType

View File

@ -24,8 +24,9 @@ public:
static std::unique_ptr<DriveReader> Create(const std::string& drive); static std::unique_ptr<DriveReader> Create(const std::string& drive);
~DriveReader(); ~DriveReader();
BlobType GetBlobType() const override { return BlobType::DRIVE; } BlobType GetBlobType() const override { return BlobType::DRIVE; }
u64 GetDataSize() const override { return m_size; }
u64 GetRawSize() const override { return m_size; } u64 GetRawSize() const override { return m_size; }
u64 GetDataSize() const override { return m_size; }
bool IsDataSizeAccurate() const override { return true; }
private: private:
DriveReader(const std::string& drive); DriveReader(const std::string& drive);

View File

@ -20,8 +20,9 @@ public:
static std::unique_ptr<PlainFileReader> Create(File::IOFile file); static std::unique_ptr<PlainFileReader> Create(File::IOFile file);
BlobType GetBlobType() const override { return BlobType::PLAIN; } BlobType GetBlobType() const override { return BlobType::PLAIN; }
u64 GetDataSize() const override { return m_size; }
u64 GetRawSize() const override { return m_size; } u64 GetRawSize() const override { return m_size; }
u64 GetDataSize() const override { return m_size; }
bool IsDataSizeAccurate() const override { return true; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
private: private:

View File

@ -43,8 +43,9 @@ public:
static std::unique_ptr<TGCFileReader> Create(File::IOFile file); static std::unique_ptr<TGCFileReader> Create(File::IOFile file);
BlobType GetBlobType() const override { return BlobType::TGC; } BlobType GetBlobType() const override { return BlobType::TGC; }
u64 GetDataSize() const override;
u64 GetRawSize() const override { return m_size; } u64 GetRawSize() const override { return m_size; }
u64 GetDataSize() const override;
bool IsDataSizeAccurate() const override { return true; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
private: private:

View File

@ -101,6 +101,7 @@ public:
virtual BlobType GetBlobType() const = 0; virtual BlobType GetBlobType() const = 0;
// Size of virtual disc (may be inaccurate depending on the blob type) // Size of virtual disc (may be inaccurate depending on the blob type)
virtual u64 GetSize() const = 0; virtual u64 GetSize() const = 0;
virtual bool IsSizeAccurate() const = 0;
// Size on disc (compressed size) // Size on disc (compressed size)
virtual u64 GetRawSize() const = 0; virtual u64 GetRawSize() const = 0;

View File

@ -23,8 +23,9 @@ public:
Create(const Volume& volume, const Partition& partition, const std::string& file_path); Create(const Volume& volume, const Partition& partition, const std::string& file_path);
BlobType GetBlobType() const override { return BlobType::PLAIN; } BlobType GetBlobType() const override { return BlobType::PLAIN; }
u64 GetDataSize() const override;
u64 GetRawSize() const override; u64 GetRawSize() const override;
u64 GetDataSize() const override;
bool IsDataSizeAccurate() const override { return true; }
bool Read(u64 offset, u64 length, u8* out_ptr) override; bool Read(u64 offset, u64 length, u8* out_ptr) override;
private: private:

View File

@ -179,6 +179,11 @@ u64 VolumeGC::GetSize() const
return m_reader->GetDataSize(); return m_reader->GetDataSize();
} }
bool VolumeGC::IsSizeAccurate() const
{
return m_reader->IsDataSizeAccurate();
}
u64 VolumeGC::GetRawSize() const u64 VolumeGC::GetRawSize() const
{ {
return m_reader->GetRawSize(); return m_reader->GetRawSize();

View File

@ -52,6 +52,7 @@ public:
Country GetCountry(const Partition& partition = PARTITION_NONE) const override; Country GetCountry(const Partition& partition = PARTITION_NONE) const override;
BlobType GetBlobType() const override; BlobType GetBlobType() const override;
u64 GetSize() const override; u64 GetSize() const override;
bool IsSizeAccurate() const override;
u64 GetRawSize() const override; u64 GetRawSize() const override;
private: private:

View File

@ -175,6 +175,11 @@ u64 VolumeWAD::GetSize() const
return m_reader->GetDataSize(); return m_reader->GetDataSize();
} }
bool VolumeWAD::IsSizeAccurate() const
{
return m_reader->IsDataSizeAccurate();
}
u64 VolumeWAD::GetRawSize() const u64 VolumeWAD::GetRawSize() const
{ {
return m_reader->GetRawSize(); return m_reader->GetRawSize();

View File

@ -54,6 +54,7 @@ public:
BlobType GetBlobType() const override; BlobType GetBlobType() const override;
u64 GetSize() const override; u64 GetSize() const override;
bool IsSizeAccurate() const override;
u64 GetRawSize() const override; u64 GetRawSize() const override;
private: private:

View File

@ -379,6 +379,11 @@ u64 VolumeWii::GetSize() const
return m_reader->GetDataSize(); return m_reader->GetDataSize();
} }
bool VolumeWii::IsSizeAccurate() const
{
return m_reader->IsDataSizeAccurate();
}
u64 VolumeWii::GetRawSize() const u64 VolumeWii::GetRawSize() const
{ {
return m_reader->GetRawSize(); return m_reader->GetRawSize();

View File

@ -62,6 +62,7 @@ public:
Country GetCountry(const Partition& partition) const override; Country GetCountry(const Partition& partition) const override;
BlobType GetBlobType() const override; BlobType GetBlobType() const override;
u64 GetSize() const override; u64 GetSize() const override;
bool IsSizeAccurate() const override;
u64 GetRawSize() const override; u64 GetRawSize() const override;
static constexpr unsigned int BLOCK_HEADER_SIZE = 0x0400; static constexpr unsigned int BLOCK_HEADER_SIZE = 0x0400;

View File

@ -24,12 +24,13 @@ public:
static std::unique_ptr<WbfsFileReader> Create(File::IOFile file, const std::string& path); static std::unique_ptr<WbfsFileReader> Create(File::IOFile file, const std::string& path);
BlobType GetBlobType() const override { return BlobType::WBFS; } BlobType GetBlobType() const override { return BlobType::WBFS; }
u64 GetRawSize() const override { return m_size; }
// The WBFS format does not save the original file size. // The WBFS format does not save the original file size.
// This function returns a constant upper bound // This function returns a constant upper bound
// (the size of a double-layer Wii disc). // (the size of a double-layer Wii disc).
u64 GetDataSize() const override; u64 GetDataSize() const override;
bool IsDataSizeAccurate() const override { return false; }
u64 GetRawSize() const override { return m_size; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
private: private: