diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2022-07-28 10:31:16 -0700 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2022-08-02 22:23:49 -0700 |
| commit | d71797154ab3db04c02363f1538c805d9aa95429 (patch) | |
| tree | 89a67e0875801530f8b8929faeef4a7f24fcada5 /Source/Core/DolphinTool/VerifyCommand.cpp | |
| parent | 7d2d5d914bf3cacbecbb0bf8a642b616744aad54 (diff) | |
VolumeVerifier: enable fast hash functions by default
sets defaults based on cpu support.
Diffstat (limited to 'Source/Core/DolphinTool/VerifyCommand.cpp')
| -rw-r--r-- | Source/Core/DolphinTool/VerifyCommand.cpp | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/Source/Core/DolphinTool/VerifyCommand.cpp b/Source/Core/DolphinTool/VerifyCommand.cpp index 6f2ff03b24..f046025c12 100644 --- a/Source/Core/DolphinTool/VerifyCommand.cpp +++ b/Source/Core/DolphinTool/VerifyCommand.cpp @@ -57,11 +57,22 @@ int VerifyCommand::Main(const std::vector<std::string>& args) algorithm = static_cast<const char*>(options.get("algorithm")); } - bool enable_crc32 = algorithm == std::nullopt || algorithm == "crc32"; - bool enable_md5 = algorithm == std::nullopt || algorithm == "md5"; - bool enable_sha1 = algorithm == std::nullopt || algorithm == "sha1"; + DiscIO::Hashes<bool> hashes_to_calculate{}; + if (algorithm == std::nullopt) + { + hashes_to_calculate = DiscIO::VolumeVerifier::GetDefaultHashesToCalculate(); + } + else + { + if (algorithm == "crc32") + hashes_to_calculate.crc32 = true; + else if (algorithm == "md5") + hashes_to_calculate.md5 = true; + else if (algorithm == "sha1") + hashes_to_calculate.sha1 = true; + } - if (!enable_crc32 && !enable_md5 && !enable_sha1) + if (!hashes_to_calculate.crc32 && !hashes_to_calculate.md5 && !hashes_to_calculate.sha1) { // optparse should protect from this std::cerr << "Error: No algorithms selected for the operation" << std::endl; @@ -78,7 +89,7 @@ int VerifyCommand::Main(const std::vector<std::string>& args) // Verify the volume const std::optional<DiscIO::VolumeVerifier::Result> result = - VerifyVolume(volume, enable_crc32, enable_md5, enable_sha1); + VerifyVolume(volume, hashes_to_calculate); if (!result) { std::cerr << "Error: Unable to verify volume" << std::endl; @@ -91,15 +102,15 @@ int VerifyCommand::Main(const std::vector<std::string>& args) } else { - if (enable_crc32 && !result->hashes.crc32.empty()) + if (hashes_to_calculate.crc32 && !result->hashes.crc32.empty()) std::cout << HashToHexString(result->hashes.crc32) << std::endl; - else if (enable_md5 && !result->hashes.md5.empty()) + else if (hashes_to_calculate.md5 && !result->hashes.md5.empty()) std::cout << HashToHexString(result->hashes.md5) << std::endl; - else if (enable_sha1 && !result->hashes.sha1.empty()) + else if (hashes_to_calculate.sha1 && !result->hashes.sha1.empty()) std::cout << HashToHexString(result->hashes.sha1) << std::endl; else { - std::cerr << "Error: No hash available" << std::endl; + std::cerr << "Error: No hash computed" << std::endl; return 1; } } @@ -112,17 +123,17 @@ void VerifyCommand::PrintFullReport(const std::optional<DiscIO::VolumeVerifier:: if (!result->hashes.crc32.empty()) std::cout << "CRC32: " << HashToHexString(result->hashes.crc32) << std::endl; else - std::cout << "CRC32 not available" << std::endl; + std::cout << "CRC32 not computed" << std::endl; if (!result->hashes.md5.empty()) std::cout << "MD5: " << HashToHexString(result->hashes.md5) << std::endl; else - std::cout << "MD5 not available" << std::endl; + std::cout << "MD5 not computed" << std::endl; if (!result->hashes.sha1.empty()) std::cout << "SHA1: " << HashToHexString(result->hashes.sha1) << std::endl; else - std::cout << "SHA1 not available" << std::endl; + std::cout << "SHA1 not computed" << std::endl; std::cout << "Problems Found: " << (result->problems.size() > 0 ? "Yes" : "No") << std::endl; @@ -156,13 +167,13 @@ void VerifyCommand::PrintFullReport(const std::optional<DiscIO::VolumeVerifier:: } std::optional<DiscIO::VolumeVerifier::Result> -VerifyCommand::VerifyVolume(std::shared_ptr<DiscIO::VolumeDisc> volume, bool enable_crc32, - bool enable_md5, bool enable_sha1) +VerifyCommand::VerifyVolume(std::shared_ptr<DiscIO::VolumeDisc> volume, + const DiscIO::Hashes<bool>& hashes_to_calculate) { if (!volume) return std::nullopt; - DiscIO::VolumeVerifier verifier(*volume, false, {enable_crc32, enable_md5, enable_sha1}); + DiscIO::VolumeVerifier verifier(*volume, false, hashes_to_calculate); verifier.Start(); while (verifier.GetBytesProcessed() != verifier.GetTotalBytes()) |
