From 25c020cbe2b0f5fa0b384c64839fc16745af133c Mon Sep 17 00:00:00 2001 From: get <45425365+Minty-Meeo@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:33:11 -0500 Subject: DolphinTool: Ditch OOP design --- Source/Core/DolphinTool/VerifyCommand.cpp | 125 ++++++++++++++++-------------- 1 file changed, 66 insertions(+), 59 deletions(-) (limited to 'Source/Core/DolphinTool/VerifyCommand.cpp') diff --git a/Source/Core/DolphinTool/VerifyCommand.cpp b/Source/Core/DolphinTool/VerifyCommand.cpp index 631ac229f4..c27c02c646 100644 --- a/Source/Core/DolphinTool/VerifyCommand.cpp +++ b/Source/Core/DolphinTool/VerifyCommand.cpp @@ -2,13 +2,77 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "DolphinTool/VerifyCommand.h" -#include "UICommon/UICommon.h" + +#include +#include #include +#include "Common/StringUtil.h" +#include "DiscIO/VolumeDisc.h" +#include "DiscIO/VolumeVerifier.h" +#include "UICommon/UICommon.h" + namespace DolphinTool { -int VerifyCommand::Main(const std::vector& args) +static std::string HashToHexString(const std::vector& hash) +{ + std::stringstream ss; + ss << std::hex; + for (int i = 0; i < static_cast(hash.size()); ++i) + { + ss << std::setw(2) << std::setfill('0') << static_cast(hash[i]); + } + return ss.str(); +} + +static void PrintFullReport(const DiscIO::VolumeVerifier::Result& result) +{ + if (!result.hashes.crc32.empty()) + std::cout << "CRC32: " << HashToHexString(result.hashes.crc32) << std::endl; + else + 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 computed" << std::endl; + + if (!result.hashes.sha1.empty()) + std::cout << "SHA1: " << HashToHexString(result.hashes.sha1) << std::endl; + else + std::cout << "SHA1 not computed" << std::endl; + + std::cout << "Problems Found: " << (result.problems.empty() ? "No" : "Yes") << std::endl; + + for (const auto& problem : result.problems) + { + std::cout << std::endl << "Severity: "; + switch (problem.severity) + { + case DiscIO::VolumeVerifier::Severity::Low: + std::cout << "Low"; + break; + case DiscIO::VolumeVerifier::Severity::Medium: + std::cout << "Medium"; + break; + case DiscIO::VolumeVerifier::Severity::High: + std::cout << "High"; + break; + case DiscIO::VolumeVerifier::Severity::None: + std::cout << "None"; + break; + default: + ASSERT(false); + break; + } + std::cout << std::endl; + + std::cout << "Summary: " << problem.text << std::endl << std::endl; + } +} + +int VerifyCommand(const std::vector& args) { optparse::OptionParser parser; @@ -115,61 +179,4 @@ int VerifyCommand::Main(const std::vector& args) return 0; } - -void VerifyCommand::PrintFullReport(const DiscIO::VolumeVerifier::Result& result) -{ - if (!result.hashes.crc32.empty()) - std::cout << "CRC32: " << HashToHexString(result.hashes.crc32) << std::endl; - else - 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 computed" << std::endl; - - if (!result.hashes.sha1.empty()) - std::cout << "SHA1: " << HashToHexString(result.hashes.sha1) << std::endl; - else - std::cout << "SHA1 not computed" << std::endl; - - std::cout << "Problems Found: " << (result.problems.empty() ? "No" : "Yes") << std::endl; - - for (const auto& problem : result.problems) - { - std::cout << std::endl << "Severity: "; - switch (problem.severity) - { - case DiscIO::VolumeVerifier::Severity::Low: - std::cout << "Low"; - break; - case DiscIO::VolumeVerifier::Severity::Medium: - std::cout << "Medium"; - break; - case DiscIO::VolumeVerifier::Severity::High: - std::cout << "High"; - break; - case DiscIO::VolumeVerifier::Severity::None: - std::cout << "None"; - break; - default: - ASSERT(false); - break; - } - std::cout << std::endl; - - std::cout << "Summary: " << problem.text << std::endl << std::endl; - } -} - -std::string VerifyCommand::HashToHexString(const std::vector& hash) -{ - std::stringstream ss; - ss << std::hex; - for (int i = 0; i < static_cast(hash.size()); ++i) - { - ss << std::setw(2) << std::setfill('0') << static_cast(hash[i]); - } - return ss.str(); -} } // namespace DolphinTool -- cgit v1.2.3