filesystem: zip: remove XASH_ZLIB macro
This commit is contained in:
parent
3c0a34926a
commit
b04a48f126
2 changed files with 25 additions and 28 deletions
|
@ -16,6 +16,7 @@ GNU General Public License for more details.
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <zlib.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
@ -33,10 +34,6 @@ GNU General Public License for more details.
|
||||||
#define FILE_COPY_SIZE (1024 * 1024)
|
#define FILE_COPY_SIZE (1024 * 1024)
|
||||||
#define FILE_BUFF_SIZE (2048)
|
#define FILE_BUFF_SIZE (2048)
|
||||||
|
|
||||||
#ifdef XASH_ZLIB
|
|
||||||
#include <zlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// PAK errors
|
// PAK errors
|
||||||
#define PAK_LOAD_OK 0
|
#define PAK_LOAD_OK 0
|
||||||
#define PAK_LOAD_COULDNT_OPEN 1
|
#define PAK_LOAD_COULDNT_OPEN 1
|
||||||
|
@ -63,8 +60,6 @@ GNU General Public License for more details.
|
||||||
#define ZIP_LOAD_NO_FILES 5
|
#define ZIP_LOAD_NO_FILES 5
|
||||||
#define ZIP_LOAD_CORRUPTED 6
|
#define ZIP_LOAD_CORRUPTED 6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct stringlist_s
|
typedef struct stringlist_s
|
||||||
{
|
{
|
||||||
// maxstrings changes as needed, causing reallocation of strings[] array
|
// maxstrings changes as needed, causing reallocation of strings[] array
|
||||||
|
@ -693,7 +688,9 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
Zip_Close( zip );
|
Zip_Close( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if( signature != ZIP_HEADER_LF ) {
|
|
||||||
|
if( signature != ZIP_HEADER_LF )
|
||||||
|
{
|
||||||
Con_Reportf( "%s is not a zip file. Ignored.\n", zipfile );
|
Con_Reportf( "%s is not a zip file. Ignored.\n", zipfile );
|
||||||
if( error )
|
if( error )
|
||||||
*error = ZIP_LOAD_BAD_HEADER;
|
*error = ZIP_LOAD_BAD_HEADER;
|
||||||
|
@ -858,8 +855,9 @@ static byte *Zip_LoadFile( const char *path, fs_offset_t *sizeptr, qboolean game
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
#ifdef XASH_ZLIB
|
|
||||||
if( header.compression_flags == ZIP_COMPRESSION_DEFLATED ) {
|
if( header.compression_flags == ZIP_COMPRESSION_DEFLATED )
|
||||||
|
{
|
||||||
|
|
||||||
if( header.filename_len )
|
if( header.filename_len )
|
||||||
FS_Seek( search->zip->handle, header.filename_len, SEEK_CUR );
|
FS_Seek( search->zip->handle, header.filename_len, SEEK_CUR );
|
||||||
|
@ -901,26 +899,25 @@ static byte *Zip_LoadFile( const char *path, fs_offset_t *sizeptr, qboolean game
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( sizeptr ) *sizeptr = file->size;
|
||||||
|
|
||||||
} else if( zlib_result == Z_DATA_ERROR ){
|
return decompresed_buffer;
|
||||||
Con_Reportf( S_ERROR "Zip_LoadFile: %s : compressed files data corrupted.\n", file->name );
|
|
||||||
|
} else if( zlib_result == Z_DATA_ERROR )
|
||||||
|
{
|
||||||
|
Con_Reportf( S_ERROR "Zip_LoadFile: %s : compressed file data corrupted.\n", file->name );
|
||||||
Mem_Free( compresed_buffer );
|
Mem_Free( compresed_buffer );
|
||||||
Mem_Free( decompresed_buffer );
|
Mem_Free( decompresed_buffer );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
Con_Reportf( S_ERROR "Zip_LoadFile: %s : file compressed with unknown algorithm.\n", file->name );
|
Con_Reportf( S_ERROR "Zip_LoadFile: %s : file compressed with unknown algorithm.\n", file->name );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
else {
|
|
||||||
Con_Reportf( S_ERROR "Zip_LoadFile: %s : compressed files not supported.\n", file->name );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue