Skip to content

Commit

Permalink
Merge pull request #8330 from JosJuice/redump-integration
Browse files Browse the repository at this point in the history
VolumeVerifier: Add Redump.org integration
  • Loading branch information
JosJuice committed Oct 23, 2019
2 parents 5f8e189 + 87c5e0b commit 2c79c63
Show file tree
Hide file tree
Showing 14 changed files with 533 additions and 69 deletions.
2 changes: 2 additions & 0 deletions Source/Core/Common/CMakeLists.txt
Expand Up @@ -82,6 +82,7 @@ add_library(common
MemArena.h
MemoryUtil.cpp
MemoryUtil.h
MinizipUtil.h
MsgHandler.cpp
MsgHandler.h
NandPaths.cpp
Expand Down Expand Up @@ -134,6 +135,7 @@ PUBLIC
enet
fmt::fmt
${MBEDTLS_LIBRARIES}
minizip

PRIVATE
${CURL_LIBRARIES}
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/Common.vcxproj
Expand Up @@ -139,6 +139,7 @@
<ClInclude Include="MD5.h" />
<ClInclude Include="MemArena.h" />
<ClInclude Include="MemoryUtil.h" />
<ClInclude Include="MinizipUtil.h" />
<ClInclude Include="MsgHandler.h" />
<ClInclude Include="NandPaths.h" />
<ClInclude Include="Network.h" />
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/Common.vcxproj.filters
Expand Up @@ -59,6 +59,7 @@
<ClInclude Include="Matrix.h" />
<ClInclude Include="MemArena.h" />
<ClInclude Include="MemoryUtil.h" />
<ClInclude Include="MinizipUtil.h" />
<ClInclude Include="MsgHandler.h" />
<ClInclude Include="NandPaths.h" />
<ClInclude Include="Network.h" />
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/CommonPaths.h
Expand Up @@ -41,6 +41,7 @@
#define MAPS_DIR "Maps"
#define CACHE_DIR "Cache"
#define COVERCACHE_DIR "GameCovers"
#define REDUMPCACHE_DIR "Redump"
#define SHADERCACHE_DIR "Shaders"
#define STATESAVES_DIR "StateSaves"
#define SCREENSHOTS_DIR "ScreenShots"
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/FileUtil.cpp
Expand Up @@ -765,6 +765,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
s_user_paths[D_MAPS_IDX] = s_user_paths[D_USER_IDX] + MAPS_DIR DIR_SEP;
s_user_paths[D_CACHE_IDX] = s_user_paths[D_USER_IDX] + CACHE_DIR DIR_SEP;
s_user_paths[D_COVERCACHE_IDX] = s_user_paths[D_CACHE_IDX] + COVERCACHE_DIR DIR_SEP;
s_user_paths[D_REDUMPCACHE_IDX] = s_user_paths[D_CACHE_IDX] + REDUMPCACHE_DIR DIR_SEP;
s_user_paths[D_SHADERCACHE_IDX] = s_user_paths[D_CACHE_IDX] + SHADERCACHE_DIR DIR_SEP;
s_user_paths[D_SHADERS_IDX] = s_user_paths[D_USER_IDX] + SHADERS_DIR DIR_SEP;
s_user_paths[D_STATESAVES_IDX] = s_user_paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/FileUtil.h
Expand Up @@ -31,6 +31,7 @@ enum
D_MAPS_IDX,
D_CACHE_IDX,
D_COVERCACHE_IDX,
D_REDUMPCACHE_IDX,
D_SHADERCACHE_IDX,
D_SHADERS_IDX,
D_STATESAVES_IDX,
Expand Down
42 changes: 42 additions & 0 deletions Source/Core/Common/MinizipUtil.h
@@ -0,0 +1,42 @@
// Copyright 2019 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <algorithm>

#include <minizip/unzip.h>

#include "Common/CommonTypes.h"
#include "Common/ScopeGuard.h"

namespace Common
{
// Reads all of the current file. destination must be big enough to fit the whole file.
template <typename ContiguousContainer>
bool ReadFileFromZip(unzFile file, ContiguousContainer* destination)
{
const u32 MAX_BUFFER_SIZE = 65535;

if (unzOpenCurrentFile(file) != UNZ_OK)
return false;

Common::ScopeGuard guard{[&] { unzCloseCurrentFile(file); }};

u32 bytes_to_go = static_cast<u32>(destination->size());
while (bytes_to_go > 0)
{
const int bytes_read =
unzReadCurrentFile(file, &(*destination)[destination->size() - bytes_to_go],
std::min(bytes_to_go, MAX_BUFFER_SIZE));

if (bytes_read < 0)
return false;

bytes_to_go -= static_cast<u32>(bytes_read);
}

return true;
}
} // namespace Common
2 changes: 2 additions & 0 deletions Source/Core/DiscIO/CMakeLists.txt
Expand Up @@ -45,5 +45,7 @@ add_library(discio

target_link_libraries(discio
PRIVATE
minizip
pugixml
ZLIB::ZLIB
)
3 changes: 3 additions & 0 deletions Source/Core/DiscIO/DiscIO.vcxproj
Expand Up @@ -94,6 +94,9 @@
<ProjectReference Include="$(CoreDir)Common\Common.vcxproj">
<Project>{2e6c348c-c75c-4d94-8d1e-9c1fcbf3efe4}</Project>
</ProjectReference>
<ProjectReference Include="$(ExternalsDir)pugixml\pugixml.vcxproj">
<Project>{38fee76f-f347-484b-949c-b4649381cffb}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down

0 comments on commit 2c79c63

Please sign in to comment.