mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 23:59:27 +01:00
DiscIO: Make factory methods return unique_ptrs
Rather than rely on the developer to do the right thing, just make the default behavior safely deallocate resources. If shared semantics are ever needed in the future, the constructor that takes a unique_ptr for shared_ptr can be used.
This commit is contained in:
parent
a0ac2b8673
commit
edbbf493f8
@ -429,14 +429,14 @@ const DiscIO::IVolume& GetVolume()
|
||||
bool SetVolumeName(const std::string& disc_path)
|
||||
{
|
||||
DVDThread::WaitUntilIdle();
|
||||
s_inserted_volume = std::unique_ptr<DiscIO::IVolume>(DiscIO::CreateVolumeFromFilename(disc_path));
|
||||
s_inserted_volume = DiscIO::CreateVolumeFromFilename(disc_path);
|
||||
return VolumeIsValid();
|
||||
}
|
||||
|
||||
bool SetVolumeDirectory(const std::string& full_path, bool is_wii, const std::string& apploader_path, const std::string& DOL_path)
|
||||
{
|
||||
DVDThread::WaitUntilIdle();
|
||||
s_inserted_volume = std::unique_ptr<DiscIO::IVolume>(DiscIO::CreateVolumeFromDirectory(full_path, is_wii, apploader_path, DOL_path));
|
||||
s_inserted_volume = DiscIO::CreateVolumeFromDirectory(full_path, is_wii, apploader_path, DOL_path);
|
||||
return VolumeIsValid();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CDUtils.h"
|
||||
@ -114,7 +115,7 @@ bool SectorReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *
|
||||
return true;
|
||||
}
|
||||
|
||||
IBlobReader* CreateBlobReader(const std::string& filename)
|
||||
std::unique_ptr<IBlobReader> CreateBlobReader(const std::string& filename)
|
||||
{
|
||||
if (cdio_is_cdrom(filename))
|
||||
return DriveReader::Create(filename);
|
||||
|
@ -14,6 +14,7 @@
|
||||
// detect whether the file is a compressed blob, or just a big hunk of data, or a drive, and
|
||||
// automatically do the right thing.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
@ -75,7 +76,7 @@ private:
|
||||
};
|
||||
|
||||
// Factory function - examines the path to choose the right type of IBlobReader, and returns one.
|
||||
IBlobReader* CreateBlobReader(const std::string& filename);
|
||||
std::unique_ptr<IBlobReader> CreateBlobReader(const std::string& filename);
|
||||
|
||||
typedef bool (*CompressCB)(const std::string& text, float percent, void* arg);
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
@ -29,17 +30,15 @@ CISOFileReader::CISOFileReader(std::FILE* file)
|
||||
m_ciso_map[idx] = (1 == header.map[idx]) ? count++ : UNUSED_BLOCK_ID;
|
||||
}
|
||||
|
||||
CISOFileReader* CISOFileReader::Create(const std::string& filename)
|
||||
std::unique_ptr<CISOFileReader> CISOFileReader::Create(const std::string& filename)
|
||||
{
|
||||
if (IsCISOBlob(filename))
|
||||
{
|
||||
File::IOFile f(filename, "rb");
|
||||
return new CISOFileReader(f.ReleaseHandle());
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
return std::unique_ptr<CISOFileReader>(new CISOFileReader(f.ReleaseHandle()));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
u64 CISOFileReader::GetDataSize() const
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -34,7 +35,7 @@ struct CISOHeader
|
||||
class CISOFileReader : public IBlobReader
|
||||
{
|
||||
public:
|
||||
static CISOFileReader* Create(const std::string& filename);
|
||||
static std::unique_ptr<CISOFileReader> Create(const std::string& filename);
|
||||
|
||||
BlobType GetBlobType() const override { return BlobType::CISO; }
|
||||
|
||||
|
@ -55,12 +55,12 @@ CompressedBlobReader::CompressedBlobReader(const std::string& filename) : m_file
|
||||
memset(m_zlib_buffer, 0, m_zlib_buffer_size);
|
||||
}
|
||||
|
||||
CompressedBlobReader* CompressedBlobReader::Create(const std::string& filename)
|
||||
std::unique_ptr<CompressedBlobReader> CompressedBlobReader::Create(const std::string& filename)
|
||||
{
|
||||
if (IsGCZBlob(filename))
|
||||
return new CompressedBlobReader(filename);
|
||||
else
|
||||
return nullptr;
|
||||
return std::unique_ptr<CompressedBlobReader>(new CompressedBlobReader(filename));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CompressedBlobReader::~CompressedBlobReader()
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -46,7 +47,7 @@ struct CompressedBlobHeader // 32 bytes
|
||||
class CompressedBlobReader : public SectorReader
|
||||
{
|
||||
public:
|
||||
static CompressedBlobReader* Create(const std::string& filename);
|
||||
static std::unique_ptr<CompressedBlobReader> Create(const std::string& filename);
|
||||
~CompressedBlobReader();
|
||||
const CompressedBlobHeader &GetHeader() const { return m_header; }
|
||||
BlobType GetBlobType() const override { return BlobType::GCZ; }
|
||||
|
@ -34,7 +34,7 @@ static int m_BlocksPerCluster;
|
||||
static bool m_isScrubbing = false;
|
||||
|
||||
static std::string m_Filename;
|
||||
static IVolume* m_Disc = nullptr;
|
||||
static std::unique_ptr<IVolume> s_disc;
|
||||
|
||||
struct SPartitionHeader
|
||||
{
|
||||
@ -94,11 +94,11 @@ bool SetupScrub(const std::string& filename, int block_size)
|
||||
|
||||
m_BlocksPerCluster = CLUSTER_SIZE / m_BlockSize;
|
||||
|
||||
m_Disc = CreateVolumeFromFilename(filename);
|
||||
if (!m_Disc)
|
||||
s_disc = CreateVolumeFromFilename(filename);
|
||||
if (!s_disc)
|
||||
return false;
|
||||
|
||||
m_FileSize = m_Disc->GetSize();
|
||||
m_FileSize = s_disc->GetSize();
|
||||
|
||||
u32 numClusters = (u32)(m_FileSize / CLUSTER_SIZE);
|
||||
|
||||
@ -112,9 +112,9 @@ bool SetupScrub(const std::string& filename, int block_size)
|
||||
|
||||
// Fill out table of free blocks
|
||||
success = ParseDisc();
|
||||
|
||||
// Done with it; need it closed for the next part
|
||||
delete m_Disc;
|
||||
m_Disc = nullptr;
|
||||
s_disc.reset();
|
||||
m_BlockCount = 0;
|
||||
|
||||
// Let's not touch the file if we've failed up to here :p
|
||||
@ -194,12 +194,12 @@ void MarkAsUsedE(u64 _PartitionDataOffset, u64 _Offset, u64 _Size)
|
||||
// Helper functions for reading the BE volume
|
||||
void ReadFromVolume(u64 _Offset, u32& _Buffer, bool _Decrypt)
|
||||
{
|
||||
m_Disc->Read(_Offset, sizeof(u32), (u8*)&_Buffer, _Decrypt);
|
||||
s_disc->Read(_Offset, sizeof(u32), (u8*)&_Buffer, _Decrypt);
|
||||
_Buffer = Common::swap32(_Buffer);
|
||||
}
|
||||
void ReadFromVolume(u64 _Offset, u64& _Buffer, bool _Decrypt)
|
||||
{
|
||||
m_Disc->Read(_Offset, sizeof(u32), (u8*)&_Buffer, _Decrypt);
|
||||
s_disc->Read(_Offset, sizeof(u32), (u8*)&_Buffer, _Decrypt);
|
||||
_Buffer = Common::swap32((u32)_Buffer);
|
||||
_Buffer <<= 2;
|
||||
}
|
||||
@ -259,71 +259,71 @@ bool ParseDisc()
|
||||
}
|
||||
|
||||
// Operations dealing with encrypted space are done here - the volume is swapped to allow this
|
||||
bool ParsePartitionData(SPartition& _rPartition)
|
||||
bool ParsePartitionData(SPartition& partition)
|
||||
{
|
||||
bool ParsedOK = true;
|
||||
bool parsed_ok = true;
|
||||
|
||||
// Switch out the main volume temporarily
|
||||
IVolume *OldVolume = m_Disc;
|
||||
std::unique_ptr<IVolume> old_volume;
|
||||
s_disc.swap(old_volume);
|
||||
|
||||
// Ready some stuff
|
||||
m_Disc = CreateVolumeFromFilename(m_Filename, _rPartition.GroupNumber, _rPartition.Number);
|
||||
if (m_Disc == nullptr)
|
||||
s_disc = CreateVolumeFromFilename(m_Filename, partition.GroupNumber, partition.Number);
|
||||
if (s_disc == nullptr)
|
||||
{
|
||||
ERROR_LOG(DISCIO, "Failed to create volume from file %s", m_Filename.c_str());
|
||||
m_Disc = OldVolume;
|
||||
s_disc.swap(old_volume);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<IFileSystem> filesystem(CreateFileSystem(m_Disc));
|
||||
std::unique_ptr<IFileSystem> filesystem(CreateFileSystem(s_disc.get()));
|
||||
if (!filesystem)
|
||||
{
|
||||
ERROR_LOG(DISCIO, "Failed to create filesystem for group %d partition %u", _rPartition.GroupNumber, _rPartition.Number);
|
||||
ParsedOK = false;
|
||||
ERROR_LOG(DISCIO, "Failed to create filesystem for group %d partition %u", partition.GroupNumber, partition.Number);
|
||||
parsed_ok = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mark things as used which are not in the filesystem
|
||||
// Header, Header Information, Apploader
|
||||
ReadFromVolume(0x2440 + 0x14, _rPartition.Header.ApploaderSize, true);
|
||||
ReadFromVolume(0x2440 + 0x18, _rPartition.Header.ApploaderTrailerSize, true);
|
||||
MarkAsUsedE(_rPartition.Offset
|
||||
+ _rPartition.Header.DataOffset
|
||||
ReadFromVolume(0x2440 + 0x14, partition.Header.ApploaderSize, true);
|
||||
ReadFromVolume(0x2440 + 0x18, partition.Header.ApploaderTrailerSize, true);
|
||||
MarkAsUsedE(partition.Offset
|
||||
+ partition.Header.DataOffset
|
||||
, 0
|
||||
, 0x2440
|
||||
+ _rPartition.Header.ApploaderSize
|
||||
+ _rPartition.Header.ApploaderTrailerSize);
|
||||
+ partition.Header.ApploaderSize
|
||||
+ partition.Header.ApploaderTrailerSize);
|
||||
|
||||
// DOL
|
||||
ReadFromVolume(0x420, _rPartition.Header.DOLOffset, true);
|
||||
_rPartition.Header.DOLSize = filesystem->GetBootDOLSize(_rPartition.Header.DOLOffset);
|
||||
MarkAsUsedE(_rPartition.Offset
|
||||
+ _rPartition.Header.DataOffset
|
||||
, _rPartition.Header.DOLOffset
|
||||
, _rPartition.Header.DOLSize);
|
||||
ReadFromVolume(0x420, partition.Header.DOLOffset, true);
|
||||
partition.Header.DOLSize = filesystem->GetBootDOLSize(partition.Header.DOLOffset);
|
||||
MarkAsUsedE(partition.Offset
|
||||
+ partition.Header.DataOffset
|
||||
, partition.Header.DOLOffset
|
||||
, partition.Header.DOLSize);
|
||||
|
||||
// FST
|
||||
ReadFromVolume(0x424, _rPartition.Header.FSTOffset, true);
|
||||
ReadFromVolume(0x428, _rPartition.Header.FSTSize, true);
|
||||
MarkAsUsedE(_rPartition.Offset
|
||||
+ _rPartition.Header.DataOffset
|
||||
, _rPartition.Header.FSTOffset
|
||||
, _rPartition.Header.FSTSize);
|
||||
ReadFromVolume(0x424, partition.Header.FSTOffset, true);
|
||||
ReadFromVolume(0x428, partition.Header.FSTSize, true);
|
||||
MarkAsUsedE(partition.Offset
|
||||
+ partition.Header.DataOffset
|
||||
, partition.Header.FSTOffset
|
||||
, partition.Header.FSTSize);
|
||||
|
||||
// Go through the filesystem and mark entries as used
|
||||
for (SFileInfo file : filesystem->GetFileList())
|
||||
{
|
||||
DEBUG_LOG(DISCIO, "%s", file.m_FullPath.empty() ? "/" : file.m_FullPath.c_str());
|
||||
if ((file.m_NameOffset & 0x1000000) == 0)
|
||||
MarkAsUsedE(_rPartition.Offset + _rPartition.Header.DataOffset, file.m_Offset, file.m_FileSize);
|
||||
MarkAsUsedE(partition.Offset + partition.Header.DataOffset, file.m_Offset, file.m_FileSize);
|
||||
}
|
||||
}
|
||||
|
||||
// Swap back
|
||||
delete m_Disc;
|
||||
m_Disc = OldVolume;
|
||||
s_disc.swap(old_volume);
|
||||
|
||||
return ParsedOK;
|
||||
return parsed_ok;
|
||||
}
|
||||
|
||||
} // namespace DiscScrubber
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -84,15 +85,12 @@ DriveReader::~DriveReader()
|
||||
#endif
|
||||
}
|
||||
|
||||
DriveReader* DriveReader::Create(const std::string& drive)
|
||||
std::unique_ptr<DriveReader> DriveReader::Create(const std::string& drive)
|
||||
{
|
||||
DriveReader* reader = new DriveReader(drive);
|
||||
auto reader = std::unique_ptr<DriveReader>(new DriveReader(drive));
|
||||
|
||||
if (!reader->IsOK())
|
||||
{
|
||||
delete reader;
|
||||
return nullptr;
|
||||
}
|
||||
reader.reset();
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -21,7 +22,7 @@ namespace DiscIO
|
||||
class DriveReader : public SectorReader
|
||||
{
|
||||
public:
|
||||
static DriveReader* Create(const std::string& drive);
|
||||
static std::unique_ptr<DriveReader> Create(const std::string& drive);
|
||||
~DriveReader();
|
||||
BlobType GetBlobType() const override { return BlobType::DRIVE; }
|
||||
u64 GetDataSize() const override { return m_size; }
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "DiscIO/FileBlob.h"
|
||||
|
||||
@ -14,13 +15,13 @@ PlainFileReader::PlainFileReader(std::FILE* file)
|
||||
m_size = m_file.GetSize();
|
||||
}
|
||||
|
||||
PlainFileReader* PlainFileReader::Create(const std::string& filename)
|
||||
std::unique_ptr<PlainFileReader> PlainFileReader::Create(const std::string& filename)
|
||||
{
|
||||
File::IOFile f(filename, "rb");
|
||||
if (f)
|
||||
return new PlainFileReader(f.ReleaseHandle());
|
||||
else
|
||||
return nullptr;
|
||||
return std::unique_ptr<PlainFileReader>(new PlainFileReader(f.ReleaseHandle()));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -17,7 +18,7 @@ namespace DiscIO
|
||||
class PlainFileReader : public IBlobReader
|
||||
{
|
||||
public:
|
||||
static PlainFileReader* Create(const std::string& filename);
|
||||
static std::unique_ptr<PlainFileReader> Create(const std::string& filename);
|
||||
|
||||
BlobType GetBlobType() const override { return BlobType::PLAIN; }
|
||||
u64 GetDataSize() const override { return m_size; }
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
@ -25,8 +26,8 @@
|
||||
namespace FileMon
|
||||
{
|
||||
|
||||
static DiscIO::IVolume *OpenISO = nullptr;
|
||||
static DiscIO::IFileSystem *pFileSystem = nullptr;
|
||||
static std::unique_ptr<DiscIO::IVolume> s_open_iso;
|
||||
static std::unique_ptr<DiscIO::IFileSystem> s_filesystem;
|
||||
static std::string ISOFile = "", CurrentFile = "";
|
||||
static bool FileAccess = true;
|
||||
|
||||
@ -61,26 +62,18 @@ bool IsSoundFile(const std::string& filename)
|
||||
void ReadFileSystem(const std::string& filename)
|
||||
{
|
||||
// Should have an actual Shutdown procedure or something
|
||||
if (OpenISO != nullptr)
|
||||
{
|
||||
delete OpenISO;
|
||||
OpenISO = nullptr;
|
||||
}
|
||||
if (pFileSystem != nullptr)
|
||||
{
|
||||
delete pFileSystem;
|
||||
pFileSystem = nullptr;
|
||||
}
|
||||
s_open_iso.reset();
|
||||
s_filesystem.reset();
|
||||
|
||||
OpenISO = DiscIO::CreateVolumeFromFilename(filename);
|
||||
if (!OpenISO)
|
||||
s_open_iso = DiscIO::CreateVolumeFromFilename(filename);
|
||||
if (!s_open_iso)
|
||||
return;
|
||||
|
||||
if (OpenISO->GetVolumeType() != DiscIO::IVolume::WII_WAD)
|
||||
if (s_open_iso->GetVolumeType() != DiscIO::IVolume::WII_WAD)
|
||||
{
|
||||
pFileSystem = DiscIO::CreateFileSystem(OpenISO);
|
||||
s_filesystem = DiscIO::CreateFileSystem(s_open_iso.get());
|
||||
|
||||
if (!pFileSystem)
|
||||
if (!s_filesystem)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -130,7 +123,7 @@ void FindFilename(u64 offset)
|
||||
if (!FileAccess)
|
||||
return;
|
||||
|
||||
if (!pFileSystem || ISOFile != SConfig::GetInstance().m_LastFilename)
|
||||
if (!s_filesystem || ISOFile != SConfig::GetInstance().m_LastFilename)
|
||||
{
|
||||
FileAccess = false;
|
||||
ReadFileSystem(SConfig::GetInstance().m_LastFilename);
|
||||
@ -139,27 +132,18 @@ void FindFilename(u64 offset)
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string filename = pFileSystem->GetFileName(offset);
|
||||
const std::string filename = s_filesystem->GetFileName(offset);
|
||||
|
||||
if (filename.empty())
|
||||
return;
|
||||
|
||||
CheckFile(filename, pFileSystem->GetFileSize(filename));
|
||||
CheckFile(filename, s_filesystem->GetFileSize(filename));
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
if (OpenISO != nullptr)
|
||||
{
|
||||
delete OpenISO;
|
||||
OpenISO = nullptr;
|
||||
}
|
||||
|
||||
if (pFileSystem != nullptr)
|
||||
{
|
||||
delete pFileSystem;
|
||||
pFileSystem = nullptr;
|
||||
}
|
||||
s_open_iso.reset();
|
||||
s_filesystem.reset();
|
||||
|
||||
ISOFile = "";
|
||||
CurrentFile = "";
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
#include "DiscIO/Filesystem.h"
|
||||
#include "DiscIO/FileSystemGCWii.h"
|
||||
|
||||
@ -17,20 +18,17 @@ IFileSystem::~IFileSystem()
|
||||
{}
|
||||
|
||||
|
||||
IFileSystem* CreateFileSystem(const IVolume* _rVolume)
|
||||
std::unique_ptr<IFileSystem> CreateFileSystem(const IVolume* volume)
|
||||
{
|
||||
IFileSystem* pFileSystem = new CFileSystemGCWii(_rVolume);
|
||||
std::unique_ptr<IFileSystem> filesystem = std::make_unique<CFileSystemGCWii>(volume);
|
||||
|
||||
if (!pFileSystem)
|
||||
if (!filesystem)
|
||||
return nullptr;
|
||||
|
||||
if (!pFileSystem->IsValid())
|
||||
{
|
||||
delete pFileSystem;
|
||||
pFileSystem = nullptr;
|
||||
}
|
||||
if (!filesystem->IsValid())
|
||||
filesystem.reset();
|
||||
|
||||
return pFileSystem;
|
||||
return filesystem;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -57,6 +56,6 @@ protected:
|
||||
const IVolume *m_rVolume;
|
||||
};
|
||||
|
||||
IFileSystem* CreateFileSystem(const IVolume *_rVolume);
|
||||
std::unique_ptr<IFileSystem> CreateFileSystem(const IVolume* volume);
|
||||
|
||||
} // namespace
|
||||
|
@ -71,12 +71,12 @@ static const unsigned char s_master_key_korean[16] = {
|
||||
0x13,0xf2,0xfe,0xfb,0xba,0x4c,0x9b,0x7e
|
||||
};
|
||||
|
||||
static IVolume* CreateVolumeFromCryptedWiiImage(std::unique_ptr<IBlobReader> reader, u32 _PartitionGroup, u32 _VolumeType, u32 _VolumeNum);
|
||||
static std::unique_ptr<IVolume> CreateVolumeFromCryptedWiiImage(std::unique_ptr<IBlobReader> reader, u32 partition_group, u32 volume_type, u32 volume_number);
|
||||
EDiscType GetDiscType(IBlobReader& _rReader);
|
||||
|
||||
IVolume* CreateVolumeFromFilename(const std::string& _rFilename, u32 _PartitionGroup, u32 _VolumeNum)
|
||||
std::unique_ptr<IVolume> CreateVolumeFromFilename(const std::string& filename, u32 partition_group, u32 volume_number)
|
||||
{
|
||||
std::unique_ptr<IBlobReader> reader(CreateBlobReader(_rFilename));
|
||||
std::unique_ptr<IBlobReader> reader(CreateBlobReader(filename));
|
||||
if (reader == nullptr)
|
||||
return nullptr;
|
||||
|
||||
@ -84,30 +84,30 @@ IVolume* CreateVolumeFromFilename(const std::string& _rFilename, u32 _PartitionG
|
||||
{
|
||||
case DISC_TYPE_WII:
|
||||
case DISC_TYPE_GC:
|
||||
return new CVolumeGC(std::move(reader));
|
||||
return std::make_unique<CVolumeGC>(std::move(reader));
|
||||
|
||||
case DISC_TYPE_WAD:
|
||||
return new CVolumeWAD(std::move(reader));
|
||||
return std::make_unique<CVolumeWAD>(std::move(reader));
|
||||
|
||||
case DISC_TYPE_WII_CONTAINER:
|
||||
return CreateVolumeFromCryptedWiiImage(std::move(reader), _PartitionGroup, 0, _VolumeNum);
|
||||
return CreateVolumeFromCryptedWiiImage(std::move(reader), partition_group, 0, volume_number);
|
||||
|
||||
case DISC_TYPE_UNK:
|
||||
default:
|
||||
std::string Filename, ext;
|
||||
SplitPath(_rFilename, nullptr, &Filename, &ext);
|
||||
Filename += ext;
|
||||
std::string name, extension;
|
||||
SplitPath(filename, nullptr, &name, &extension);
|
||||
name += extension;
|
||||
NOTICE_LOG(DISCIO, "%s does not have the Magic word for a gcm, wiidisc or wad file\n"
|
||||
"Set Log Verbosity to Warning and attempt to load the game again to view the values", Filename.c_str());
|
||||
"Set Log Verbosity to Warning and attempt to load the game again to view the values", name.c_str());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii, const std::string& _rApploader, const std::string& _rDOL)
|
||||
std::unique_ptr<IVolume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii, const std::string& apploader, const std::string& dol)
|
||||
{
|
||||
if (CVolumeDirectory::IsValidDirectory(_rDirectory))
|
||||
return new CVolumeDirectory(_rDirectory, _bIsWii, _rApploader, _rDOL);
|
||||
if (CVolumeDirectory::IsValidDirectory(directory))
|
||||
return std::make_unique<CVolumeDirectory>(directory, is_wii, apploader, dol);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -137,55 +137,55 @@ void VolumeKeyForPartition(IBlobReader& _rReader, u64 offset, u8* VolumeKey)
|
||||
mbedtls_aes_crypt_cbc(&AES_ctx, MBEDTLS_AES_DECRYPT, 16, IV, SubKey, VolumeKey);
|
||||
}
|
||||
|
||||
static IVolume* CreateVolumeFromCryptedWiiImage(std::unique_ptr<IBlobReader> reader, u32 _PartitionGroup, u32 _VolumeType, u32 _VolumeNum)
|
||||
static std::unique_ptr<IVolume> CreateVolumeFromCryptedWiiImage(std::unique_ptr<IBlobReader> reader, u32 partition_group, u32 volume_type, u32 volume_number)
|
||||
{
|
||||
CBlobBigEndianReader big_endian_reader(*reader);
|
||||
|
||||
u32 numPartitions = big_endian_reader.Read32(0x40000 + (_PartitionGroup * 8));
|
||||
u64 PartitionsOffset = (u64)big_endian_reader.Read32(0x40000 + (_PartitionGroup * 8) + 4) << 2;
|
||||
u32 numPartitions = big_endian_reader.Read32(0x40000 + (partition_group * 8));
|
||||
u64 PartitionsOffset = (u64)big_endian_reader.Read32(0x40000 + (partition_group * 8) + 4) << 2;
|
||||
|
||||
// Check if we're looking for a valid partition
|
||||
if ((int)_VolumeNum != -1 && _VolumeNum > numPartitions)
|
||||
if ((int)volume_number != -1 && volume_number > numPartitions)
|
||||
return nullptr;
|
||||
|
||||
struct SPartition
|
||||
{
|
||||
u64 Offset;
|
||||
u32 Type;
|
||||
u64 offset;
|
||||
u32 type;
|
||||
};
|
||||
|
||||
struct SPartitionGroup
|
||||
{
|
||||
u32 numPartitions;
|
||||
u64 PartitionsOffset;
|
||||
std::vector<SPartition> PartitionsVec;
|
||||
u32 num_partitions;
|
||||
u64 partitions_offset;
|
||||
std::vector<SPartition> partitions;
|
||||
};
|
||||
SPartitionGroup PartitionGroup[4];
|
||||
SPartitionGroup partition_groups[4];
|
||||
|
||||
// Read all partitions
|
||||
for (SPartitionGroup& group : PartitionGroup)
|
||||
for (SPartitionGroup& group : partition_groups)
|
||||
{
|
||||
for (u32 i = 0; i < numPartitions; i++)
|
||||
{
|
||||
SPartition Partition;
|
||||
Partition.Offset = ((u64)big_endian_reader.Read32(PartitionsOffset + (i * 8) + 0)) << 2;
|
||||
Partition.Type = big_endian_reader.Read32(PartitionsOffset + (i * 8) + 4);
|
||||
group.PartitionsVec.push_back(Partition);
|
||||
SPartition partition;
|
||||
partition.offset = ((u64)big_endian_reader.Read32(PartitionsOffset + (i * 8) + 0)) << 2;
|
||||
partition.type = big_endian_reader.Read32(PartitionsOffset + (i * 8) + 4);
|
||||
group.partitions.push_back(partition);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the partition type specified or number
|
||||
// types: 0 = game, 1 = firmware update, 2 = channel installer
|
||||
// some partitions on SSBB use the ASCII title id of the demo VC game they hold...
|
||||
for (size_t i = 0; i < PartitionGroup[_PartitionGroup].PartitionsVec.size(); i++)
|
||||
for (size_t i = 0; i < partition_groups[partition_group].partitions.size(); i++)
|
||||
{
|
||||
const SPartition& rPartition = PartitionGroup[_PartitionGroup].PartitionsVec.at(i);
|
||||
const SPartition& partition = partition_groups[partition_group].partitions.at(i);
|
||||
|
||||
if ((rPartition.Type == _VolumeType && (int)_VolumeNum == -1) || i == _VolumeNum)
|
||||
if ((partition.type == volume_type && (int)volume_number == -1) || i == volume_number)
|
||||
{
|
||||
u8 VolumeKey[16];
|
||||
VolumeKeyForPartition(*reader, rPartition.Offset, VolumeKey);
|
||||
return new CVolumeWiiCrypted(std::move(reader), rPartition.Offset, VolumeKey);
|
||||
u8 volume_key[16];
|
||||
VolumeKeyForPartition(*reader, partition.offset, volume_key);
|
||||
return std::make_unique<CVolumeWiiCrypted>(std::move(reader), partition.offset, volume_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -14,8 +15,8 @@ namespace DiscIO
|
||||
class IVolume;
|
||||
class IBlobReader;
|
||||
|
||||
IVolume* CreateVolumeFromFilename(const std::string& _rFilename, u32 _PartitionGroup = 0, u32 _VolumeNum = -1);
|
||||
IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii, const std::string& _rApploader = "", const std::string& _rDOL = "");
|
||||
std::unique_ptr<IVolume> CreateVolumeFromFilename(const std::string& filename, u32 partition_group = 0, u32 volume_number = -1);
|
||||
std::unique_ptr<IVolume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii, const std::string& apploader = "", const std::string& dol = "");
|
||||
void VolumeKeyForPartition(IBlobReader& _rReader, u64 offset, u8* VolumeKey);
|
||||
|
||||
} // namespace
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -167,19 +168,14 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
|
||||
return m_files[0]->file;
|
||||
}
|
||||
|
||||
WbfsFileReader* WbfsFileReader::Create(const std::string& filename)
|
||||
std::unique_ptr<WbfsFileReader> WbfsFileReader::Create(const std::string& filename)
|
||||
{
|
||||
WbfsFileReader* reader = new WbfsFileReader(filename);
|
||||
auto reader = std::unique_ptr<WbfsFileReader>(new WbfsFileReader(filename));
|
||||
|
||||
if (reader->IsGood())
|
||||
{
|
||||
return reader;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete reader;
|
||||
return nullptr;
|
||||
}
|
||||
if (!reader->IsGood())
|
||||
reader.reset();
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
||||
bool IsWbfsBlob(const std::string& filename)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -17,7 +18,9 @@ namespace DiscIO
|
||||
class WbfsFileReader : public IBlobReader
|
||||
{
|
||||
public:
|
||||
static WbfsFileReader* Create(const std::string& filename);
|
||||
~WbfsFileReader();
|
||||
|
||||
static std::unique_ptr<WbfsFileReader> Create(const std::string& filename);
|
||||
|
||||
BlobType GetBlobType() const override { return BlobType::WBFS; }
|
||||
|
||||
@ -31,7 +34,6 @@ public:
|
||||
|
||||
private:
|
||||
WbfsFileReader(const std::string& filename);
|
||||
~WbfsFileReader();
|
||||
|
||||
bool OpenFiles(const std::string& filename);
|
||||
bool ReadHeader();
|
||||
|
@ -105,14 +105,14 @@ CISOProperties::CISOProperties(const GameListItem& game_list_item, wxWindow* par
|
||||
, OpenGameListItem(game_list_item)
|
||||
{
|
||||
// Load ISO data
|
||||
OpenISO = DiscIO::CreateVolumeFromFilename(OpenGameListItem.GetFileName());
|
||||
m_open_iso = DiscIO::CreateVolumeFromFilename(OpenGameListItem.GetFileName());
|
||||
|
||||
game_id = OpenISO->GetUniqueID();
|
||||
game_id = m_open_iso->GetUniqueID();
|
||||
|
||||
// Load game INIs
|
||||
GameIniFileLocal = File::GetUserPath(D_GAMESETTINGS_IDX) + game_id + ".ini";
|
||||
GameIniDefault = SConfig::LoadDefaultGameIni(game_id, OpenISO->GetRevision());
|
||||
GameIniLocal = SConfig::LoadLocalGameIni(game_id, OpenISO->GetRevision());
|
||||
GameIniDefault = SConfig::LoadDefaultGameIni(game_id, m_open_iso->GetRevision());
|
||||
GameIniLocal = SConfig::LoadLocalGameIni(game_id, m_open_iso->GetRevision());
|
||||
|
||||
// Setup GUI
|
||||
bRefreshList = false;
|
||||
@ -123,9 +123,9 @@ CISOProperties::CISOProperties(const GameListItem& game_list_item, wxWindow* par
|
||||
|
||||
// Disk header and apploader
|
||||
|
||||
m_InternalName->SetValue(StrToWxStr(OpenISO->GetInternalName()));
|
||||
m_GameID->SetValue(StrToWxStr(OpenISO->GetUniqueID()));
|
||||
switch (OpenISO->GetCountry())
|
||||
m_InternalName->SetValue(StrToWxStr(m_open_iso->GetInternalName()));
|
||||
m_GameID->SetValue(StrToWxStr(m_open_iso->GetUniqueID()));
|
||||
switch (m_open_iso->GetCountry())
|
||||
{
|
||||
case DiscIO::IVolume::COUNTRY_AUSTRALIA:
|
||||
m_Country->SetValue(_("Australia"));
|
||||
@ -172,14 +172,14 @@ CISOProperties::CISOProperties(const GameListItem& game_list_item, wxWindow* par
|
||||
break;
|
||||
}
|
||||
|
||||
wxString temp = "0x" + StrToWxStr(OpenISO->GetMakerID());
|
||||
wxString temp = "0x" + StrToWxStr(m_open_iso->GetMakerID());
|
||||
m_MakerID->SetValue(temp);
|
||||
m_Revision->SetValue(StrToWxStr(std::to_string(OpenISO->GetRevision())));
|
||||
m_Date->SetValue(StrToWxStr(OpenISO->GetApploaderDate()));
|
||||
m_FST->SetValue(StrToWxStr(std::to_string(OpenISO->GetFSTSize())));
|
||||
m_Revision->SetValue(StrToWxStr(std::to_string(m_open_iso->GetRevision())));
|
||||
m_Date->SetValue(StrToWxStr(m_open_iso->GetApploaderDate()));
|
||||
m_FST->SetValue(StrToWxStr(std::to_string(m_open_iso->GetFSTSize())));
|
||||
|
||||
// Here we set all the info to be shown + we set the window title
|
||||
bool wii = OpenISO->GetVolumeType() != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
bool wii = m_open_iso->GetVolumeType() != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
ChangeBannerDetails(SConfig::GetInstance().GetCurrentLanguage(wii));
|
||||
|
||||
m_Banner->SetBitmap(OpenGameListItem.GetBitmap());
|
||||
@ -187,9 +187,9 @@ CISOProperties::CISOProperties(const GameListItem& game_list_item, wxWindow* par
|
||||
|
||||
// Filesystem browser/dumper
|
||||
// TODO : Should we add a way to browse the wad file ?
|
||||
if (OpenISO->GetVolumeType() != DiscIO::IVolume::WII_WAD)
|
||||
if (m_open_iso->GetVolumeType() != DiscIO::IVolume::WII_WAD)
|
||||
{
|
||||
if (OpenISO->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
if (m_open_iso->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
{
|
||||
int partition_count = 0;
|
||||
for (int group = 0; group < 4; group++)
|
||||
@ -225,9 +225,9 @@ CISOProperties::CISOProperties(const GameListItem& game_list_item, wxWindow* par
|
||||
}
|
||||
else
|
||||
{
|
||||
pFileSystem = DiscIO::CreateFileSystem(OpenISO);
|
||||
if (pFileSystem)
|
||||
CreateDirectoryTree(RootId, pFileSystem->GetFileList());
|
||||
m_filesystem = DiscIO::CreateFileSystem(m_open_iso.get());
|
||||
if (m_filesystem)
|
||||
CreateDirectoryTree(RootId, m_filesystem->GetFileList());
|
||||
}
|
||||
|
||||
m_Treectrl->Expand(RootId);
|
||||
@ -236,9 +236,6 @@ CISOProperties::CISOProperties(const GameListItem& game_list_item, wxWindow* par
|
||||
|
||||
CISOProperties::~CISOProperties()
|
||||
{
|
||||
if (OpenISO->GetVolumeType() == DiscIO::IVolume::GAMECUBE_DISC && pFileSystem)
|
||||
delete pFileSystem;
|
||||
delete OpenISO;
|
||||
}
|
||||
|
||||
size_t CISOProperties::CreateDirectoryTree(wxTreeItemId& parent, const std::vector<DiscIO::SFileInfo>& fileInfos)
|
||||
@ -396,7 +393,7 @@ void CISOProperties::CreateGUIControls()
|
||||
sbCoreOverrides->Add(sGPUDeterminism, 0, wxEXPAND|wxALL, 5);
|
||||
|
||||
wxStaticBoxSizer * const sbWiiOverrides = new wxStaticBoxSizer(wxVERTICAL, m_GameConfig, _("Wii Console"));
|
||||
if (OpenISO->GetVolumeType() == DiscIO::IVolume::GAMECUBE_DISC)
|
||||
if (m_open_iso->GetVolumeType() == DiscIO::IVolume::GAMECUBE_DISC)
|
||||
{
|
||||
sbWiiOverrides->ShowItems(false);
|
||||
EnableWideScreen->Hide();
|
||||
@ -484,7 +481,7 @@ void CISOProperties::CreateGUIControls()
|
||||
|
||||
wxStaticText* const m_LangText = new wxStaticText(m_Information, wxID_ANY, _("Show Language:"));
|
||||
|
||||
bool wii = OpenISO->GetVolumeType() != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
bool wii = m_open_iso->GetVolumeType() != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
DiscIO::IVolume::ELanguage preferred_language = SConfig::GetInstance().GetCurrentLanguage(wii);
|
||||
|
||||
std::vector<DiscIO::IVolume::ELanguage> languages = OpenGameListItem.GetLanguages();
|
||||
@ -595,10 +592,10 @@ void CISOProperties::CreateGUIControls()
|
||||
sInfoPage->Add(sbBannerDetails, 0, wxEXPAND|wxALL, 5);
|
||||
m_Information->SetSizer(sInfoPage);
|
||||
|
||||
if (OpenISO->GetVolumeType() != DiscIO::IVolume::WII_WAD)
|
||||
if (m_open_iso->GetVolumeType() != DiscIO::IVolume::WII_WAD)
|
||||
{
|
||||
wxPanel* const m_Filesystem = new wxPanel(m_Notebook, ID_FILESYSTEM);
|
||||
m_Notebook->AddPage(m_Filesystem, _("Filesystem"));
|
||||
wxPanel* const filesystem_panel = new wxPanel(m_Notebook, ID_FILESYSTEM);
|
||||
m_Notebook->AddPage(filesystem_panel, _("Filesystem"));
|
||||
|
||||
// Filesystem icons
|
||||
wxImageList* const m_iconList = new wxImageList(16, 16);
|
||||
@ -607,13 +604,13 @@ void CISOProperties::CreateGUIControls()
|
||||
m_iconList->Add(wxBitmap(file_xpm), wxNullBitmap); // 2
|
||||
|
||||
// Filesystem tree
|
||||
m_Treectrl = new wxTreeCtrl(m_Filesystem, ID_TREECTRL);
|
||||
m_Treectrl = new wxTreeCtrl(filesystem_panel, ID_TREECTRL);
|
||||
m_Treectrl->AssignImageList(m_iconList);
|
||||
RootId = m_Treectrl->AddRoot(_("Disc"), 0, 0, nullptr);
|
||||
|
||||
wxBoxSizer* sTreePage = new wxBoxSizer(wxVERTICAL);
|
||||
sTreePage->Add(m_Treectrl, 1, wxEXPAND|wxALL, 5);
|
||||
m_Filesystem->SetSizer(sTreePage);
|
||||
filesystem_panel->SetSizer(sTreePage);
|
||||
}
|
||||
|
||||
wxSizer* sButtons = CreateButtonSizer(wxNO_DEFAULT);
|
||||
@ -623,7 +620,7 @@ void CISOProperties::CreateGUIControls()
|
||||
|
||||
// If there is no default gameini, disable the button.
|
||||
bool game_ini_exists = false;
|
||||
for (const std::string& ini_filename : SConfig::GetGameIniFilenames(game_id, OpenISO->GetRevision()))
|
||||
for (const std::string& ini_filename : SConfig::GetGameIniFilenames(game_id, m_open_iso->GetRevision()))
|
||||
{
|
||||
if (File::Exists(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + ini_filename))
|
||||
{
|
||||
@ -703,7 +700,7 @@ void CISOProperties::OnRightClickOnTree(wxTreeEvent& event)
|
||||
|
||||
popupMenu.Append(IDM_EXTRACTALL, _("Extract All Files..."));
|
||||
|
||||
if (OpenISO->GetVolumeType() != DiscIO::IVolume::WII_DISC ||
|
||||
if (m_open_iso->GetVolumeType() != DiscIO::IVolume::WII_DISC ||
|
||||
(m_Treectrl->GetItemImage(m_Treectrl->GetSelection()) == 0 &&
|
||||
m_Treectrl->GetFirstVisibleItem() != m_Treectrl->GetSelection()))
|
||||
{
|
||||
@ -746,7 +743,7 @@ void CISOProperties::OnExtractFile(wxCommandEvent& WXUNUSED (event))
|
||||
m_Treectrl->SelectItem(m_Treectrl->GetItemParent(m_Treectrl->GetSelection()));
|
||||
}
|
||||
|
||||
if (OpenISO->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
if (m_open_iso->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
{
|
||||
const wxTreeItemId tree_selection = m_Treectrl->GetSelection();
|
||||
WiiPartition* partition = reinterpret_cast<WiiPartition*>(m_Treectrl->GetItemData(tree_selection));
|
||||
@ -756,13 +753,13 @@ void CISOProperties::OnExtractFile(wxCommandEvent& WXUNUSED (event))
|
||||
}
|
||||
else
|
||||
{
|
||||
pFileSystem->ExportFile(WxStrToStr(File), WxStrToStr(Path));
|
||||
m_filesystem->ExportFile(WxStrToStr(File), WxStrToStr(Path));
|
||||
}
|
||||
}
|
||||
|
||||
void CISOProperties::ExportDir(const std::string& _rFullPath, const std::string& _rExportFolder, const WiiPartition* partition)
|
||||
{
|
||||
DiscIO::IFileSystem* const fs = OpenISO->GetVolumeType() == DiscIO::IVolume::WII_DISC ? partition->FileSystem.get() : pFileSystem;
|
||||
DiscIO::IFileSystem* const fs = m_open_iso->GetVolumeType() == DiscIO::IVolume::WII_DISC ? partition->FileSystem.get() : m_filesystem.get();
|
||||
|
||||
const std::vector<DiscIO::SFileInfo>& fst = fs->GetFileList();
|
||||
|
||||
@ -776,7 +773,7 @@ void CISOProperties::ExportDir(const std::string& _rFullPath, const std::string&
|
||||
size = (u32)fst.size();
|
||||
|
||||
fs->ExportApploader(_rExportFolder);
|
||||
if (OpenISO->GetVolumeType() != DiscIO::IVolume::WII_DISC)
|
||||
if (m_open_iso->GetVolumeType() != DiscIO::IVolume::WII_DISC)
|
||||
fs->ExportDOL(_rExportFolder);
|
||||
}
|
||||
else
|
||||
@ -861,7 +858,7 @@ void CISOProperties::OnExtractDir(wxCommandEvent& event)
|
||||
|
||||
if (event.GetId() == IDM_EXTRACTALL)
|
||||
{
|
||||
if (OpenISO->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
if (m_open_iso->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
{
|
||||
wxTreeItemIdValue cookie;
|
||||
wxTreeItemId root = m_Treectrl->GetRootItem();
|
||||
@ -890,7 +887,7 @@ void CISOProperties::OnExtractDir(wxCommandEvent& event)
|
||||
|
||||
Directory += DIR_SEP_CHR;
|
||||
|
||||
if (OpenISO->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
if (m_open_iso->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
{
|
||||
const wxTreeItemId tree_selection = m_Treectrl->GetSelection();
|
||||
WiiPartition* partition = reinterpret_cast<WiiPartition*>(m_Treectrl->GetItemData(tree_selection));
|
||||
@ -912,14 +909,14 @@ void CISOProperties::OnExtractDataFromHeader(wxCommandEvent& event)
|
||||
if (Path.empty())
|
||||
return;
|
||||
|
||||
if (OpenISO->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
if (m_open_iso->GetVolumeType() == DiscIO::IVolume::WII_DISC)
|
||||
{
|
||||
WiiPartition* partition = reinterpret_cast<WiiPartition*>(m_Treectrl->GetItemData(m_Treectrl->GetSelection()));
|
||||
FS = partition->FileSystem.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
FS = pFileSystem;
|
||||
FS = m_filesystem.get();
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
@ -958,7 +955,7 @@ void CISOProperties::CheckPartitionIntegrity(wxCommandEvent& event)
|
||||
{
|
||||
// Normally we can't enter this function if we aren't analyzing a Wii disc
|
||||
// anyway, but let's still check to be sure.
|
||||
if (OpenISO->GetVolumeType() != DiscIO::IVolume::WII_DISC)
|
||||
if (m_open_iso->GetVolumeType() != DiscIO::IVolume::WII_DISC)
|
||||
return;
|
||||
|
||||
wxProgressDialog dialog(_("Checking integrity..."), _("Working..."), 1000, this,
|
||||
@ -1082,7 +1079,7 @@ void CISOProperties::LoadGameConfig()
|
||||
|
||||
PatchList_Load();
|
||||
ActionReplayList_Load();
|
||||
m_geckocode_panel->LoadCodes(GameIniDefault, GameIniLocal, OpenISO->GetUniqueID());
|
||||
m_geckocode_panel->LoadCodes(GameIniDefault, GameIniLocal, m_open_iso->GetUniqueID());
|
||||
}
|
||||
|
||||
void CISOProperties::SaveGameIniValueFrom3StateCheckbox(const char* section, const char* key, wxCheckBox* checkbox)
|
||||
@ -1279,7 +1276,7 @@ void CISOProperties::OnComputeMD5Sum(wxCommandEvent& WXUNUSED (event))
|
||||
// they will all be opened, but there is usually only one
|
||||
void CISOProperties::OnShowDefaultConfig(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
for (const std::string& filename : SConfig::GetGameIniFilenames(game_id, OpenISO->GetRevision()))
|
||||
for (const std::string& filename : SConfig::GetGameIniFilenames(game_id, m_open_iso->GetRevision()))
|
||||
{
|
||||
std::string path = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename;
|
||||
if (File::Exists(path))
|
||||
|
@ -80,8 +80,8 @@ public:
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
DiscIO::IVolume *OpenISO;
|
||||
DiscIO::IFileSystem *pFileSystem;
|
||||
std::unique_ptr<DiscIO::IVolume> m_open_iso;
|
||||
std::unique_ptr<DiscIO::IFileSystem> m_filesystem;
|
||||
|
||||
std::vector<PatchEngine::Patch> onFrame;
|
||||
std::vector<ActionReplay::ARCode> arCodes;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <jni.h>
|
||||
#include <memory>
|
||||
#include <android/log.h>
|
||||
#include <android/native_window_jni.h>
|
||||
#include <EGL/egl.h>
|
||||
@ -261,11 +262,11 @@ static std::string GetDescription(std::string filename)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Description for file: %s", filename.c_str());
|
||||
|
||||
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
|
||||
std::unique_ptr<DiscIO::IVolume> volume(DiscIO::CreateVolumeFromFilename(filename));
|
||||
|
||||
if (pVolume != nullptr)
|
||||
if (volume != nullptr)
|
||||
{
|
||||
std::map <DiscIO::IVolume::ELanguage, std::string> descriptions = pVolume->GetDescriptions();
|
||||
std::map<DiscIO::IVolume::ELanguage, std::string> descriptions = volume->GetDescriptions();
|
||||
|
||||
/*
|
||||
bool is_wii_title = pVolume->GetVolumeType() != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
@ -289,53 +290,44 @@ static std::string GetDescription(std::string filename)
|
||||
return descriptions.cbegin()->second;
|
||||
}
|
||||
|
||||
return std::string ("");
|
||||
return std::string();
|
||||
}
|
||||
|
||||
static std::string GetGameId(std::string filename)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting ID for file: %s", filename.c_str());
|
||||
|
||||
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
|
||||
if (pVolume != nullptr)
|
||||
{
|
||||
std::string id = pVolume->GetUniqueID();
|
||||
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Game ID: %s", id.c_str());
|
||||
std::unique_ptr<DiscIO::IVolume> volume(DiscIO::CreateVolumeFromFilename(filename));
|
||||
if (volume == nullptr)
|
||||
return std::string();
|
||||
|
||||
return id;
|
||||
}
|
||||
return std::string ("");
|
||||
std::string id = volume->GetUniqueID();
|
||||
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Game ID: %s", id.c_str());
|
||||
return id;
|
||||
}
|
||||
|
||||
static std::string GetCompany(std::string filename)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Company for file: %s", filename.c_str());
|
||||
|
||||
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
|
||||
if (pVolume != nullptr)
|
||||
{
|
||||
std::string company = DiscIO::GetCompanyFromID(pVolume->GetMakerID());
|
||||
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Company: %s", company.c_str());
|
||||
return company;
|
||||
}
|
||||
return std::string ("");
|
||||
std::unique_ptr<DiscIO::IVolume> volume(DiscIO::CreateVolumeFromFilename(filename));
|
||||
if (volume == nullptr)
|
||||
return std::string();
|
||||
|
||||
std::string company = DiscIO::GetCompanyFromID(volume->GetMakerID());
|
||||
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Company: %s", company.c_str());
|
||||
return company;
|
||||
}
|
||||
|
||||
static u64 GetFileSize(std::string filename)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting size of file: %s", filename.c_str());
|
||||
|
||||
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
|
||||
if (pVolume != nullptr)
|
||||
{
|
||||
u64 size = pVolume->GetSize();
|
||||
// Causes a warning because size is u64, not 'long unsigned'
|
||||
//__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Size: %lu", size);
|
||||
std::unique_ptr<DiscIO::IVolume> volume(DiscIO::CreateVolumeFromFilename(filename));
|
||||
if (volume == nullptr)
|
||||
return -1;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return volume->GetSize();
|
||||
}
|
||||
|
||||
static std::string GetJString(JNIEnv *env, jstring jstr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user