mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 22:09:19 -07:00
6ffcbcee70
This way, scrubbing can also be performed when converting to other formats.
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
// Copyright 2008 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
// DiscScrubber removes the pseudorandom padding data from discs
|
|
|
|
// Note: the technique is inspired by Wiiscrubber, but much simpler - intentionally :)
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
#include <vector>
|
|
#include "Common/CommonTypes.h"
|
|
|
|
namespace File
|
|
{
|
|
class IOFile;
|
|
}
|
|
|
|
namespace DiscIO
|
|
{
|
|
class FileInfo;
|
|
class Volume;
|
|
struct Partition;
|
|
|
|
class DiscScrubber final
|
|
{
|
|
public:
|
|
DiscScrubber();
|
|
~DiscScrubber();
|
|
|
|
bool SetupScrub(const Volume* disc);
|
|
|
|
// Returns true if the specified 32 KiB block only contains unused data
|
|
bool CanBlockBeScrubbed(u64 offset) const;
|
|
|
|
static constexpr size_t CLUSTER_SIZE = 0x8000;
|
|
|
|
private:
|
|
void MarkAsUsed(u64 offset, u64 size);
|
|
void MarkAsUsedE(u64 partition_data_offset, u64 offset, u64 size);
|
|
u64 ToClusterOffset(u64 offset) const;
|
|
bool ReadFromVolume(u64 offset, u32& buffer, const Partition& partition);
|
|
bool ReadFromVolume(u64 offset, u64& buffer, const Partition& partition);
|
|
bool ParseDisc();
|
|
bool ParsePartitionData(const Partition& partition);
|
|
void ParseFileSystemData(u64 partition_data_offset, const FileInfo& directory);
|
|
|
|
const Volume* m_disc;
|
|
|
|
std::vector<u8> m_free_table;
|
|
u64 m_file_size = 0;
|
|
bool m_is_scrubbing = false;
|
|
};
|
|
|
|
} // namespace DiscIO
|