From 94ee720a0745939874ff4a663fe071c847369c67 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 26 Sep 2015 14:46:53 +0200 Subject: [PATCH 1/2] Rename IsCompressedBlob to IsGCZBlob for clarity GCZ is just one of the several compressed formats that Dolphin supports. --- Source/Core/DiscIO/Blob.cpp | 2 +- Source/Core/DiscIO/CompressedBlob.cpp | 8 ++++---- Source/Core/DiscIO/CompressedBlob.h | 4 ++-- Source/Core/DolphinQt/GameList/GameFile.cpp | 2 +- Source/Core/DolphinWX/ISOFile.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Core/DiscIO/Blob.cpp b/Source/Core/DiscIO/Blob.cpp index 19cb36d8b3..9ed8577c38 100644 --- a/Source/Core/DiscIO/Blob.cpp +++ b/Source/Core/DiscIO/Blob.cpp @@ -129,7 +129,7 @@ IBlobReader* CreateBlobReader(const std::string& filename) if (IsWbfsBlob(filename)) return WbfsFileReader::Create(filename); - if (IsCompressedBlob(filename)) + if (IsGCZBlob(filename)) return CompressedBlobReader::Create(filename); if (IsCISOBlob(filename)) diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp index 04304b7613..5c08355175 100644 --- a/Source/Core/DiscIO/CompressedBlob.cpp +++ b/Source/Core/DiscIO/CompressedBlob.cpp @@ -55,7 +55,7 @@ CompressedBlobReader::CompressedBlobReader(const std::string& filename) : m_file CompressedBlobReader* CompressedBlobReader::Create(const std::string& filename) { - if (IsCompressedBlob(filename)) + if (IsGCZBlob(filename)) return new CompressedBlobReader(filename); else return nullptr; @@ -148,7 +148,7 @@ bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u { bool scrubbing = false; - if (IsCompressedBlob(infile)) + if (IsGCZBlob(infile)) { PanicAlertT("\"%s\" is already compressed! Cannot compress it further.", infile.c_str()); return false; @@ -330,7 +330,7 @@ bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u bool DecompressBlobToFile(const std::string& infile, const std::string& outfile, CompressCB callback, void* arg) { - if (!IsCompressedBlob(infile)) + if (!IsGCZBlob(infile)) { PanicAlertT("File not compressed"); return false; @@ -400,7 +400,7 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile, return true; } -bool IsCompressedBlob(const std::string& filename) +bool IsGCZBlob(const std::string& filename) { File::IOFile f(filename, "rb"); diff --git a/Source/Core/DiscIO/CompressedBlob.h b/Source/Core/DiscIO/CompressedBlob.h index 7157f805b3..cfeefcd927 100644 --- a/Source/Core/DiscIO/CompressedBlob.h +++ b/Source/Core/DiscIO/CompressedBlob.h @@ -23,11 +23,11 @@ namespace DiscIO { -bool IsCompressedBlob(const std::string& filename); +bool IsGCZBlob(const std::string& filename); const u32 kBlobCookie = 0xB10BC001; -// A blob file structure: +// GCZ file structure: // BlobHeader // u64 offsetsToBlocks[n], top bit specifies whether the block is compressed, or not. // compressed data diff --git a/Source/Core/DolphinQt/GameList/GameFile.cpp b/Source/Core/DolphinQt/GameList/GameFile.cpp index 74b24590cb..2a9e993711 100644 --- a/Source/Core/DolphinQt/GameList/GameFile.cpp +++ b/Source/Core/DolphinQt/GameList/GameFile.cpp @@ -113,7 +113,7 @@ GameFile::GameFile(const QString& fileName) m_volume_size = volume->GetSize(); m_unique_id = QString::fromStdString(volume->GetUniqueID()); - m_compressed = DiscIO::IsCompressedBlob(fileName.toStdString()); + m_compressed = DiscIO::IsGCZBlob(fileName.toStdString()); m_disc_number = volume->GetDiscNumber(); m_revision = volume->GetRevision(); diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index f7841742cc..1a7c939fb8 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -111,7 +111,7 @@ GameListItem::GameListItem(const std::string& _rFileName, const std::unordered_m m_VolumeSize = pVolume->GetSize(); m_UniqueID = pVolume->GetUniqueID(); - m_BlobCompressed = DiscIO::IsCompressedBlob(_rFileName); + m_BlobCompressed = DiscIO::IsGCZBlob(_rFileName); m_disc_number = pVolume->GetDiscNumber(); m_Revision = pVolume->GetRevision(); From 6935d281128ea78169ecde44e869f83a7b67ddb8 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 26 Sep 2015 15:24:29 +0200 Subject: [PATCH 2/2] Display all compressed formats in blue in GUI In the past, only GCZ was shown as compressed, not CISO and WBFS. --- Source/Core/DiscIO/Blob.h | 3 ++- Source/Core/DiscIO/CISOBlob.h | 1 + Source/Core/DiscIO/CompressedBlob.h | 1 + Source/Core/DiscIO/DriveBlob.h | 1 + Source/Core/DiscIO/FileBlob.h | 1 + Source/Core/DiscIO/Volume.h | 3 ++- Source/Core/DiscIO/VolumeDirectory.cpp | 5 +++++ Source/Core/DiscIO/VolumeDirectory.h | 1 + Source/Core/DiscIO/VolumeGC.cpp | 5 +++++ Source/Core/DiscIO/VolumeGC.h | 1 + Source/Core/DiscIO/VolumeWad.cpp | 5 +++++ Source/Core/DiscIO/VolumeWad.h | 3 ++- Source/Core/DiscIO/VolumeWiiCrypted.cpp | 5 +++++ Source/Core/DiscIO/VolumeWiiCrypted.h | 1 + Source/Core/DiscIO/WbfsBlob.h | 1 + Source/Core/DolphinQt/GameList/GameFile.cpp | 2 +- Source/Core/DolphinWX/ISOFile.cpp | 2 +- 17 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Source/Core/DiscIO/Blob.h b/Source/Core/DiscIO/Blob.h index a66a62d97b..a20ba1888a 100644 --- a/Source/Core/DiscIO/Blob.h +++ b/Source/Core/DiscIO/Blob.h @@ -25,7 +25,8 @@ class IBlobReader public: virtual ~IBlobReader() {} - virtual u64 GetRawSize() const = 0; + virtual bool IsCompressed() const = 0; + virtual u64 GetRawSize() const = 0; virtual u64 GetDataSize() const = 0; // NOT thread-safe - can't call this from multiple threads. virtual bool Read(u64 offset, u64 size, u8* out_ptr) = 0; diff --git a/Source/Core/DiscIO/CISOBlob.h b/Source/Core/DiscIO/CISOBlob.h index 7a4638ecd7..2cbf78ba62 100644 --- a/Source/Core/DiscIO/CISOBlob.h +++ b/Source/Core/DiscIO/CISOBlob.h @@ -36,6 +36,7 @@ class CISOFileReader : public IBlobReader public: static CISOFileReader* Create(const std::string& filename); + bool IsCompressed() const override { return true; } u64 GetDataSize() const override; u64 GetRawSize() const override; bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; diff --git a/Source/Core/DiscIO/CompressedBlob.h b/Source/Core/DiscIO/CompressedBlob.h index cfeefcd927..d319ab3927 100644 --- a/Source/Core/DiscIO/CompressedBlob.h +++ b/Source/Core/DiscIO/CompressedBlob.h @@ -49,6 +49,7 @@ public: static CompressedBlobReader* Create(const std::string& filename); ~CompressedBlobReader(); const CompressedBlobHeader &GetHeader() const { return m_header; } + bool IsCompressed() const override { return true; } u64 GetDataSize() const override { return m_header.data_size; } u64 GetRawSize() const override { return m_file_size; } u64 GetBlockCompressedSize(u64 block_num) const; diff --git a/Source/Core/DiscIO/DriveBlob.h b/Source/Core/DiscIO/DriveBlob.h index f4716c1cf0..0ae09f5089 100644 --- a/Source/Core/DiscIO/DriveBlob.h +++ b/Source/Core/DiscIO/DriveBlob.h @@ -23,6 +23,7 @@ class DriveReader : public SectorReader public: static DriveReader* Create(const std::string& drive); ~DriveReader(); + bool IsCompressed() const override { return false; } u64 GetDataSize() const override { return m_size; } u64 GetRawSize() const override { return m_size; } diff --git a/Source/Core/DiscIO/FileBlob.h b/Source/Core/DiscIO/FileBlob.h index 92135de2af..9d5aa630fa 100644 --- a/Source/Core/DiscIO/FileBlob.h +++ b/Source/Core/DiscIO/FileBlob.h @@ -19,6 +19,7 @@ class PlainFileReader : public IBlobReader public: static PlainFileReader* Create(const std::string& filename); + bool IsCompressed() const override { return false; } u64 GetDataSize() const override { return m_size; } u64 GetRawSize() const override { return m_size; } bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h index a2314e825d..c8172c677e 100644 --- a/Source/Core/DiscIO/Volume.h +++ b/Source/Core/DiscIO/Volume.h @@ -101,8 +101,9 @@ public: virtual bool ChangePartition(u64 offset) { return false; } virtual ECountry GetCountry() const = 0; + virtual bool IsCompressed() const = 0; + // Size of virtual disc (not always accurate) virtual u64 GetSize() const = 0; - // Size on disc (compressed size) virtual u64 GetRawSize() const = 0; diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp index eadb198eeb..e6b55ce6a5 100644 --- a/Source/Core/DiscIO/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/VolumeDirectory.cpp @@ -225,6 +225,11 @@ IVolume::EPlatform CVolumeDirectory::GetVolumeType() const return m_is_wii ? WII_DISC : GAMECUBE_DISC; } +bool CVolumeDirectory::IsCompressed() const +{ + return false; +} + u64 CVolumeDirectory::GetSize() const { return 0; diff --git a/Source/Core/DiscIO/VolumeDirectory.h b/Source/Core/DiscIO/VolumeDirectory.h index 4dc7fa1a9a..8d90496e55 100644 --- a/Source/Core/DiscIO/VolumeDirectory.h +++ b/Source/Core/DiscIO/VolumeDirectory.h @@ -51,6 +51,7 @@ public: ECountry GetCountry() const override; + bool IsCompressed() const override; u64 GetSize() const override; u64 GetRawSize() const override; diff --git a/Source/Core/DiscIO/VolumeGC.cpp b/Source/Core/DiscIO/VolumeGC.cpp index e0d17f17ee..319955a133 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -168,6 +168,11 @@ std::string CVolumeGC::GetApploaderDate() const return DecodeString(date); } +bool CVolumeGC::IsCompressed() const +{ + return m_pReader ? m_pReader->IsCompressed() : false; +} + u64 CVolumeGC::GetSize() const { if (m_pReader) diff --git a/Source/Core/DiscIO/VolumeGC.h b/Source/Core/DiscIO/VolumeGC.h index 37777d093d..ed08b50871 100644 --- a/Source/Core/DiscIO/VolumeGC.h +++ b/Source/Core/DiscIO/VolumeGC.h @@ -39,6 +39,7 @@ public: EPlatform GetVolumeType() const override; ECountry GetCountry() const override; + bool IsCompressed() const override; u64 GetSize() const override; u64 GetRawSize() const override; diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index a268b3add9..0cbbe998bb 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -124,6 +124,11 @@ std::map CVolumeWAD::GetNames(bool prefer_long) return ReadWiiNames(name_data); } +bool CVolumeWAD::IsCompressed() const +{ + return m_pReader ? m_pReader->IsCompressed() : false; +} + u64 CVolumeWAD::GetSize() const { if (m_pReader) diff --git a/Source/Core/DiscIO/VolumeWad.h b/Source/Core/DiscIO/VolumeWad.h index 580a751a8d..99b1369fea 100644 --- a/Source/Core/DiscIO/VolumeWad.h +++ b/Source/Core/DiscIO/VolumeWad.h @@ -37,8 +37,9 @@ public: std::string GetApploaderDate() const override { return ""; } EPlatform GetVolumeType() const override; - ECountry GetCountry() const override; + + bool IsCompressed() const override; u64 GetSize() const override; u64 GetRawSize() const override; diff --git a/Source/Core/DiscIO/VolumeWiiCrypted.cpp b/Source/Core/DiscIO/VolumeWiiCrypted.cpp index aa7f36da64..87c68f8cd2 100644 --- a/Source/Core/DiscIO/VolumeWiiCrypted.cpp +++ b/Source/Core/DiscIO/VolumeWiiCrypted.cpp @@ -250,6 +250,11 @@ u8 CVolumeWiiCrypted::GetDiscNumber() const return disc_number; } +bool CVolumeWiiCrypted::IsCompressed() const +{ + return m_pReader ? m_pReader->IsCompressed() : false; +} + u64 CVolumeWiiCrypted::GetSize() const { if (m_pReader) diff --git a/Source/Core/DiscIO/VolumeWiiCrypted.h b/Source/Core/DiscIO/VolumeWiiCrypted.h index 66b48a2e44..ccf0865122 100644 --- a/Source/Core/DiscIO/VolumeWiiCrypted.h +++ b/Source/Core/DiscIO/VolumeWiiCrypted.h @@ -43,6 +43,7 @@ public: bool ChangePartition(u64 offset) override; ECountry GetCountry() const override; + bool IsCompressed() const override; u64 GetSize() const override; u64 GetRawSize() const override; diff --git a/Source/Core/DiscIO/WbfsBlob.h b/Source/Core/DiscIO/WbfsBlob.h index f0a95b170c..75e3af449f 100644 --- a/Source/Core/DiscIO/WbfsBlob.h +++ b/Source/Core/DiscIO/WbfsBlob.h @@ -19,6 +19,7 @@ class WbfsFileReader : public IBlobReader public: static WbfsFileReader* Create(const std::string& filename); + bool IsCompressed() const override { return true; } u64 GetDataSize() const override { return m_size; } u64 GetRawSize() const override { return m_size; } bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; diff --git a/Source/Core/DolphinQt/GameList/GameFile.cpp b/Source/Core/DolphinQt/GameList/GameFile.cpp index 2a9e993711..2a7cf3df2e 100644 --- a/Source/Core/DolphinQt/GameList/GameFile.cpp +++ b/Source/Core/DolphinQt/GameList/GameFile.cpp @@ -113,7 +113,7 @@ GameFile::GameFile(const QString& fileName) m_volume_size = volume->GetSize(); m_unique_id = QString::fromStdString(volume->GetUniqueID()); - m_compressed = DiscIO::IsGCZBlob(fileName.toStdString()); + m_compressed = volume->IsCompressed(); m_disc_number = volume->GetDiscNumber(); m_revision = volume->GetRevision(); diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 1a7c939fb8..2f5b89681f 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -111,7 +111,7 @@ GameListItem::GameListItem(const std::string& _rFileName, const std::unordered_m m_VolumeSize = pVolume->GetSize(); m_UniqueID = pVolume->GetUniqueID(); - m_BlobCompressed = DiscIO::IsGCZBlob(_rFileName); + m_BlobCompressed = pVolume->IsCompressed(); m_disc_number = pVolume->GetDiscNumber(); m_Revision = pVolume->GetRevision();