mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-22 01:35:40 -04:00
Add image verification
"Verify Dump" is now removed, now both hash calculation and image verification are done in one step. After a successful hash calculation, the button is replaced with a "Search on Redump.org" button that opens a web browser on Redump's search page.
This commit is contained in:
@ -82,6 +82,17 @@ std::string HashToString(const Hash& hash)
|
||||
hash[9], hash[10], hash[11], hash[12], hash[13], hash[14], hash[15]);
|
||||
}
|
||||
|
||||
std::optional<Hash> HashFromString(const std::string_view& str) {
|
||||
auto decoded = StringUtil::DecodeHex(str);
|
||||
if (decoded && decoded->size() == std::tuple_size_v<Hash>)
|
||||
{
|
||||
Hash result;
|
||||
std::copy(decoded->begin(), decoded->end(), result.begin());
|
||||
return result;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool GetImageHash(CDImage* image, Hash* out_hash,
|
||||
ProgressCallback* progress_callback /*= ProgressCallback::NullProgressCallback*/)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "progress_callback.h"
|
||||
#include "types.h"
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
class CDImage;
|
||||
@ -10,6 +11,7 @@ namespace CDImageHasher {
|
||||
|
||||
using Hash = std::array<u8, 16>;
|
||||
std::string HashToString(const Hash& hash);
|
||||
std::optional<Hash> HashFromString(const std::string_view& str);
|
||||
|
||||
bool GetImageHash(CDImage* image, Hash* out_hash,
|
||||
ProgressCallback* progress_callback = ProgressCallback::NullProgressCallback);
|
||||
|
Reference in New Issue
Block a user