filesystem: zip: codestyle 2
This commit is contained in:
parent
5cf4e34607
commit
1cc2ec9095
2 changed files with 66 additions and 54 deletions
|
@ -120,7 +120,6 @@ typedef unsigned int uint;
|
||||||
typedef char string[MAX_STRING];
|
typedef char string[MAX_STRING];
|
||||||
typedef struct file_s file_t; // normal file
|
typedef struct file_s file_t; // normal file
|
||||||
typedef struct wfile_s wfile_t; // wad 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 struct stream_s stream_t; // sound stream for background music playing
|
||||||
typedef off_t fs_offset_t;
|
typedef off_t fs_offset_t;
|
||||||
|
|
||||||
|
|
|
@ -645,11 +645,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
zip_header_eocd_t header_eocd;
|
zip_header_eocd_t header_eocd;
|
||||||
uint signature;
|
uint signature;
|
||||||
fs_offset_t filepos = 0;
|
fs_offset_t filepos = 0;
|
||||||
|
zipfile_t *info = NULL;
|
||||||
|
|
||||||
zip_t *zip = (zip_t *)Mem_Calloc( fs_mempool, sizeof( zip_t ) );
|
zip_t *zip = (zip_t *)Mem_Calloc( fs_mempool, sizeof( zip_t ) );
|
||||||
|
|
||||||
zipfile_t *info = NULL;
|
|
||||||
|
|
||||||
zip->handle = FS_Open( zipfile, "rb", true );
|
zip->handle = FS_Open( zipfile, "rb", true );
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -664,8 +663,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
if( !zip->handle )
|
if( !zip->handle )
|
||||||
{
|
{
|
||||||
Con_Reportf( "%s couldn't open\n", zipfile );
|
Con_Reportf( "%s couldn't open\n", zipfile );
|
||||||
|
|
||||||
if( error )
|
if( error )
|
||||||
*error = ZIP_LOAD_COULDNT_OPEN;
|
*error = ZIP_LOAD_COULDNT_OPEN;
|
||||||
|
|
||||||
Zip_Close( zip );
|
Zip_Close( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -673,8 +674,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
if( FS_FileLength( zip->handle ) > UINT_MAX )
|
if( FS_FileLength( zip->handle ) > UINT_MAX )
|
||||||
{
|
{
|
||||||
Con_Reportf( "%s bigger than 4GB.\n", zipfile );
|
Con_Reportf( "%s bigger than 4GB.\n", zipfile );
|
||||||
|
|
||||||
if( error )
|
if( error )
|
||||||
*error = ZIP_LOAD_COULDNT_OPEN;
|
*error = ZIP_LOAD_COULDNT_OPEN;
|
||||||
|
|
||||||
Zip_Close( zip );
|
Zip_Close( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -684,8 +687,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
if( signature == ZIP_HEADER_EOCD )
|
if( signature == ZIP_HEADER_EOCD )
|
||||||
{
|
{
|
||||||
Con_Reportf( "%s has no files. Ignored.\n", zipfile );
|
Con_Reportf( "%s has no files. Ignored.\n", zipfile );
|
||||||
|
|
||||||
if(error)
|
if(error)
|
||||||
*error = ZIP_LOAD_NO_FILES;
|
*error = ZIP_LOAD_NO_FILES;
|
||||||
|
|
||||||
Zip_Close( zip );
|
Zip_Close( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -693,8 +698,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
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;
|
||||||
|
|
||||||
Zip_Close( zip );
|
Zip_Close( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -715,8 +722,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
if( ZIP_HEADER_EOCD != signature )
|
if( ZIP_HEADER_EOCD != signature )
|
||||||
{
|
{
|
||||||
Con_Reportf( "Cannot find EOCD in %s. Zip file corrupted.\n", zipfile );
|
Con_Reportf( "Cannot find EOCD in %s. Zip file corrupted.\n", zipfile );
|
||||||
|
|
||||||
if(error)
|
if(error)
|
||||||
*error = ZIP_LOAD_BAD_HEADER;
|
*error = ZIP_LOAD_BAD_HEADER;
|
||||||
|
|
||||||
Zip_Close( zip );
|
Zip_Close( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -738,8 +747,10 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
if( header_cdf.signature != ZIP_HEADER_CDF )
|
if( header_cdf.signature != ZIP_HEADER_CDF )
|
||||||
{
|
{
|
||||||
Con_Reportf( "CDF signature mismatch in %s. Zip file corrupted.\n", zipfile );
|
Con_Reportf( "CDF signature mismatch in %s. Zip file corrupted.\n", zipfile );
|
||||||
|
|
||||||
if(error)
|
if(error)
|
||||||
*error = ZIP_LOAD_BAD_HEADER;
|
*error = ZIP_LOAD_BAD_HEADER;
|
||||||
|
|
||||||
Mem_Free( info );
|
Mem_Free( info );
|
||||||
Zip_Close( zip );
|
Zip_Close( zip );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -781,7 +792,9 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
|
||||||
for( int i = 0; i < numpackfiles; i++ )
|
for( int i = 0; i < numpackfiles; i++ )
|
||||||
FS_AddFileToZip( info[i].name, zip, info[i].offset, info[i].size, info[i].compressed_size );
|
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 );
|
Mem_Free( info );
|
||||||
|
|
||||||
return zip;
|
return zip;
|
||||||
|
@ -2914,7 +2927,7 @@ byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamediro
|
||||||
buf = W_LoadFile( path, &filesize, gamedironly );
|
buf = W_LoadFile( path, &filesize, gamedironly );
|
||||||
|
|
||||||
if( !buf )
|
if( !buf )
|
||||||
buf = Zip_LoadFile(path, &filesize, gamedironly);
|
buf = Zip_LoadFile( path, &filesize, gamedironly );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( filesizeptr )
|
if( filesizeptr )
|
||||||
|
|
Loading…
Add table
Reference in a new issue