Skip to content

Commit

Permalink
Merge pull request #3092 from JosJuice/compressed-blobs
Browse files Browse the repository at this point in the history
Display all compressed formats in blue in GUI
  • Loading branch information
Tilka committed Sep 27, 2015
2 parents 8ea9b07 + 6935d28 commit 34c0203
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/Blob.cpp
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DiscIO/Blob.h
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DiscIO/CISOBlob.h
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/DiscIO/CompressedBlob.cpp
Expand Up @@ -57,7 +57,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;
Expand Down Expand Up @@ -150,7 +150,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;
Expand Down Expand Up @@ -332,7 +332,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;
Expand Down Expand Up @@ -402,7 +402,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");

Expand Down
5 changes: 3 additions & 2 deletions Source/Core/DiscIO/CompressedBlob.h
Expand Up @@ -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
Expand All @@ -49,6 +49,7 @@ class CompressedBlobReader : public SectorReader
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;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DiscIO/DriveBlob.h
Expand Up @@ -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; }

Expand Down
1 change: 1 addition & 0 deletions Source/Core/DiscIO/FileBlob.h
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DiscIO/Volume.h
Expand Up @@ -101,8 +101,9 @@ class IVolume
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;

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DiscIO/VolumeDirectory.cpp
Expand Up @@ -227,6 +227,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;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DiscIO/VolumeDirectory.h
Expand Up @@ -51,6 +51,7 @@ class CVolumeDirectory : public IVolume

ECountry GetCountry() const override;

bool IsCompressed() const override;
u64 GetSize() const override;
u64 GetRawSize() const override;

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DiscIO/VolumeGC.cpp
Expand Up @@ -169,6 +169,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)
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DiscIO/VolumeGC.h
Expand Up @@ -39,6 +39,7 @@ class CVolumeGC : public IVolume

EPlatform GetVolumeType() const override;
ECountry GetCountry() const override;
bool IsCompressed() const override;
u64 GetSize() const override;
u64 GetRawSize() const override;

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DiscIO/VolumeWad.cpp
Expand Up @@ -126,6 +126,11 @@ std::map<IVolume::ELanguage, std::string> 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)
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DiscIO/VolumeWad.h
Expand Up @@ -37,8 +37,9 @@ class CVolumeWAD : public IVolume
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;

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DiscIO/VolumeWiiCrypted.cpp
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DiscIO/VolumeWiiCrypted.h
Expand Up @@ -43,6 +43,7 @@ class CVolumeWiiCrypted : public IVolume
bool ChangePartition(u64 offset) override;

ECountry GetCountry() const override;
bool IsCompressed() const override;
u64 GetSize() const override;
u64 GetRawSize() const override;

Expand Down
1 change: 1 addition & 0 deletions Source/Core/DiscIO/WbfsBlob.h
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/GameList/GameFile.cpp
Expand Up @@ -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 = volume->IsCompressed();
m_disc_number = volume->GetDiscNumber();
m_revision = volume->GetRevision();

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/ISOFile.cpp
Expand Up @@ -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 = pVolume->IsCompressed();
m_disc_number = pVolume->GetDiscNumber();
m_Revision = pVolume->GetRevision();

Expand Down

0 comments on commit 34c0203

Please sign in to comment.