summaryrefslogtreecommitdiff
path: root/source/files.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2008-04-23 15:02:41 +0000
committerAndrey Nazarov <skuller@skuller.net>2008-04-23 15:02:41 +0000
commit49e6170b49fbb933eddec6d0e3f946320c68832f (patch)
tree88d228d6f89103710074fdba041ce80584d5caa6 /source/files.c
parent8c795585fb0c6c9178d9981f6943da04b7279205 (diff)
Added `dumpents' server command.
Added support for `cl_noskins' value of 2 (default all female skins to `female/athena', all male skins to `male/grunt'). Renamed `scoreshot' command to `aashot', added `aadump' command. Fixed several alignment issues on ARM architecture. Server browser menu now indicates full and password protected servers with color codes. Implemented history search in console with Ctrl+R, Ctrl+S. Removed `cl_railtrail_alpha' variable, all `cl_rail*_color' variables now accept colors in #RRGGBBAA format. Added `map_override' cvar (enables loading map entity lump from external maps/*.ent file). Made `quit' command accept extra arguments. Made `draw' command accept arbitrary colors in #RRGGBBAA format. Fixed debian packages.
Diffstat (limited to 'source/files.c')
-rw-r--r--source/files.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/source/files.c b/source/files.c
index 88c7684..34a07d5 100644
--- a/source/files.c
+++ b/source/files.c
@@ -989,11 +989,11 @@ Filenames are relative to the quake search path
a null buffer will just return the file length without loading
============
*/
-size_t FS_LoadFileEx( const char *path, void **buffer, int flags ) {
+size_t FS_LoadFileEx( const char *path, void **buffer, int flags, memtag_t tag ) {
fsFile_t *file;
fileHandle_t f;
byte *buf;
- size_t length;
+ size_t len;
if( !path ) {
Com_Error( ERR_FATAL, "FS_LoadFile: NULL" );
@@ -1024,31 +1024,45 @@ size_t FS_LoadFileEx( const char *path, void **buffer, int flags ) {
file->mode = flags | FS_MODE_READ;
// look for it in the filesystem or pack files
- length = FS_FOpenFileRead( file, path, qfalse );
- if( length == INVALID_LENGTH ) {
- return length;
+ len = FS_FOpenFileRead( file, path, qfalse );
+ if( len == INVALID_LENGTH ) {
+ return len;
}
if( buffer ) {
#if USE_ZLIB
if( file->type == FS_GZIP ) {
- length = INVALID_LENGTH; // unknown length
+ len = INVALID_LENGTH; // unknown length
} else
#endif
{
- *buffer = buf = FS_AllocTempMem( length + 1 );
- FS_Read( buf, length, f );
- buf[length] = 0;
+ if( tag == TAG_FREE ) {
+ buf = FS_AllocTempMem( len + 1 );
+ } else {
+ buf = Z_TagMalloc( len + 1, tag );
+ }
+ if( FS_Read( buf, len, f ) == len ) {
+ *buffer = buf;
+ buf[len] = 0;
+ } else {
+ Com_EPrintf( "FS_LoadFile: error reading file: %s\n", path );
+ if( tag == TAG_FREE ) {
+ FS_FreeFile( buf );
+ } else {
+ Z_Free( buf );
+ }
+ len = INVALID_LENGTH;
+ }
}
}
FS_FCloseFile( f );
- return length;
+ return len;
}
size_t FS_LoadFile( const char *path, void **buffer ) {
- return FS_LoadFileEx( path, buffer, 0 );
+ return FS_LoadFileEx( path, buffer, 0, TAG_FREE );
}
void *FS_AllocTempMem( size_t length ) {