GameList: Add "File Size" field

This commit is contained in:
Stenzek
2023-12-20 23:40:24 +10:00
parent fd341f6a9d
commit 36643fe78b
15 changed files with 128 additions and 26 deletions

View File

@ -386,6 +386,11 @@ bool CDImage::IsPrecached() const
return false;
}
s64 CDImage::GetSizeOnDisk() const
{
return -1;
}
void CDImage::ClearTOC()
{
m_lba_count = 0;

View File

@ -328,6 +328,10 @@ public:
virtual PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback);
virtual bool IsPrecached() const;
// Returns the size on disk of the image. This could be multiple files.
// If this function returns -1, it means the size could not be computed.
virtual s64 GetSizeOnDisk() const;
protected:
void ClearTOC();
void CopyTOC(const CDImage* image);

View File

@ -25,6 +25,8 @@ public:
bool ReadSubChannelQ(SubChannelQ* subq, const Index& index, LBA lba_in_index) override;
bool HasNonStandardSubchannel() const override;
s64 GetSizeOnDisk() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -145,6 +147,11 @@ bool CDImageBin::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_i
return true;
}
s64 CDImageBin::GetSizeOnDisk() const
{
return FileSystem::FSize64(m_fp);
}
std::unique_ptr<CDImage> CDImage::OpenBinImage(const char* filename, Error* error)
{
std::unique_ptr<CDImageBin> image = std::make_unique<CDImageBin>();

View File

@ -68,6 +68,7 @@ public:
bool HasNonStandardSubchannel() const override;
PrecacheResult Precache(ProgressCallback* progress) override;
bool IsPrecached() const override;
s64 GetSizeOnDisk() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -571,6 +572,11 @@ ALWAYS_INLINE_RELEASE bool CDImageCHD::UpdateHunkBuffer(const Index& index, LBA
return true;
}
s64 CDImageCHD::GetSizeOnDisk() const
{
return static_cast<s64>(chd_get_compressed_size(m_chd));
}
std::unique_ptr<CDImage> CDImage::OpenCHDImage(const char* filename, Error* error)
{
std::unique_ptr<CDImageCHD> image = std::make_unique<CDImageCHD>();

View File

@ -32,6 +32,7 @@ public:
bool ReadSubChannelQ(SubChannelQ* subq, const Index& index, LBA lba_in_index) override;
bool HasNonStandardSubchannel() const override;
s64 GetSizeOnDisk() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -339,6 +340,15 @@ bool CDImageCueSheet::ReadSectorFromIndex(void* buffer, const Index& index, LBA
return true;
}
s64 CDImageCueSheet::GetSizeOnDisk() const
{
// Doesn't include the cue.. but they're tiny anyway, whatever.
u64 size = 0;
for (const TrackFile& tf : m_files)
size += FileSystem::FSize64(tf.file);
return size;
}
std::unique_ptr<CDImage> CDImage::OpenCueSheetImage(const char* filename, Error* error)
{
std::unique_ptr<CDImageCueSheet> image = std::make_unique<CDImageCueSheet>();

View File

@ -170,6 +170,7 @@ public:
bool ReadSubChannelQ(SubChannelQ* subq, const Index& index, LBA lba_in_index) override;
bool HasNonStandardSubchannel() const override;
s64 GetSizeOnDisk() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -542,6 +543,11 @@ bool CDImageEcm::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_i
return true;
}
s64 CDImageEcm::GetSizeOnDisk() const
{
return FileSystem::FSize64(m_fp);
}
std::unique_ptr<CDImage> CDImage::OpenEcmImage(const char* filename, Error* error)
{
std::unique_ptr<CDImageEcm> image = std::make_unique<CDImageEcm>();

View File

@ -48,6 +48,7 @@ public:
bool ReadSubChannelQ(SubChannelQ* subq, const Index& index, LBA lba_in_index) override;
bool HasNonStandardSubchannel() const override;
s64 GetSizeOnDisk() const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -285,6 +286,11 @@ bool CDImageMds::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_i
return true;
}
s64 CDImageMds::GetSizeOnDisk() const
{
return FileSystem::FSize64(m_mdf_file);
}
std::unique_ptr<CDImage> CDImage::OpenMdsImage(const char* filename, Error* error)
{
std::unique_ptr<CDImageMds> image = std::make_unique<CDImageMds>();

View File

@ -135,6 +135,7 @@ public:
bool ReadSubChannelQ(SubChannelQ* subq, const Index& index, LBA lba_in_index) override;
bool HasNonStandardSubchannel() const override;
s64 GetSizeOnDisk() const override;
bool HasSubImages() const override;
u32 GetSubImageCount() const override;
@ -960,6 +961,11 @@ std::string CDImagePBP::GetSubImageMetadata(u32 index, const std::string_view& t
return CDImage::GetSubImageMetadata(index, type);
}
s64 CDImagePBP::GetSizeOnDisk() const
{
return FileSystem::FSize64(m_file);
}
std::unique_ptr<CDImage> CDImage::OpenPBPImage(const char* filename, Error* error)
{
std::unique_ptr<CDImagePBP> image = std::make_unique<CDImagePBP>();

View File

@ -33,6 +33,7 @@ public:
bool ReadSubChannelQ(SubChannelQ* subq, const Index& index, LBA lba_in_index) override;
bool HasNonStandardSubchannel() const override;
s64 GetSizeOnDisk() const override;
std::string GetMetadata(const std::string_view& type) const override;
std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override;
@ -53,6 +54,7 @@ private:
std::unique_ptr<CDImage> m_parent_image;
std::vector<u8> m_replacement_data;
std::unordered_map<u32, u32> m_replacement_map;
s64 m_patch_size = 0;
u32 m_replacement_offset = 0;
};
@ -71,6 +73,8 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr<CDImage> parent_imag
return false;
}
m_patch_size = FileSystem::FSize64(fp.get());
u32 magic;
if (std::fread(&magic, sizeof(magic), 1, fp.get()) != 1)
{
@ -445,6 +449,11 @@ bool CDImagePPF::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_i
return true;
}
s64 CDImagePPF::GetSizeOnDisk() const
{
return m_patch_size + m_parent_image->GetSizeOnDisk();
}
std::unique_ptr<CDImage>
CDImage::OverlayPPFPatch(const char* filename, std::unique_ptr<CDImage> parent_image,
ProgressCallback* progress /* = ProgressCallback::NullProgressCallback */)