mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-27 03:39:57 +00:00
DolphinWX: decompress discs to calculate MD5 hash
This commit is contained in:
parent
efe71e686b
commit
00aefa5e08
@ -77,23 +77,19 @@ bool SectorReader::Read(u64 offset, u64 size, u8* out_ptr)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 toCopy = m_blocksize - positionInBlock;
|
|
||||||
if (toCopy >= remain)
|
|
||||||
{
|
|
||||||
const u8* data = GetBlockData(block);
|
const u8* data = GetBlockData(block);
|
||||||
if (!data)
|
if (!data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
u32 toCopy = m_blocksize - positionInBlock;
|
||||||
|
if (toCopy >= remain)
|
||||||
|
{
|
||||||
// Yay, we are done!
|
// Yay, we are done!
|
||||||
memcpy(out_ptr, data + positionInBlock, (size_t)remain);
|
memcpy(out_ptr, data + positionInBlock, (size_t)remain);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const u8* data = GetBlockData(block);
|
|
||||||
if (!data)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
memcpy(out_ptr, data + positionInBlock, toCopy);
|
memcpy(out_ptr, data + positionInBlock, toCopy);
|
||||||
out_ptr += toCopy;
|
out_ptr += toCopy;
|
||||||
remain -= toCopy;
|
remain -= toCopy;
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
#include "Core/GeckoCodeConfig.h"
|
#include "Core/GeckoCodeConfig.h"
|
||||||
#include "Core/PatchEngine.h"
|
#include "Core/PatchEngine.h"
|
||||||
#include "Core/Boot/Boot.h"
|
#include "Core/Boot/Boot.h"
|
||||||
|
#include "DiscIO/Blob.h"
|
||||||
#include "DiscIO/Filesystem.h"
|
#include "DiscIO/Filesystem.h"
|
||||||
#include "DiscIO/Volume.h"
|
#include "DiscIO/Volume.h"
|
||||||
#include "DiscIO/VolumeCreator.h"
|
#include "DiscIO/VolumeCreator.h"
|
||||||
@ -1237,8 +1238,8 @@ void CISOProperties::OnComputeMD5Sum(wxCommandEvent& WXUNUSED (event))
|
|||||||
u64 read_offset = 0;
|
u64 read_offset = 0;
|
||||||
mbedtls_md5_context ctx;
|
mbedtls_md5_context ctx;
|
||||||
|
|
||||||
File::IOFile file(OpenGameListItem.GetFileName(), "rb");
|
std::unique_ptr<DiscIO::IBlobReader> file(DiscIO::CreateBlobReader(OpenGameListItem.GetFileName()));
|
||||||
u64 game_size = file.GetSize();
|
u64 game_size = file->GetDataSize();
|
||||||
|
|
||||||
wxProgressDialog progressDialog(
|
wxProgressDialog progressDialog(
|
||||||
_("Computing MD5 checksum"),
|
_("Computing MD5 checksum"),
|
||||||
@ -1254,13 +1255,14 @@ void CISOProperties::OnComputeMD5Sum(wxCommandEvent& WXUNUSED (event))
|
|||||||
|
|
||||||
while(read_offset < game_size)
|
while(read_offset < game_size)
|
||||||
{
|
{
|
||||||
if (!progressDialog.Update((int)((double)read_offset / (double)game_size * 1000), _("Computing MD5 checksum")))
|
if (!progressDialog.Update((int)((double)read_offset / (double)game_size * 1000)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size_t read_size;
|
size_t read_size = std::min((u64)data.size(), game_size - read_offset);
|
||||||
file.ReadArray(&data[0], data.size(), &read_size);
|
if (!file->Read(read_offset, read_size, data.data()))
|
||||||
mbedtls_md5_update(&ctx, &data[0], read_size);
|
return;
|
||||||
|
|
||||||
|
mbedtls_md5_update(&ctx, data.data(), read_size);
|
||||||
read_offset += read_size;
|
read_offset += read_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user