mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #3097 from JosJuice/blob-type
Fix blob type detection for game right-click menu
This commit is contained in:
@ -20,12 +20,23 @@
|
||||
namespace DiscIO
|
||||
{
|
||||
|
||||
// Increment CACHE_REVISION if the enum below is modified (ISOFile.cpp & GameFile.cpp)
|
||||
enum class BlobType
|
||||
{
|
||||
PLAIN,
|
||||
DRIVE,
|
||||
DIRECTORY,
|
||||
GCZ,
|
||||
CISO,
|
||||
WBFS
|
||||
};
|
||||
|
||||
class IBlobReader
|
||||
{
|
||||
public:
|
||||
virtual ~IBlobReader() {}
|
||||
|
||||
virtual bool IsCompressed() const = 0;
|
||||
virtual BlobType GetBlobType() const = 0;
|
||||
virtual u64 GetRawSize() const = 0;
|
||||
virtual u64 GetDataSize() const = 0;
|
||||
// NOT thread-safe - can't call this from multiple threads.
|
||||
|
@ -36,7 +36,7 @@ class CISOFileReader : public IBlobReader
|
||||
public:
|
||||
static CISOFileReader* Create(const std::string& filename);
|
||||
|
||||
bool IsCompressed() const override { return true; }
|
||||
BlobType GetBlobType() const override { return BlobType::CISO; }
|
||||
u64 GetDataSize() const override;
|
||||
u64 GetRawSize() const override;
|
||||
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
static CompressedBlobReader* Create(const std::string& filename);
|
||||
~CompressedBlobReader();
|
||||
const CompressedBlobHeader &GetHeader() const { return m_header; }
|
||||
bool IsCompressed() const override { return true; }
|
||||
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 GetBlockCompressedSize(u64 block_num) const;
|
||||
|
@ -23,7 +23,7 @@ class DriveReader : public SectorReader
|
||||
public:
|
||||
static DriveReader* Create(const std::string& drive);
|
||||
~DriveReader();
|
||||
bool IsCompressed() const override { return false; }
|
||||
BlobType GetBlobType() const override { return BlobType::DRIVE; }
|
||||
u64 GetDataSize() const override { return m_size; }
|
||||
u64 GetRawSize() const override { return m_size; }
|
||||
|
||||
|
@ -19,7 +19,7 @@ class PlainFileReader : public IBlobReader
|
||||
public:
|
||||
static PlainFileReader* Create(const std::string& filename);
|
||||
|
||||
bool IsCompressed() const override { return false; }
|
||||
BlobType GetBlobType() const override { return BlobType::PLAIN; }
|
||||
u64 GetDataSize() const override { return m_size; }
|
||||
u64 GetRawSize() const override { return m_size; }
|
||||
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
@ -101,7 +102,7 @@ public:
|
||||
virtual bool ChangePartition(u64 offset) { return false; }
|
||||
|
||||
virtual ECountry GetCountry() const = 0;
|
||||
virtual bool IsCompressed() const = 0;
|
||||
virtual BlobType GetBlobType() const = 0;
|
||||
// Size of virtual disc (not always accurate)
|
||||
virtual u64 GetSize() const = 0;
|
||||
// Size on disc (compressed size)
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/FileBlob.h"
|
||||
#include "DiscIO/FileMonitor.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
@ -227,9 +228,12 @@ IVolume::EPlatform CVolumeDirectory::GetVolumeType() const
|
||||
return m_is_wii ? WII_DISC : GAMECUBE_DISC;
|
||||
}
|
||||
|
||||
bool CVolumeDirectory::IsCompressed() const
|
||||
BlobType CVolumeDirectory::GetBlobType() const
|
||||
{
|
||||
return false;
|
||||
// VolumeDirectory isn't actually a blob, but it sort of acts
|
||||
// like one, so it makes sense that it has its own blob type.
|
||||
// It should be made into a proper blob in the future.
|
||||
return BlobType::DIRECTORY;
|
||||
}
|
||||
|
||||
u64 CVolumeDirectory::GetSize() const
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
namespace File { struct FSTEntry; }
|
||||
@ -51,7 +52,7 @@ public:
|
||||
|
||||
ECountry GetCountry() const override;
|
||||
|
||||
bool IsCompressed() const override;
|
||||
BlobType GetBlobType() const override;
|
||||
u64 GetSize() const override;
|
||||
u64 GetRawSize() const override;
|
||||
|
||||
|
@ -169,9 +169,9 @@ std::string CVolumeGC::GetApploaderDate() const
|
||||
return DecodeString(date);
|
||||
}
|
||||
|
||||
bool CVolumeGC::IsCompressed() const
|
||||
BlobType CVolumeGC::GetBlobType() const
|
||||
{
|
||||
return m_pReader ? m_pReader->IsCompressed() : false;
|
||||
return m_pReader ? m_pReader->GetBlobType() : BlobType::PLAIN;
|
||||
}
|
||||
|
||||
u64 CVolumeGC::GetSize() const
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
// --- this volume type is used for GC disc images ---
|
||||
@ -17,8 +18,6 @@
|
||||
namespace DiscIO
|
||||
{
|
||||
|
||||
class IBlobReader;
|
||||
|
||||
class CVolumeGC : public IVolume
|
||||
{
|
||||
public:
|
||||
@ -39,7 +38,7 @@ public:
|
||||
|
||||
EPlatform GetVolumeType() const override;
|
||||
ECountry GetCountry() const override;
|
||||
bool IsCompressed() const override;
|
||||
BlobType GetBlobType() const override;
|
||||
u64 GetSize() const override;
|
||||
u64 GetRawSize() const override;
|
||||
|
||||
|
@ -126,9 +126,9 @@ std::map<IVolume::ELanguage, std::string> CVolumeWAD::GetNames(bool prefer_long)
|
||||
return ReadWiiNames(name_data);
|
||||
}
|
||||
|
||||
bool CVolumeWAD::IsCompressed() const
|
||||
BlobType CVolumeWAD::GetBlobType() const
|
||||
{
|
||||
return m_pReader ? m_pReader->IsCompressed() : false;
|
||||
return m_pReader ? m_pReader->GetBlobType() : BlobType::PLAIN;
|
||||
}
|
||||
|
||||
u64 CVolumeWAD::GetSize() const
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
// --- this volume type is used for Wad files ---
|
||||
@ -19,8 +20,6 @@
|
||||
namespace DiscIO
|
||||
{
|
||||
|
||||
class IBlobReader;
|
||||
|
||||
class CVolumeWAD : public IVolume
|
||||
{
|
||||
public:
|
||||
@ -39,7 +38,7 @@ public:
|
||||
EPlatform GetVolumeType() const override;
|
||||
ECountry GetCountry() const override;
|
||||
|
||||
bool IsCompressed() const override;
|
||||
BlobType GetBlobType() const override;
|
||||
u64 GetSize() const override;
|
||||
u64 GetRawSize() const override;
|
||||
|
||||
|
@ -250,9 +250,9 @@ u8 CVolumeWiiCrypted::GetDiscNumber() const
|
||||
return disc_number;
|
||||
}
|
||||
|
||||
bool CVolumeWiiCrypted::IsCompressed() const
|
||||
BlobType CVolumeWiiCrypted::GetBlobType() const
|
||||
{
|
||||
return m_pReader ? m_pReader->IsCompressed() : false;
|
||||
return m_pReader ? m_pReader->GetBlobType() : BlobType::PLAIN;
|
||||
}
|
||||
|
||||
u64 CVolumeWiiCrypted::GetSize() const
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <polarssl/aes.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
// --- this volume type is used for encrypted Wii images ---
|
||||
@ -18,8 +19,6 @@
|
||||
namespace DiscIO
|
||||
{
|
||||
|
||||
class IBlobReader;
|
||||
|
||||
class CVolumeWiiCrypted : public IVolume
|
||||
{
|
||||
public:
|
||||
@ -43,7 +42,7 @@ public:
|
||||
bool ChangePartition(u64 offset) override;
|
||||
|
||||
ECountry GetCountry() const override;
|
||||
bool IsCompressed() const override;
|
||||
BlobType GetBlobType() const override;
|
||||
u64 GetSize() const override;
|
||||
u64 GetRawSize() const override;
|
||||
|
||||
|
@ -19,7 +19,7 @@ class WbfsFileReader : public IBlobReader
|
||||
public:
|
||||
static WbfsFileReader* Create(const std::string& filename);
|
||||
|
||||
bool IsCompressed() const override { return true; }
|
||||
BlobType GetBlobType() const override { return BlobType::WBFS; }
|
||||
u64 GetDataSize() const override { return m_size; }
|
||||
u64 GetRawSize() const override { return m_size; }
|
||||
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
|
||||
|
Reference in New Issue
Block a user