Browse Source

filesystem: zip: codestyle 2

pull/2/head
Mr0maks 6 years ago
parent
commit
1cc2ec9095
  1. 1
      common/xash3d_types.h
  2. 21
      engine/common/filesystem.c

1
common/xash3d_types.h

@ -120,7 +120,6 @@ typedef unsigned int uint; @@ -120,7 +120,6 @@ typedef unsigned int uint;
typedef char string[MAX_STRING];
typedef struct file_s file_t; // normal file
typedef struct wfile_s wfile_t; // wad file
typedef struct zip_s zip_t; // zip file
typedef struct stream_s stream_t; // sound stream for background music playing
typedef off_t fs_offset_t;

21
engine/common/filesystem.c

@ -645,11 +645,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error ) @@ -645,11 +645,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
zip_header_eocd_t header_eocd;
uint signature;
fs_offset_t filepos = 0;
zipfile_t *info = NULL;
zip_t *zip = (zip_t *)Mem_Calloc( fs_mempool, sizeof( zip_t ) );
zipfile_t *info = NULL;
zip->handle = FS_Open( zipfile, "rb", true );
#ifndef _WIN32
@ -664,8 +663,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error ) @@ -664,8 +663,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
if( !zip->handle )
{
Con_Reportf( "%s couldn't open\n", zipfile );
if( error )
*error = ZIP_LOAD_COULDNT_OPEN;
Zip_Close( zip );
return NULL;
}
@ -673,8 +674,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error ) @@ -673,8 +674,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
if( FS_FileLength( zip->handle ) > UINT_MAX )
{
Con_Reportf( "%s bigger than 4GB.\n", zipfile );
if( error )
*error = ZIP_LOAD_COULDNT_OPEN;
Zip_Close( zip );
return NULL;
}
@ -684,8 +687,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error ) @@ -684,8 +687,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
if( signature == ZIP_HEADER_EOCD )
{
Con_Reportf( "%s has no files. Ignored.\n", zipfile );
if(error)
*error = ZIP_LOAD_NO_FILES;
Zip_Close( zip );
return NULL;
}
@ -693,8 +698,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error ) @@ -693,8 +698,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
if( signature != ZIP_HEADER_LF )
{
Con_Reportf( "%s is not a zip file. Ignored.\n", zipfile );
if( error )
*error = ZIP_LOAD_BAD_HEADER;
Zip_Close( zip );
return NULL;
}
@ -715,8 +722,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error ) @@ -715,8 +722,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
if( ZIP_HEADER_EOCD != signature )
{
Con_Reportf( "Cannot find EOCD in %s. Zip file corrupted.\n", zipfile );
if(error)
*error = ZIP_LOAD_BAD_HEADER;
Zip_Close( zip );
return NULL;
}
@ -738,8 +747,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error ) @@ -738,8 +747,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
if( header_cdf.signature != ZIP_HEADER_CDF )
{
Con_Reportf( "CDF signature mismatch in %s. Zip file corrupted.\n", zipfile );
if(error)
*error = ZIP_LOAD_BAD_HEADER;
Mem_Free( info );
Zip_Close( zip );
return NULL;
@ -781,7 +792,9 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error ) @@ -781,7 +792,9 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
for( int i = 0; i < numpackfiles; i++ )
FS_AddFileToZip( info[i].name, zip, info[i].offset, info[i].size, info[i].compressed_size );
if( error ) *error = ZIP_LOAD_OK;
if( error )
*error = ZIP_LOAD_OK;
Mem_Free( info );
return zip;
@ -2914,7 +2927,7 @@ byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamediro @@ -2914,7 +2927,7 @@ byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamediro
buf = W_LoadFile( path, &filesize, gamedironly );
if( !buf )
buf = Zip_LoadFile(path, &filesize, gamedironly);
buf = Zip_LoadFile( path, &filesize, gamedironly );
}
if( filesizeptr )

Loading…
Cancel
Save