summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinTool/VerifyCommand.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-06-17 03:56:22 +0200
committerGitHub <noreply@github.com>2023-06-17 03:56:22 +0200
commit523f8c5776f3142bc5bfb3e298a5920f2fe9ad2d (patch)
tree34da80d0d5f139c9a786c8ac1a972e4429c78f44 /Source/Core/DolphinTool/VerifyCommand.cpp
parent98b5d72ef1415758db372f35942a19982cb27128 (diff)
parent25c020cbe2b0f5fa0b384c64839fc16745af133c (diff)
Merge pull request #11953 from Minty-Meeo/dolphin-tool-code-review-2
DolphinTool: Ditch OOP design
Diffstat (limited to 'Source/Core/DolphinTool/VerifyCommand.cpp')
-rw-r--r--Source/Core/DolphinTool/VerifyCommand.cpp125
1 files changed, 66 insertions, 59 deletions
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 <string>
+#include <vector>
#include <OptionParser.h>
+#include "Common/StringUtil.h"
+#include "DiscIO/VolumeDisc.h"
+#include "DiscIO/VolumeVerifier.h"
+#include "UICommon/UICommon.h"
+
namespace DolphinTool
{
-int VerifyCommand::Main(const std::vector<std::string>& args)
+static std::string HashToHexString(const std::vector<u8>& hash)
+{
+ std::stringstream ss;
+ ss << std::hex;
+ for (int i = 0; i < static_cast<int>(hash.size()); ++i)
+ {
+ ss << std::setw(2) << std::setfill('0') << static_cast<int>(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<std::string>& args)
{
optparse::OptionParser parser;
@@ -115,61 +179,4 @@ int VerifyCommand::Main(const std::vector<std::string>& 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<u8>& hash)
-{
- std::stringstream ss;
- ss << std::hex;
- for (int i = 0; i < static_cast<int>(hash.size()); ++i)
- {
- ss << std::setw(2) << std::setfill('0') << static_cast<int>(hash[i]);
- }
- return ss.str();
-}
} // namespace DolphinTool