Merge pull request #13540 from tygyh/DiscIO-Remove-redundant-qualifiers

DiscIO: Remove redundant qualifiers
This commit is contained in:
Jordan Woyak 2025-04-22 20:00:03 -05:00 committed by GitHub
commit 31a3de819d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 45 additions and 53 deletions

View file

@ -354,7 +354,7 @@ std::unique_ptr<DirectoryBlobReader> DirectoryBlobReader::Create(const std::stri
} }
std::unique_ptr<DirectoryBlobReader> DirectoryBlobReader::Create( std::unique_ptr<DirectoryBlobReader> DirectoryBlobReader::Create(
std::unique_ptr<DiscIO::VolumeDisc> volume, std::unique_ptr<VolumeDisc> volume,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback, const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>& const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>&
fst_callback) fst_callback)
@ -414,7 +414,7 @@ DirectoryBlobReader::DirectoryBlobReader(const std::string& game_partition_root,
} }
DirectoryBlobReader::DirectoryBlobReader( DirectoryBlobReader::DirectoryBlobReader(
std::unique_ptr<DiscIO::VolumeDisc> volume, std::unique_ptr<VolumeDisc> volume,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback, const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>& const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>&
fst_callback) fst_callback)
@ -699,7 +699,7 @@ void DirectoryBlobReader::SetPartitionHeader(DirectoryBlobPartition* partition,
constexpr u32 TMD_OFFSET = 0x2c0; constexpr u32 TMD_OFFSET = 0x2c0;
constexpr u32 H3_OFFSET = 0x4000; constexpr u32 H3_OFFSET = 0x4000;
const std::optional<DiscIO::Partition>& wrapped_partition = partition->GetWrappedPartition(); const std::optional<Partition>& wrapped_partition = partition->GetWrappedPartition();
const std::string& partition_root = partition->GetRootDirectory(); const std::string& partition_root = partition->GetRootDirectory();
u64 ticket_size; u64 ticket_size;
@ -797,8 +797,7 @@ void DirectoryBlobReader::SetPartitionHeader(DirectoryBlobPartition* partition,
partition->SetKey(ticket.GetTitleKey()); partition->SetKey(ticket.GetTitleKey());
} }
static void GenerateBuilderNodesFromFileSystem(const DiscIO::VolumeDisc& volume, static void GenerateBuilderNodesFromFileSystem(const VolumeDisc& volume, const Partition& partition,
const DiscIO::Partition& partition,
std::vector<FSTBuilderNode>* nodes, std::vector<FSTBuilderNode>* nodes,
const FileInfo& parent_info) const FileInfo& parent_info)
{ {
@ -875,7 +874,7 @@ static std::vector<u8> ExtractNodeToVector(std::vector<FSTBuilderNode>* nodes, v
} }
DirectoryBlobPartition::DirectoryBlobPartition( DirectoryBlobPartition::DirectoryBlobPartition(
DiscIO::VolumeDisc* volume, const DiscIO::Partition& partition, std::optional<bool> is_wii, VolumeDisc* volume, const Partition& partition, std::optional<bool> is_wii,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback, const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>& const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>&
fst_callback, fst_callback,

View file

@ -180,7 +180,7 @@ public:
DirectoryBlobPartition() = default; DirectoryBlobPartition() = default;
DirectoryBlobPartition(const std::string& root_directory, std::optional<bool> is_wii); DirectoryBlobPartition(const std::string& root_directory, std::optional<bool> is_wii);
DirectoryBlobPartition( DirectoryBlobPartition(
DiscIO::VolumeDisc* volume, const DiscIO::Partition& partition, std::optional<bool> is_wii, VolumeDisc* volume, const Partition& partition, std::optional<bool> is_wii,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback, const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>& const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>&
fst_callback, fst_callback,
@ -196,10 +196,7 @@ public:
void SetDataSize(u64 size) { m_data_size = size; } void SetDataSize(u64 size) { m_data_size = size; }
const std::string& GetRootDirectory() const { return m_root_directory; } const std::string& GetRootDirectory() const { return m_root_directory; }
const DiscContentContainer& GetContents() const { return m_contents; } const DiscContentContainer& GetContents() const { return m_contents; }
const std::optional<DiscIO::Partition>& GetWrappedPartition() const const std::optional<Partition>& GetWrappedPartition() const { return m_wrapped_partition; }
{
return m_wrapped_partition;
}
const std::array<u8, VolumeWii::AES_KEY_SIZE>& GetKey() const { return m_key; } const std::array<u8, VolumeWii::AES_KEY_SIZE>& GetKey() const { return m_key; }
void SetKey(std::array<u8, VolumeWii::AES_KEY_SIZE> key) { m_key = key; } void SetKey(std::array<u8, VolumeWii::AES_KEY_SIZE> key) { m_key = key; }
@ -241,7 +238,7 @@ private:
u64 m_data_size = 0; u64 m_data_size = 0;
std::optional<DiscIO::Partition> m_wrapped_partition = std::nullopt; std::optional<Partition> m_wrapped_partition = std::nullopt;
}; };
class DirectoryBlobReader final : public BlobReader class DirectoryBlobReader final : public BlobReader
@ -251,7 +248,7 @@ class DirectoryBlobReader final : public BlobReader
public: public:
static std::unique_ptr<DirectoryBlobReader> Create(const std::string& dol_path); static std::unique_ptr<DirectoryBlobReader> Create(const std::string& dol_path);
static std::unique_ptr<DirectoryBlobReader> Create( static std::unique_ptr<DirectoryBlobReader> Create(
std::unique_ptr<DiscIO::VolumeDisc> volume, std::unique_ptr<VolumeDisc> volume,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback, const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>& const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>&
fst_callback); fst_callback);
@ -290,7 +287,7 @@ private:
explicit DirectoryBlobReader(const std::string& game_partition_root, explicit DirectoryBlobReader(const std::string& game_partition_root,
const std::string& true_root); const std::string& true_root);
explicit DirectoryBlobReader( explicit DirectoryBlobReader(
std::unique_ptr<DiscIO::VolumeDisc> volume, std::unique_ptr<VolumeDisc> volume,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback, const std::function<void(std::vector<FSTBuilderNode>* fst_nodes)>& sys_callback,
const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>& const std::function<void(std::vector<FSTBuilderNode>* fst_nodes, FSTBuilderNode* dol_node)>&
fst_callback); fst_callback);
@ -310,7 +307,7 @@ private:
void SetPartitions(std::vector<PartitionWithType>&& partitions); void SetPartitions(std::vector<PartitionWithType>&& partitions);
void SetPartitionHeader(DirectoryBlobPartition* partition, u64 partition_address); void SetPartitionHeader(DirectoryBlobPartition* partition, u64 partition_address);
DiscIO::VolumeDisc* GetWrappedVolume() { return m_wrapped_volume.get(); } VolumeDisc* GetWrappedVolume() { return m_wrapped_volume.get(); }
// For GameCube: // For GameCube:
DirectoryBlobPartition m_gamecube_pseudopartition; DirectoryBlobPartition m_gamecube_pseudopartition;
@ -325,7 +322,7 @@ private:
u64 m_data_size; u64 m_data_size;
std::unique_ptr<DiscIO::VolumeDisc> m_wrapped_volume; std::unique_ptr<VolumeDisc> m_wrapped_volume;
}; };
} // namespace DiscIO } // namespace DiscIO

View file

@ -125,7 +125,7 @@ bool DiscScrubber::ParseDisc(const Volume& disc)
// Mark the header as used - it's mostly 0s anyways // Mark the header as used - it's mostly 0s anyways
MarkAsUsed(0, 0x50000); MarkAsUsed(0, 0x50000);
for (const DiscIO::Partition& partition : disc.GetPartitions()) for (const Partition& partition : disc.GetPartitions())
{ {
u32 tmd_size; u32 tmd_size;
u64 tmd_offset; u64 tmd_offset;
@ -222,7 +222,7 @@ bool DiscScrubber::ParsePartitionData(const Volume& disc, const Partition& parti
void DiscScrubber::ParseFileSystemData(u64 partition_data_offset, const FileInfo& directory) void DiscScrubber::ParseFileSystemData(u64 partition_data_offset, const FileInfo& directory)
{ {
for (const DiscIO::FileInfo& file_info : directory) for (const FileInfo& file_info : directory)
{ {
DEBUG_LOG_FMT(DISCIO, "Scrubbing {}", file_info.GetPath()); DEBUG_LOG_FMT(DISCIO, "Scrubbing {}", file_info.GetPath());
if (file_info.IsDirectory()) if (file_info.IsDirectory())

View file

@ -207,23 +207,23 @@ bool IsGCZBlockSizeLegacyCompatible(int block_size, u64 file_size)
return file_size % block_size == 0 && file_size % (block_size * 32) != 0; return file_size % block_size == 0 && file_size % (block_size * 32) != 0;
} }
bool IsDiscImageBlockSizeValid(int block_size, DiscIO::BlobType format) bool IsDiscImageBlockSizeValid(int block_size, BlobType format)
{ {
switch (format) switch (format)
{ {
case DiscIO::BlobType::GCZ: case BlobType::GCZ:
// Block size "must" be a power of 2 // Block size "must" be a power of 2
if (!MathUtil::IsPow2(block_size)) if (!MathUtil::IsPow2(block_size))
return false; return false;
break; break;
case DiscIO::BlobType::WIA: case BlobType::WIA:
// Block size must not be less than the minimum, and must be a multiple of it // Block size must not be less than the minimum, and must be a multiple of it
if (block_size < WIA_MIN_BLOCK_SIZE || block_size % WIA_MIN_BLOCK_SIZE != 0) if (block_size < WIA_MIN_BLOCK_SIZE || block_size % WIA_MIN_BLOCK_SIZE != 0)
return false; return false;
break; break;
case DiscIO::BlobType::RVZ: case BlobType::RVZ:
// Block size must not be smaller than the minimum // Block size must not be smaller than the minimum
// Block sizes smaller than the large block size threshold must be a power of 2 // Block sizes smaller than the large block size threshold must be a power of 2
// Block sizes larger than that threshold must be a multiple of the threshold // Block sizes larger than that threshold must be a multiple of the threshold

View file

@ -87,5 +87,5 @@ u64 GetBiggestReferencedOffset(const Volume& volume);
u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector<Partition>& partitions); u64 GetBiggestReferencedOffset(const Volume& volume, const std::vector<Partition>& partitions);
bool IsGCZBlockSizeLegacyCompatible(int block_size, u64 file_size); bool IsGCZBlockSizeLegacyCompatible(int block_size, u64 file_size);
bool IsDiscImageBlockSizeValid(int block_size, DiscIO::BlobType format); bool IsDiscImageBlockSizeValid(int block_size, BlobType format);
} // namespace DiscIO } // namespace DiscIO

View file

@ -117,16 +117,16 @@ std::string GetName(Region region, bool translate)
switch (region) switch (region)
{ {
case DiscIO::Region::NTSC_J: case Region::NTSC_J:
name = _trans("NTSC-J"); name = _trans("NTSC-J");
break; break;
case DiscIO::Region::NTSC_U: case Region::NTSC_U:
name = _trans("NTSC-U"); name = _trans("NTSC-U");
break; break;
case DiscIO::Region::PAL: case Region::PAL:
name = _trans("PAL"); name = _trans("PAL");
break; break;
case DiscIO::Region::NTSC_K: case Region::NTSC_K:
name = _trans("NTSC-K"); name = _trans("NTSC-K");
break; break;
default: default:

View file

@ -23,7 +23,7 @@ static std::string MakeAbsolute(const std::string& directory, const std::string&
std::optional<GameModDescriptor> ParseGameModDescriptorFile(const std::string& filename) std::optional<GameModDescriptor> ParseGameModDescriptorFile(const std::string& filename)
{ {
::File::IOFile f(filename, "rb"); File::IOFile f(filename, "rb");
if (!f) if (!f)
return std::nullopt; return std::nullopt;
@ -212,7 +212,7 @@ bool WriteGameModDescriptorFile(const std::string& filename, const GameModDescri
if (json.empty()) if (json.empty())
return false; return false;
::File::IOFile f(filename, "wb"); File::IOFile f(filename, "wb");
if (!f) if (!f)
return false; return false;

View file

@ -255,7 +255,7 @@ static void SplitAt(BuilderContentSource* before, BuilderContentSource* after, u
} }
} }
static void ApplyPatchToFile(const Patch& patch, DiscIO::FSTBuilderNode* file_node, static void ApplyPatchToFile(const Patch& patch, FSTBuilderNode* file_node,
std::string_view external_filename, u64 file_patch_offset, std::string_view external_filename, u64 file_patch_offset,
u64 raw_external_file_offset, u64 file_patch_length, bool resize) u64 raw_external_file_offset, u64 file_patch_length, bool resize)
{ {
@ -352,8 +352,7 @@ static void ApplyPatchToFile(const Patch& patch, DiscIO::FSTBuilderNode* file_no
content.pop_back(); content.pop_back();
} }
static void ApplyPatchToFile(const Patch& patch, const File& file_patch, static void ApplyPatchToFile(const Patch& patch, const File& file_patch, FSTBuilderNode* file_node)
DiscIO::FSTBuilderNode* file_node)
{ {
// The last two bits of the offset seem to be ignored by actual Riivolution. // The last two bits of the offset seem to be ignored by actual Riivolution.
ApplyPatchToFile(patch, file_node, file_patch.m_external, file_patch.m_offset & ~u64(3), ApplyPatchToFile(patch, file_node, file_patch.m_external, file_patch.m_offset & ~u64(3),
@ -378,11 +377,11 @@ static FSTBuilderNode* FindFileNodeInFST(std::string_view path, std::vector<FSTB
if (is_file) if (is_file)
{ {
return &fst->emplace_back( return &fst->emplace_back(
DiscIO::FSTBuilderNode{std::string(name), 0, std::vector<BuilderContentSource>()}); FSTBuilderNode{std::string(name), 0, std::vector<BuilderContentSource>()});
} }
auto& new_folder = fst->emplace_back( auto& new_folder =
DiscIO::FSTBuilderNode{std::string(name), 0, std::vector<FSTBuilderNode>()}); fst->emplace_back(FSTBuilderNode{std::string(name), 0, std::vector<FSTBuilderNode>()});
return FindFileNodeInFST(path.substr(path_separator + 1), return FindFileNodeInFST(path.substr(path_separator + 1),
&std::get<std::vector<FSTBuilderNode>>(new_folder.m_content), true); &std::get<std::vector<FSTBuilderNode>>(new_folder.m_content), true);
} }
@ -398,14 +397,14 @@ static FSTBuilderNode* FindFileNodeInFST(std::string_view path, std::vector<FSTB
create_if_not_exists); create_if_not_exists);
} }
static DiscIO::FSTBuilderNode* FindFilenameNodeInFST(std::string_view filename, static FSTBuilderNode* FindFilenameNodeInFST(std::string_view filename,
std::vector<FSTBuilderNode>& fst) std::vector<FSTBuilderNode>& fst)
{ {
for (FSTBuilderNode& node : fst) for (FSTBuilderNode& node : fst)
{ {
if (node.IsFolder()) if (node.IsFolder())
{ {
DiscIO::FSTBuilderNode* result = FindFilenameNodeInFST(filename, node.GetFolderContent()); FSTBuilderNode* result = FindFilenameNodeInFST(filename, node.GetFolderContent());
if (result) if (result)
return result; return result;
} }
@ -419,13 +418,12 @@ static DiscIO::FSTBuilderNode* FindFilenameNodeInFST(std::string_view filename,
} }
static void ApplyFilePatchToFST(const Patch& patch, const File& file, static void ApplyFilePatchToFST(const Patch& patch, const File& file,
std::vector<DiscIO::FSTBuilderNode>* fst, std::vector<FSTBuilderNode>* fst, FSTBuilderNode* dol_node)
DiscIO::FSTBuilderNode* dol_node)
{ {
if (!file.m_disc.empty() && file.m_disc[0] == '/') if (!file.m_disc.empty() && file.m_disc[0] == '/')
{ {
// If the disc path starts with a / then we should patch that specific disc path. // If the disc path starts with a / then we should patch that specific disc path.
DiscIO::FSTBuilderNode* node = FSTBuilderNode* node =
FindFileNodeInFST(std::string_view(file.m_disc).substr(1), fst, file.m_create); FindFileNodeInFST(std::string_view(file.m_disc).substr(1), fst, file.m_create);
if (node) if (node)
ApplyPatchToFile(patch, file, node); ApplyPatchToFile(patch, file, node);
@ -438,16 +436,15 @@ static void ApplyFilePatchToFST(const Patch& patch, const File& file,
else else
{ {
// Otherwise we want to patch the first file in the FST that matches that filename. // Otherwise we want to patch the first file in the FST that matches that filename.
DiscIO::FSTBuilderNode* node = FindFilenameNodeInFST(file.m_disc, *fst); FSTBuilderNode* node = FindFilenameNodeInFST(file.m_disc, *fst);
if (node) if (node)
ApplyPatchToFile(patch, file, node); ApplyPatchToFile(patch, file, node);
} }
} }
static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder, static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder,
std::vector<DiscIO::FSTBuilderNode>* fst, std::vector<FSTBuilderNode>* fst, FSTBuilderNode* dol_node,
DiscIO::FSTBuilderNode* dol_node, std::string_view disc_path, std::string_view disc_path, std::string_view external_path)
std::string_view external_path)
{ {
const auto external_files = patch.m_file_data_loader->GetFolderContents(external_path); const auto external_files = patch.m_file_data_loader->GetFolderContents(external_path);
for (const auto& child : external_files) for (const auto& child : external_files)
@ -485,8 +482,7 @@ static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder,
} }
static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder, static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder,
std::vector<DiscIO::FSTBuilderNode>* fst, std::vector<FSTBuilderNode>* fst, FSTBuilderNode* dol_node)
DiscIO::FSTBuilderNode* dol_node)
{ {
ApplyFolderPatchToFST(patch, folder, fst, dol_node, folder.m_disc, folder.m_external); ApplyFolderPatchToFST(patch, folder, fst, dol_node, folder.m_disc, folder.m_external);
} }

View file

@ -65,7 +65,7 @@ void RedumpVerifier::Start(const Volume& volume)
m_disc_number = volume.GetDiscNumber().value_or(0); m_disc_number = volume.GetDiscNumber().value_or(0);
m_size = volume.GetDataSize(); m_size = volume.GetDataSize();
const DiscIO::Platform platform = volume.GetVolumeType(); const Platform platform = volume.GetVolumeType();
m_future = std::async(std::launch::async, [this, platform]() -> std::vector<PotentialMatch> { m_future = std::async(std::launch::async, [this, platform]() -> std::vector<PotentialMatch> {
std::string system; std::string system;
@ -625,7 +625,7 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
if (blank_contents) if (blank_contents)
return false; return false;
const DiscIO::FileSystem* filesystem = m_volume.GetFileSystem(partition); const FileSystem* filesystem = m_volume.GetFileSystem(partition);
if (!filesystem) if (!filesystem)
{ {
if (m_is_datel) if (m_is_datel)
@ -756,7 +756,7 @@ void VolumeVerifier::CheckVolumeSize()
u64 volume_size = m_volume.GetDataSize(); u64 volume_size = m_volume.GetDataSize();
const bool is_disc = IsDisc(m_volume.GetVolumeType()); const bool is_disc = IsDisc(m_volume.GetVolumeType());
const bool should_be_dual_layer = is_disc && ShouldBeDualLayer(); const bool should_be_dual_layer = is_disc && ShouldBeDualLayer();
bool volume_size_roughly_known = m_data_size_type != DiscIO::DataSizeType::UpperBound; bool volume_size_roughly_known = m_data_size_type != DataSizeType::UpperBound;
if (should_be_dual_layer && m_biggest_referenced_offset <= SL_DVD_R_SIZE) if (should_be_dual_layer && m_biggest_referenced_offset <= SL_DVD_R_SIZE)
{ {
@ -767,7 +767,7 @@ void VolumeVerifier::CheckVolumeSize()
"This problem generally only exists in illegal copies of games.")); "This problem generally only exists in illegal copies of games."));
} }
if (m_data_size_type != DiscIO::DataSizeType::Accurate) if (m_data_size_type != DataSizeType::Accurate)
{ {
AddProblem(Severity::Low, AddProblem(Severity::Low,
Common::GetStringT("The format that the disc image is saved in does not " Common::GetStringT("The format that the disc image is saved in does not "
@ -800,7 +800,7 @@ void VolumeVerifier::CheckVolumeSize()
// The reason why this condition is checking for m_data_size_type != UpperBound instead of // The reason why this condition is checking for m_data_size_type != UpperBound instead of
// m_data_size_type == Accurate is because we want to show the warning about input recordings and // m_data_size_type == Accurate is because we want to show the warning about input recordings and
// NetPlay for NFS disc images (which are the only disc images that have it set to LowerBound). // NetPlay for NFS disc images (which are the only disc images that have it set to LowerBound).
if (is_disc && m_data_size_type != DiscIO::DataSizeType::UpperBound && !m_is_tgc) if (is_disc && m_data_size_type != DataSizeType::UpperBound && !m_is_tgc)
{ {
const Platform platform = m_volume.GetVolumeType(); const Platform platform = m_volume.GetVolumeType();
const bool should_be_gc_size = platform == Platform::GameCubeDisc || m_is_datel; const bool should_be_gc_size = platform == Platform::GameCubeDisc || m_is_datel;
@ -1019,7 +1019,7 @@ void VolumeVerifier::CheckSuperPaperMario()
// bytes are zeroes like in good dumps, the game works correctly, but otherwise it can freeze // bytes are zeroes like in good dumps, the game works correctly, but otherwise it can freeze
// (depending on the exact values of the extra bytes). https://bugs.dolphin-emu.org/issues/11900 // (depending on the exact values of the extra bytes). https://bugs.dolphin-emu.org/issues/11900
const DiscIO::Partition partition = m_volume.GetGamePartition(); const Partition partition = m_volume.GetGamePartition();
const FileSystem* fs = m_volume.GetFileSystem(partition); const FileSystem* fs = m_volume.GetFileSystem(partition);
if (!fs) if (!fs)
return; return;