synced with scummvm

This commit is contained in:
Pawel Kolodziejski 2011-05-01 17:49:40 +02:00
parent 8e46fdc4c3
commit 6be453780f
192 changed files with 2249 additions and 703 deletions

View file

@ -105,7 +105,6 @@ typedef struct {
#include "common/fs.h"
#include "common/unzip.h"
#include "common/file.h"
#include "common/memstream.h"
#include "common/hashmap.h"
@ -455,7 +454,7 @@ int unzStringFileNameCompare(const char* fileName1, const char* fileName2, int i
if (iCaseSensitivity==1)
return strcmp(fileName1,fileName2);
return strcasecmp(fileName1,fileName2);
return scumm_stricmp(fileName1,fileName2);
}
#define BUFREADCOMMENT (0x400)
@ -1470,11 +1469,13 @@ int ZipArchive::listMembers(Common::ArchiveMemberList &list) {
while (err == UNZ_OK) {
char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
unzGetCurrentFileInfo(_zipFile, NULL,
szCurrentFileName, sizeof(szCurrentFileName)-1,
NULL, 0, NULL, 0);
list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(szCurrentFileName, this)));
matches++;
if (unzGetCurrentFileInfo(_zipFile, NULL,
szCurrentFileName, sizeof(szCurrentFileName)-1,
NULL, 0, NULL, 0) == UNZ_OK) {
list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(szCurrentFileName, this)));
matches++;
}
err = unzGoToNextFile(_zipFile);
}
@ -1493,18 +1494,31 @@ Common::SeekableReadStream *ZipArchive::createReadStreamForMember(const Common::
return 0;
unz_file_info fileInfo;
unzOpenCurrentFile(_zipFile);
unzGetCurrentFileInfo(_zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
if (unzOpenCurrentFile(_zipFile) != UNZ_OK)
return 0;
if (unzGetCurrentFileInfo(_zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0) != UNZ_OK)
return 0;
byte *buffer = (byte *)malloc(fileInfo.uncompressed_size);
assert(buffer);
unzReadCurrentFile(_zipFile, buffer, fileInfo.uncompressed_size);
unzCloseCurrentFile(_zipFile);
if (unzReadCurrentFile(_zipFile, buffer, fileInfo.uncompressed_size) != (int)fileInfo.uncompressed_size) {
free(buffer);
return 0;
}
if (unzCloseCurrentFile(_zipFile) != UNZ_OK) {
free(buffer);
return 0;
}
return new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size, DisposeAfterUse::YES);
// FIXME: instead of reading all into a memory stream, we could
// instead create a new ZipStream class. But then we have to be
// careful to handle the case where the client code opens multiple
// files in the archive and tries to use them indepenendtly.
// files in the archive and tries to use them independently.
}
Archive *makeZipArchive(const String &name) {