mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
VolumeVerifier: Add datfile parsing
This commit is contained in:
@ -21,7 +21,7 @@
|
||||
|
||||
// To be used as follows:
|
||||
//
|
||||
// VolumeVerifier verifier(volume);
|
||||
// VolumeVerifier verifier(volume, redump_verification, hashes_to_calculate);
|
||||
// verifier.Start();
|
||||
// while (verifier.GetBytesProcessed() != verifier.GetTotalBytes())
|
||||
// verifier.Process();
|
||||
@ -36,6 +36,53 @@ namespace DiscIO
|
||||
{
|
||||
class FileInfo;
|
||||
|
||||
template <typename T>
|
||||
struct Hashes
|
||||
{
|
||||
T crc32;
|
||||
T md5;
|
||||
T sha1;
|
||||
};
|
||||
|
||||
class RedumpVerifier final
|
||||
{
|
||||
public:
|
||||
enum class Status
|
||||
{
|
||||
Unknown,
|
||||
GoodDump,
|
||||
BadDump,
|
||||
Error,
|
||||
};
|
||||
|
||||
struct Result
|
||||
{
|
||||
Status status = Status::Unknown;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
void Start(const Volume& volume);
|
||||
Result Finish(const Hashes<std::vector<u8>>& hashes);
|
||||
|
||||
private:
|
||||
struct PotentialMatch
|
||||
{
|
||||
u64 size;
|
||||
Hashes<std::vector<u8>> hashes;
|
||||
};
|
||||
|
||||
std::vector<PotentialMatch> ScanXML();
|
||||
|
||||
std::string m_dat_filename;
|
||||
std::string m_game_id;
|
||||
u16 m_revision;
|
||||
u8 m_disc_number;
|
||||
u64 m_size;
|
||||
|
||||
std::future<std::vector<PotentialMatch>> m_future;
|
||||
Result m_result;
|
||||
};
|
||||
|
||||
class VolumeVerifier final
|
||||
{
|
||||
public:
|
||||
@ -53,22 +100,15 @@ public:
|
||||
std::string text;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Hashes
|
||||
{
|
||||
T crc32;
|
||||
T md5;
|
||||
T sha1;
|
||||
};
|
||||
|
||||
struct Result
|
||||
{
|
||||
Hashes<std::vector<u8>> hashes;
|
||||
std::string summary_text;
|
||||
std::vector<Problem> problems;
|
||||
RedumpVerifier::Result redump;
|
||||
};
|
||||
|
||||
VolumeVerifier(const Volume& volume, Hashes<bool> hashes_to_calculate);
|
||||
VolumeVerifier(const Volume& volume, bool redump_verification, Hashes<bool> hashes_to_calculate);
|
||||
~VolumeVerifier();
|
||||
|
||||
void Start();
|
||||
@ -111,6 +151,9 @@ private:
|
||||
bool m_is_datel = false;
|
||||
bool m_is_not_retail = false;
|
||||
|
||||
bool m_redump_verification;
|
||||
RedumpVerifier m_redump_verifier;
|
||||
|
||||
Hashes<bool> m_hashes_to_calculate{};
|
||||
bool m_calculating_any_hash = false;
|
||||
unsigned long m_crc32_context = 0;
|
||||
|
Reference in New Issue
Block a user