mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-02-17 01:31:47 +00:00
Replace custom unzip functions with standard ones
unz[SG]etCurrentFileInfoPosition() isn't needed anymore, because newer minizip versions have unz[SG]etOffset() for that purpose.
This commit is contained in:
parent
2e47865234
commit
d234bc60e9
6 changed files with 18 additions and 54 deletions
|
@ -1339,7 +1339,7 @@ int idFile_InZip::Seek( long offset, fsOrigin_t origin ) {
|
|||
}
|
||||
case FS_SEEK_SET: {
|
||||
// set the file position in the zip file (also sets the current file info)
|
||||
unzSetCurrentFileInfoPosition( z, zipFilePos );
|
||||
unzSetOffset64(z, zipFilePos);
|
||||
unzOpenCurrentFile( z );
|
||||
if ( offset <= 0 ) {
|
||||
return 0;
|
||||
|
|
|
@ -32,6 +32,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "idlib/math/Vector.h"
|
||||
#include "idlib/BitMsg.h"
|
||||
|
||||
#include "framework/Unzip.h"
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
||||
|
@ -238,7 +240,7 @@ public:
|
|||
private:
|
||||
idStr name; // name of the file in the pak
|
||||
idStr fullPath; // full file path including pak file name
|
||||
int zipFilePos; // zip file info position in pak
|
||||
ZPOS64_T zipFilePos; // zip file info position in pak
|
||||
int fileSize; // size of the file
|
||||
void * z; // unzip info
|
||||
};
|
||||
|
|
|
@ -1329,7 +1329,7 @@ pack_t *idFileSystemLocal::LoadZipFile( const char *zipfile ) {
|
|||
buildBuffer[i].name.ToLower();
|
||||
buildBuffer[i].name.BackSlashesToSlashes();
|
||||
// store the file position in the zip
|
||||
unzGetCurrentFileInfoPosition( uf, &buildBuffer[i].pos );
|
||||
buildBuffer[i].pos = unzGetOffset64( uf );
|
||||
// add the file to the hash
|
||||
buildBuffer[i].next = pack->hashTable[hash];
|
||||
pack->hashTable[hash] = &buildBuffer[i];
|
||||
|
@ -2894,7 +2894,7 @@ idFile_InZip * idFileSystemLocal::ReadFileFromZip( pack_t *pak, fileInPack_t *pa
|
|||
// pakFile->Pos is position of that file within the zip
|
||||
|
||||
// set position in pk4 file to the file (in the zip/pk4) we want a handle on
|
||||
unzSetCurrentFileInfoPosition( pak->handle, pakFile->pos );
|
||||
unzSetOffset64( pak->handle, pakFile->pos );
|
||||
|
||||
// clone handle and assign a new internal filestream to zip file to it
|
||||
unzFile uf = unzReOpen( pak->pakFilename, pak->handle );
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
NOTE from Daniel Gibson:
|
||||
|
||||
These are parts of MiniZip (the unzip-parts), taken from zlib-1.2.7/contrib/minizip/
|
||||
and adjusted for doom3 by adding three functions that were added by id Software in the
|
||||
original Doom3 GPL release for MiniZip 0.15beta. They were adjusted by Daniel Gibson
|
||||
for MiniZip 1.1
|
||||
and adjusted for doom3 by making small adjustments foor doom3 (doom3-specific allocator)
|
||||
and adding a function (unzReOpen()) from the original Doom3 GPL release by id Software
|
||||
that used MiniZip 0.15beta. It was adjusted by Daniel Gibson for MiniZip 1.1
|
||||
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2012 Daniel Gibson
|
||||
|
||||
|
|
|
@ -65,14 +65,10 @@
|
|||
|
||||
####################################################################################
|
||||
|
||||
The following functions were added by id Software (originally in framework/Unzip.cpp) for doom3
|
||||
and adjusted by Daniel Gibson for MiniZip 1.1 by Daniel Gibson
|
||||
unzReOpen() was added by id Software (originally in framework/Unzip.cpp) for doom3
|
||||
and adjusted for MiniZip 1.1 by Daniel Gibson
|
||||
The file was renamed from unzip.c to unzip.cpp so we can use C++ functions from doom3
|
||||
|
||||
* unzReOpen()
|
||||
* unzGetCurrentFileInfoPosition()
|
||||
* unzSetCurrentFileInfoPosition()
|
||||
|
||||
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2012 Daniel Gibson
|
||||
|
||||
|
@ -1759,6 +1755,9 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
|||
uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
|
||||
if (uReadThis == 0)
|
||||
return UNZ_EOF;
|
||||
// TODO: the following line was added by id Software to the original src - seems to work without it,
|
||||
// but if problems occur look here..
|
||||
// if(s->cur_file_info.compressed_size == pfile_in_zip_read_info->rest_read_compressed)
|
||||
if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
|
||||
pfile_in_zip_read_info->filestream,
|
||||
pfile_in_zip_read_info->pos_in_zipfile +
|
||||
|
@ -2158,7 +2157,7 @@ extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
|
|||
|
||||
|
||||
// ####################################################################
|
||||
// the following functions were added for doom3 by id Software and
|
||||
// the following function was added for doom3 by id Software and
|
||||
// adjusted for MiniZip 1.1 by Daniel Gibson
|
||||
|
||||
|
||||
|
@ -2194,27 +2193,3 @@ extern unzFile unzReOpen (const char* path, unzFile file)
|
|||
|
||||
return (unzFile)s;
|
||||
}
|
||||
|
||||
/*
|
||||
Get the position of the info of the current file in the zip.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
extern int unzGetCurrentFileInfoPosition (unzFile file, ZPOS64_T *pos )
|
||||
{
|
||||
ZPOS64_T p = unzGetOffset64(file);
|
||||
if(p==0)
|
||||
return UNZ_PARAMERROR;
|
||||
|
||||
*pos = p;
|
||||
|
||||
return UNZ_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
Set the position of the info of the current file in the zip.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
extern int unzSetCurrentFileInfoPosition (unzFile file, ZPOS64_T pos )
|
||||
{
|
||||
return unzSetOffset64(file, pos);
|
||||
}
|
||||
|
|
|
@ -432,12 +432,13 @@ extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
|||
|
||||
// ####################################################################
|
||||
|
||||
// the following functions were added for doom3 by id Software
|
||||
// the following function was added for doom3 by id Software
|
||||
|
||||
extern unzFile unzReOpen( const char* path, unzFile file );
|
||||
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
Re-Open a Zip file, i.e. clone an existing one and give it a new file descriptor.
|
||||
path contain the full pathname (by example,
|
||||
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
|
||||
"zlib/zlib111.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
|
@ -446,20 +447,6 @@ extern unzFile unzReOpen( const char* path, unzFile file );
|
|||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern int unzGetCurrentFileInfoPosition( unzFile file, ZPOS64_T* pos );
|
||||
|
||||
/*
|
||||
Get the position of the info of the current file in the zip.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int unzSetCurrentFileInfoPosition( unzFile file, ZPOS64_T pos );
|
||||
|
||||
/*
|
||||
Set the position of the info of the current file in the zip.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue