summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorTillmann Karras <tilkax@gmail.com>2015-09-16 21:06:54 +0200
committerTillmann Karras <tilkax@gmail.com>2015-10-12 02:35:43 +0200
commit00aefa5e08a9aa6865a14706dcf35346993fa517 (patch)
treeb22bc09b7e3c5876b801f02207273e1c5dfe5bcf /Source/Core
parentefe71e686b8b89e87e2c10237e4d33bc4bfdf54f (diff)
DolphinWX: decompress discs to calculate MD5 hash
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DiscIO/Blob.cpp12
-rw-r--r--Source/Core/DolphinWX/ISOProperties.cpp14
2 files changed, 12 insertions, 14 deletions
diff --git a/Source/Core/DiscIO/Blob.cpp b/Source/Core/DiscIO/Blob.cpp
index 9ed8577c38..1a2333f198 100644
--- a/Source/Core/DiscIO/Blob.cpp
+++ b/Source/Core/DiscIO/Blob.cpp
@@ -77,23 +77,19 @@ bool SectorReader::Read(u64 offset, u64 size, u8* out_ptr)
continue;
}
+ const u8* data = GetBlockData(block);
+ if (!data)
+ return false;
+
u32 toCopy = m_blocksize - positionInBlock;
if (toCopy >= remain)
{
- const u8* data = GetBlockData(block);
- if (!data)
- return false;
-
// Yay, we are done!
memcpy(out_ptr, data + positionInBlock, (size_t)remain);
return true;
}
else
{
- const u8* data = GetBlockData(block);
- if (!data)
- return false;
-
memcpy(out_ptr, data + positionInBlock, toCopy);
out_ptr += toCopy;
remain -= toCopy;
diff --git a/Source/Core/DolphinWX/ISOProperties.cpp b/Source/Core/DolphinWX/ISOProperties.cpp
index c790098ca9..0344e98130 100644
--- a/Source/Core/DolphinWX/ISOProperties.cpp
+++ b/Source/Core/DolphinWX/ISOProperties.cpp
@@ -57,6 +57,7 @@
#include "Core/GeckoCodeConfig.h"
#include "Core/PatchEngine.h"
#include "Core/Boot/Boot.h"
+#include "DiscIO/Blob.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
@@ -1237,8 +1238,8 @@ void CISOProperties::OnComputeMD5Sum(wxCommandEvent& WXUNUSED (event))
u64 read_offset = 0;
mbedtls_md5_context ctx;
- File::IOFile file(OpenGameListItem.GetFileName(), "rb");
- u64 game_size = file.GetSize();
+ std::unique_ptr<DiscIO::IBlobReader> file(DiscIO::CreateBlobReader(OpenGameListItem.GetFileName()));
+ u64 game_size = file->GetDataSize();
wxProgressDialog progressDialog(
_("Computing MD5 checksum"),
@@ -1254,13 +1255,14 @@ void CISOProperties::OnComputeMD5Sum(wxCommandEvent& WXUNUSED (event))
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;
- size_t read_size;
- file.ReadArray(&data[0], data.size(), &read_size);
- mbedtls_md5_update(&ctx, &data[0], read_size);
+ size_t read_size = std::min((u64)data.size(), game_size - read_offset);
+ if (!file->Read(read_offset, read_size, data.data()))
+ return;
+ mbedtls_md5_update(&ctx, data.data(), read_size);
read_offset += read_size;
}