-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VolumeVerifier: Add zip support for datfile
- Loading branch information
Showing
8 changed files
with
92 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ add_library(discio | |
|
||
target_link_libraries(discio | ||
PRIVATE | ||
minizip | ||
pugixml | ||
ZLIB::ZLIB | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters