diff options
Diffstat (limited to 'src/qcommon')
-rw-r--r-- | src/qcommon/files.c | 222 |
1 files changed, 111 insertions, 111 deletions
diff --git a/src/qcommon/files.c b/src/qcommon/files.c index 4e1aef13..06bd6fc6 100644 --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -428,9 +428,9 @@ long FS_filelength(fileHandle_t f) h = FS_FileForHandle(f); if(h == NULL) - return -1; - else - return FS_fplength(h); + return -1; + else + return FS_fplength(h); } /* @@ -964,7 +964,7 @@ Ignore case and seprator char distinctions */ qboolean FS_FilenameCompare( const char *s1, const char *s2 ) { int c1, c2; - + do { c1 = *s1++; c2 = *s2++; @@ -982,12 +982,12 @@ qboolean FS_FilenameCompare( const char *s1, const char *s2 ) { if ( c2 == '\\' || c2 == ':' ) { c2 = '/'; } - + if (c1 != c2) { return qtrue; // strings not equal } } while (c1); - + return qfalse; // strings are equal } @@ -1076,9 +1076,9 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ // be prepended, so we don't need to worry about "c:" or "//limbo" if(strstr(filename, ".." ) || strstr(filename, "::")) { - if(file == NULL) - return qfalse; - + if(file == NULL) + return qfalse; + *file = 0; return -1; } @@ -1091,9 +1091,9 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ if(search->pack) { hash = FS_HashFileName(filename, search->pack->hashSize); - - if(search->pack->hashTable[hash]) - { + + if(search->pack->hashTable[hash]) + { // look through all the pak file elements pak = search->pack; pakFile = pak->hashTable[hash]; @@ -1105,14 +1105,14 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ { // found it! if(pakFile->len) - return pakFile->len; - else - { - // It's not nice, but legacy code depends - // on positive value if file exists no matter - // what size - return 1; - } + return pakFile->len; + else + { + // It's not nice, but legacy code depends + // on positive value if file exists no matter + // what size + return 1; + } } pakFile = pakFile->next; @@ -1122,28 +1122,28 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ else if(search->dir) { dir = search->dir; - + netpath = FS_BuildOSPath(dir->path, dir->gamedir, filename); filep = fopen (netpath, "rb"); if(filep) { - len = FS_fplength(filep); + len = FS_fplength(filep); fclose(filep); - + if(len) - return len; - else - return 1; + return len; + else + return 1; } } - + return 0; } *file = FS_HandleForFile(); fsh[*file].handleFiles.unique = uniqueFILE; - + // is the element a pak file? if(search->pack) { @@ -1161,7 +1161,7 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ // look through all the pak file elements pak = search->pack; pakFile = pak->hashTable[hash]; - + do { // case and separator insensitive comparisons @@ -1200,7 +1200,7 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ { // open a new file on the pakfile fsh[*file].handleFiles.file.z = unzOpen(pak->pakFilename); - + if(fsh[*file].handleFiles.file.z == NULL) Com_Error(ERR_FATAL, "Couldn't open %s", pak->pakFilename); } @@ -1209,7 +1209,7 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ Q_strncpyz(fsh[*file].name, filename, sizeof(fsh[*file].name)); fsh[*file].zipFile = qtrue; - + // set the file position in the zip file (also sets the current file info) unzSetOffset(fsh[*file].handleFiles.file.z, pakFile->pos); @@ -1220,12 +1220,12 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ if(fs_debug->integer) { Com_Printf("FS_FOpenFileRead: %s (found in '%s')\n", - filename, pak->pakFilename); + filename, pak->pakFilename); } - + return pakFile->len; } - + pakFile = pakFile->next; } while(pakFile != NULL); } @@ -1263,16 +1263,16 @@ long FS_FOpenFileReadDir(const char *filename, searchpath_t *search, fileHandle_ if (filep == NULL) { *file = 0; - return -1; + return -1; } Q_strncpyz(fsh[*file].name, filename, sizeof(fsh[*file].name)); fsh[*file].zipFile = qfalse; - + if(fs_debug->integer) { Com_Printf("FS_FOpenFileRead: %s (found in '%s/%s')\n", filename, - dir->path, dir->gamedir); + dir->path, dir->gamedir); } fsh[*file].handleFiles.file.o = filep; @@ -1302,19 +1302,19 @@ long FS_FOpenFileRead(const char *filename, fileHandle_t *file, qboolean uniqueF for(search = fs_searchpaths; search; search = search->next) { - len = FS_FOpenFileReadDir(filename, search, file, uniqueFILE, qfalse); - - if(file == NULL) - { - if(len > 0) - return len; - } - else - { - if(len >= 0 && *file) - return len; - } - + len = FS_FOpenFileReadDir(filename, search, file, uniqueFILE, qfalse); + + if(file == NULL) + { + if(len > 0) + return len; + } + else + { + if(len >= 0 && *file) + return len; + } + } #ifdef FS_MISSING @@ -1365,7 +1365,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha if(enableDll) Com_sprintf(dllName, sizeof(dllName), "%s" ARCH_STRING DLL_EXT, name); - + Com_sprintf(qvmName, sizeof(qvmName), "vm/%s.qvm", name); lastSearch = *startSearch; @@ -1373,7 +1373,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha search = fs_searchpaths; else search = lastSearch->next; - + while(search) { if(search->dir && !fs_numServerPaks) @@ -1388,7 +1388,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha { Q_strncpyz(found, netpath, foundlen); *startSearch = search; - + return VMI_NATIVE; } } @@ -1403,17 +1403,17 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha { pack = search->pack; - if(lastSearch && lastSearch->pack) - { - // make sure we only try loading one VM file per game dir - // i.e. if VM from pak7.pk3 fails we won't try one from pak6.pk3 - - if(!FS_FilenameCompare(lastSearch->pack->pakPathname, pack->pakPathname)) - { - search = search->next; - continue; - } - } + if(lastSearch && lastSearch->pack) + { + // make sure we only try loading one VM file per game dir + // i.e. if VM from pak7.pk3 fails we won't try one from pak6.pk3 + + if(!FS_FilenameCompare(lastSearch->pack->pakPathname, pack->pakPathname)) + { + search = search->next; + continue; + } + } if(FS_FOpenFileReadDir(qvmName, search, NULL, qfalse, qfalse) > 0) { @@ -1422,7 +1422,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const cha return VMI_COMPILED; } } - + search = search->next; } @@ -1583,7 +1583,7 @@ int FS_Seek( fileHandle_t f, long offset, int origin ) { if (fsh[f].streamed) { fsh[f].streamed = qfalse; - FS_Seek( f, offset, origin ); + FS_Seek( f, offset, origin ); fsh[f].streamed = qtrue; } @@ -1789,7 +1789,7 @@ long FS_ReadFileDir(const char *qpath, void *searchPath, qboolean unpure, void * { // look for it in the filesystem or pack files len = FS_FOpenFileRead(qpath, &h, qfalse); - } + } else { // look for it in a specific search path only @@ -1809,7 +1809,7 @@ long FS_ReadFileDir(const char *qpath, void *searchPath, qboolean unpure, void * } return -1; } - + if ( !buffer ) { if ( isConfig && com_journal && com_journal->integer == 1 ) { Com_DPrintf( "Writing len for %s to journal file.\n", qpath ); @@ -2050,21 +2050,21 @@ qboolean FS_CompareZipChecksum(const char *zipfile) { pack_t *thepak; int index, checksum; - + thepak = FS_LoadZipFile(zipfile, ""); - + if(!thepak) return qfalse; - + checksum = thepak->checksum; FS_FreePak(thepak); - + for(index = 0; index < fs_numServerReferencedPaks; index++) { if(checksum == fs_serverReferencedPaks[index]) return qtrue; } - + return qfalse; } @@ -2215,7 +2215,7 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt temp = pathLength; if (pathLength) { - temp++; // include the '/' + temp++; // include the '/' } nfiles = FS_AddFileToList( name + temp, list, nfiles ); } @@ -2228,8 +2228,8 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt // don't scan directories for files if we are pure or restricted if ( fs_numServerPaks && !allowNonPureFilesOnDisk ) { - continue; - } else { + continue; + } else { netpath = FS_BuildOSPath( search->dir->path, search->dir->gamedir, path ); sysFiles = Sys_ListFiles( netpath, extension, filter, &numSysFiles, qfalse ); for ( i = 0 ; i < numSysFiles ; i++ ) { @@ -2239,7 +2239,7 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt } Sys_FreeFileList( sysFiles ); } - } + } } // return a copy of the list @@ -2804,7 +2804,7 @@ void FS_AddGameDirectory( const char *path, const char *dir ) { return; // we've already got this one } } - + Q_strncpyz( fs_gamedir, dir, sizeof( fs_gamedir ) ); // find all pak files in this directory @@ -2823,7 +2823,7 @@ void FS_AddGameDirectory( const char *path, const char *dir ) { Q_strncpyz(pak->pakPathname, curpath, sizeof(pak->pakPathname)); // store the game name for downloading Q_strncpyz(pak->pakGamename, dir, sizeof(pak->pakGamename)); - + fs_packFiles += pak->numfiles; search = Z_Malloc (sizeof(searchpath_t)); @@ -3098,14 +3098,14 @@ static void FS_Startup( const char *gameName ) FS_AddGameDirectory( fs_basepath->string, gameName ); } // fs_homepath is somewhat particular to *nix systems, only add if relevant - - #ifdef MACOS_X + +#ifdef MACOS_X fs_apppath = Cvar_Get ("fs_apppath", Sys_DefaultAppPath(), CVAR_INIT|CVAR_PROTECTED ); // Make MacOSX also include the base path included with the .app bundle if (fs_apppath->string[0]) FS_AddGameDirectory(fs_apppath->string, gameName); - #endif - +#endif + // NOTE: same filtering below for mods and basegame if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { FS_CreatePath ( fs_homepath->string ); @@ -3471,11 +3471,11 @@ void FS_PureServerSetReferencedPaks( const char *pakSums, const char *pakNames ) fs_serverReferencedPakNames[i] = CopyString( Cmd_Argv( i ) ); } } - + // ensure that there are as many checksums as there are pak names. if(d < c) c = d; - + fs_numServerReferencedPaks = c; } @@ -3577,8 +3577,8 @@ qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect) if(fs_gamedirvar->modified) { if(FS_FilenameCompare(lastValidGame, fs_gamedirvar->string) && - (*lastValidGame || FS_FilenameCompare(fs_gamedirvar->string, BASEGAME)) && - (*fs_gamedirvar->string || FS_FilenameCompare(lastValidGame, BASEGAME))) + (*lastValidGame || FS_FilenameCompare(fs_gamedirvar->string, BASEGAME)) && + (*fs_gamedirvar->string || FS_FilenameCompare(lastValidGame, BASEGAME))) { Com_GameRestart(checksumFeed, disconnect); return qtrue; @@ -3586,12 +3586,12 @@ qboolean FS_ConditionalRestart(int checksumFeed, qboolean disconnect) else fs_gamedirvar->modified = qfalse; } - + if(checksumFeed != fs_checksumFeed) FS_Restart(checksumFeed); else if(fs_numServerPaks && !fs_reordered) FS_ReorderPurePaks(); - + return qfalse; } @@ -3610,28 +3610,28 @@ int FS_FOpenFileByMode( const char *qpath, fileHandle_t *f, fsMode_t mode ) { sync = qfalse; switch( mode ) { - case FS_READ: - r = FS_FOpenFileRead( qpath, f, qtrue ); - break; - case FS_WRITE: - *f = FS_FOpenFileWrite( qpath ); - r = 0; - if (*f == 0) { - r = -1; - } - break; - case FS_APPEND_SYNC: - sync = qtrue; - case FS_APPEND: - *f = FS_FOpenFileAppend( qpath ); - r = 0; - if (*f == 0) { - r = -1; - } - break; - default: - Com_Error( ERR_FATAL, "FS_FOpenFileByMode: bad mode" ); - return -1; + case FS_READ: + r = FS_FOpenFileRead( qpath, f, qtrue ); + break; + case FS_WRITE: + *f = FS_FOpenFileWrite( qpath ); + r = 0; + if (*f == 0) { + r = -1; + } + break; + case FS_APPEND_SYNC: + sync = qtrue; + case FS_APPEND: + *f = FS_FOpenFileAppend( qpath ); + r = 0; + if (*f == 0) { + r = -1; + } + break; + default: + Com_Error( ERR_FATAL, "FS_FOpenFileByMode: bad mode" ); + return -1; } if (!f) { |