mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Buildfix
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/StringUtils.h"
|
||||
@@ -352,6 +354,34 @@ inline char asciitolower(char in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
static bool ZipExtractFileToMemory(struct zip *z, int fileIndex, std::string *data) {
|
||||
struct zip_stat zstat;
|
||||
zip_stat_index(z, fileIndex, 0, &zstat);
|
||||
if (zstat.size == 0) {
|
||||
data->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t readSize = zstat.size;
|
||||
data->resize(readSize);
|
||||
|
||||
zip_file *zf = zip_fopen_index(z, fileIndex, 0);
|
||||
if (!zf) {
|
||||
ERROR_LOG(Log::HLE, "Failed to zip_fopen_index file %d from zip", fileIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
zip_int64_t retval = zip_fread(zf, data->data(), readSize);
|
||||
zip_fclose(zf);
|
||||
|
||||
if (retval < 0 || retval < (int)readSize) {
|
||||
ERROR_LOG(Log::HLE, "Failed to read %d bytes from zip (%d) - archive corrupt?", (int)readSize, (int)retval);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void DetectZipFileContents(struct zip *z, ZipFileInfo *info) {
|
||||
int numFiles = zip_get_num_files(z);
|
||||
_dbg_assert_(numFiles >= 0);
|
||||
|
||||
@@ -473,34 +473,6 @@ std::string GameManager::GetISOGameID(FileLoader *loader) const {
|
||||
return sfo.GetValueString("DISC_ID");
|
||||
}
|
||||
|
||||
bool ZipExtractFileToMemory(struct zip *z, int fileIndex, std::string *data) {
|
||||
struct zip_stat zstat;
|
||||
zip_stat_index(z, fileIndex, 0, &zstat);
|
||||
if (zstat.size == 0) {
|
||||
data->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t readSize = zstat.size;
|
||||
data->resize(readSize);
|
||||
|
||||
zip_file *zf = zip_fopen_index(z, fileIndex, 0);
|
||||
if (!zf) {
|
||||
ERROR_LOG(Log::HLE, "Failed to zip_fopen_index file %d from zip", fileIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
zip_int64_t retval = zip_fread(zf, data->data(), readSize);
|
||||
zip_fclose(zf);
|
||||
|
||||
if (retval < 0 || retval < (int)readSize) {
|
||||
ERROR_LOG(Log::HLE, "Failed to read %d bytes from zip (%d) - archive corrupt?", (int)readSize, (int)retval);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool GameManager::ExtractFile(struct zip *z, int file_index, const Path &outFilename, size_t *bytesCopied, size_t allBytes) {
|
||||
struct zip_stat zstat;
|
||||
zip_stat_index(z, file_index, 0, &zstat);
|
||||
|
||||
@@ -122,8 +122,4 @@ extern GameManager g_GameManager;
|
||||
struct zip *ZipOpenPath(Path fileName);
|
||||
void ZipClose(zip *z);
|
||||
|
||||
void DetectZipFileContents(struct zip *z, ZipFileInfo *info);
|
||||
bool DetectZipFileContents(const Path &fileName, ZipFileInfo *info);
|
||||
|
||||
bool ZipExtractFileToMemory(struct zip *z, int fileIndex, std::string *data);
|
||||
bool CanExtractWithoutOverwrite(struct zip *z, const Path &destination, int maxOkFiles);
|
||||
|
||||
Reference in New Issue
Block a user