29 #include "../idlib/precompiled.h"
37 #if !__MACH__ && __MWERKS__
41 #include <sys/types.h>
48 #include "../curl/include/curl/curl.h"
174 #define DOOM3_PURE_SPECIAL_CASES
216 #if defined DOOM3_PURE_SPECIAL_CASES
242 for (
int i = 0; pureExclusions[
i].
func !=
NULL;
i++ ) {
243 if ( pureExclusions[
i].
name ) {
246 if ( pureExclusions[
i].ext ) {
255 #define MAX_ZIPPED_FILE_NAME 2048
256 #define FILE_HASH_SIZE 1024
311 #define FSFLAG_SEARCH_DIRS ( 1 << 0 )
312 #define FSFLAG_SEARCH_PAKS ( 1 << 1 )
313 #define FSFLAG_PURE_NOREF ( 1 << 2 )
314 #define FSFLAG_BINARY_ONLY ( 1 << 3 )
315 #define FSFLAG_SEARCH_ADDONS ( 1 << 4 )
319 #define MAX_CACHED_DIRS 6
322 #define MAX_GAME_OS 6
323 #define BINARY_CONFIG "binary.conf"
324 #define ADDON_CONFIG "addon.conf"
344 virtual void Init(
void );
347 virtual void Shutdown(
bool reloading );
352 virtual idFileList *
ListFiles(
const char *relativePath,
const char *extension,
bool sort =
false,
bool fullRelativePath =
false,
const char* gamedir =
NULL );
353 virtual idFileList *
ListFilesTree(
const char *relativePath,
const char *extension,
bool sort =
false,
const char* gamedir =
NULL );
357 virtual const char *
BuildOSPath(
const char *base,
const char *
game,
const char *relativePath );
359 virtual bool FileIsInPAK(
const char *relativePath );
364 virtual void SetRestartChecksums(
const int pureChecksums[ MAX_PURE_PAKS ],
int gamePakChecksum );
367 virtual int ReadFile(
const char *relativePath,
void **
buffer, ID_TIME_T *timestamp );
368 virtual void FreeFile(
void *buffer );
369 virtual int WriteFile(
const char *relativePath,
const void *buffer,
int size,
const char *basePath =
"fs_savepath" );
370 virtual void RemoveFile(
const char *relativePath );
372 virtual idFile *
OpenFileRead(
const char *relativePath,
bool allowCopyFiles =
true,
const char* gamedir =
NULL );
373 virtual idFile *
OpenFileWrite(
const char *relativePath,
const char *basePath =
"fs_savepath" );
374 virtual idFile *
OpenFileAppend(
const char *relativePath,
bool sync =
false,
const char *basePath =
"fs_basepath" );
383 virtual void FindDLL(
const char *basename,
char dllPath[
MAX_OSPATH ],
bool updateChecksum );
387 virtual void CopyFile(
const char *fromOSPath,
const char *toOSPath );
478 static size_t CurlWriteFunction(
void *ptr,
size_t size,
size_t nmemb,
void *stream );
480 static int CurlProgressFunction(
void *clientp,
double dltotal,
double dlnow,
double ultotal,
double ulnow );
535 while( fname[i] !=
'\0' ) {
537 if ( letter ==
'.' ) {
540 if ( letter ==
'\\' ) {
543 hash += (long)(letter) * (i+119);
564 if ( c1 >=
'a' && c1 <=
'z' ) {
567 if ( c2 >=
'a' && c2 <=
'z' ) {
571 if ( c1 ==
'\\' || c1 ==
':' ) {
574 if ( c2 ==
'\\' || c2 ==
':' ) {
602 if ( stat( fileName, &buf ) != -1 && !S_ISREG(buf.st_mode) ) {
607 fp = fopen( fileName, mode );
616 for ( i = 0; i < list.
Num(); i++ ) {
617 entry = fpath + PATHSEPERATOR_CHAR + list[
i];
618 if ( !entry.
Icmp( fileName ) ) {
619 fp = fopen( entry, mode );
621 if ( caseSensitiveName ) {
622 *caseSensitiveName = entry;
626 common->
Printf(
"idFileSystemLocal::OpenFileRead: changed %s to %s\n", fileName, entry.
c_str() );
631 common->
Warning(
"idFileSystemLocal::OpenFileRead: fs_caseSensitiveOS 1 could not open %s", entry.
c_str() );
635 }
else if ( caseSensitiveName ) {
636 *caseSensitiveName = fileName;
652 path += PATHSEPERATOR_STR;
686 if ( strstr( OSPath,
".." ) || strstr( OSPath,
"::" ) ) {
688 common->
DPrintf(
"refusing to create relative path \"%s\"\n", OSPath );
694 for( ofs = &path[ 1 ]; *ofs ; ofs++ ) {
695 if ( *ofs == PATHSEPERATOR_CHAR ) {
699 *ofs = PATHSEPERATOR_CHAR;
716 common->
Printf(
"copy %s to %s\n", fromOSPath, toOSPath );
726 if (
fread( buf, 1, len, f ) != (
unsigned int)len ) {
734 common->
Printf(
"could not create destination file\n" );
738 if (
fwrite( buf, 1, len, f ) != (
unsigned int)len ) {
761 if ( src->
Read( buf, len ) !=
len ) {
768 common->
Printf(
"could not create destination file\n" );
772 if (
fwrite( buf, 1, len, f ) != (
unsigned int)len ) {
789 for( s = &path[ 0 ]; *
s ; s++ ) {
790 if ( *s ==
'/' || *s ==
'\\' ) {
807 idStr testPath, fileName;
809 sprintf( testPath,
"%s/%s", game , relativePath );
814 common->
Warning(
"Non-portable: path contains uppercase characters: %s", testPath.
c_str() );
819 fileName = relativePath;
830 idStr strBase = base;
861 bool ignoreWarning =
false;
864 idStr tempStr = OSPath;
866 if ( ( strstr( tempStr,
"//" ) || strstr( tempStr,
"w:" ) ) && strstr( tempStr,
"/doom/base/") ) {
869 base = strstr( OSPath,
"base" );
870 ignoreWarning =
true;
877 if ( base > OSPath ) {
881 if ( ( c1 ==
'/' || c1 ==
'\\' ) && ( c2 ==
'/' || c2 ==
'\\' ) ) {
889 const char *fsgame =
NULL;
891 for ( igame = 0; igame < 2; igame++ ) {
894 }
else if ( igame == 1 ) {
897 if ( base ==
NULL && fsgame && strlen( fsgame ) ) {
898 base = (
char *)strstr( OSPath, fsgame );
901 if ( base > OSPath ) {
904 c2 = *( base + strlen( fsgame ) );
905 if ( ( c1 ==
'/' || c1 ==
'\\' ) && ( c2 ==
'/' || c2 ==
'\\' ) ) {
908 base = strstr( base + 1, fsgame );
914 s = strstr( base,
"/" );
916 s = strstr( base,
"\\" );
919 strcpy( relativePath, s + 1 );
921 common->
Printf(
"idFileSystem::OSPathToRelativePath: %s becomes %s\n", OSPath, relativePath );
927 if ( !ignoreWarning ) {
928 common->
Warning(
"idFileSystem::OSPathToRelativePath failed on %s", OSPath );
930 strcpy( relativePath,
"" );
983 if ( !relativePath ) {
984 common->
FatalError(
"idFileSystemLocal::FileIsInPAK: NULL 'relativePath' parameter passed\n" );
988 if ( relativePath[0] ==
'/' || relativePath[0] ==
'\\' ) {
995 if ( strstr( relativePath,
".." ) || strstr( relativePath,
"::" ) ) {
1025 pakFile = pakFile->
next;
1026 }
while( pakFile !=
NULL );
1051 if ( !relativePath || !relativePath[0] ) {
1056 *timestamp = FILE_NOT_FOUND_TIMESTAMP;
1067 if ( strstr( relativePath,
".cfg" ) == relativePath + strlen( relativePath ) - 4 ) {
1075 common->
DPrintf(
"Loading %s from journal file.\n", relativePath );
1078 if ( r !=
sizeof( len ) ) {
1123 f->
Read( buf, len );
1131 common->
DPrintf(
"Writing %s to journal file.\n", relativePath );
1171 if ( !relativePath || !buffer ) {
1181 size = f->
Write( buffer, size );
1201 src.
Warning(
"ParseAddonDef: no addonDef" );
1215 if ( !token.
Icmp(
"}" ) ) {
1219 src.
Warning(
"Expected quoted string, but found '%s'", token.
c_str() );
1224 if ( sscanf( token.
c_str(),
"0x%x", &checksum ) != 1 && sscanf( token.
c_str(),
"%x", &checksum ) != 1 ) {
1225 src.
Warning(
"Could not parse checksum '%s'", token.
c_str() );
1237 src.
Warning(
"Expected map path" );
1243 dict->
Set(
"path", token.
c_str() );
1255 if ( !token.
Icmp(
"}" ) ) {
1259 src.
Warning(
"Expected quoted string, but found '%s'", token.
c_str() );
1267 src.
Warning(
"Unexpected end of file" );
1274 if ( dict->
FindKey( token ) ) {
1277 dict->
Set( token, token2 );
1300 int fs_numHeaderLongs;
1301 int * fs_headerLongs;
1315 fs_numHeaderLongs = 0;
1336 pack->
addon =
false;
1340 pack->
isNew =
false;
1352 fs_headerLongs[fs_numHeaderLongs++] =
LittleLong( file_info.
crc );
1355 buildBuffer[
i].
name = filename_inzip;
1368 pack->
addon =
false;
1370 for ( pakFile = pack->
hashTable[confHash]; pakFile; pakFile = pakFile->
next ) {
1375 if ( file && file->
Length() ) {
1377 buf =
new char[ file->
Length() + 1 ];
1379 buf[ file->
Length() ] =
'\0';
1423 while ( last->
next ) {
1426 last->
next = search;
1440 for ( i = hashIndex.
First( hashKey ); i >= 0; i = hashIndex.
Next( i ) ) {
1441 if ( list[i].Icmp( name ) == 0 ) {
1446 hashIndex.
Add( hashKey, i );
1494 if ( !extensions.
Num() ) {
1498 if ( !relativePath ) {
1501 pathLength = strlen( relativePath );
1508 if ( search->
dir ) {
1509 if(gamedir && strlen(gamedir)) {
1520 for ( i = 0; i < extensions.
Num(); i++ ) {
1526 if ( extensions[i][0] ==
'/' && extensions[i][1] == 0 ) {
1531 for( j = 0; j < sysFiles.
Num(); j++ ) {
1533 if ( fullRelativePath ) {
1534 work = relativePath;
1536 work += sysFiles[
j];
1540 AddUnique( sysFiles[j], list, hashIndex );
1544 }
else if ( search->
pack ) {
1557 for( i = 0; i < pak->
numfiles; i++ ) {
1562 if ( length <= pathLength ) {
1566 name = buildBuffer[
i].
name;
1570 if ( pathLength &&
idStr::Icmpn( name, relativePath, pathLength - 1 ) != 0 ) {
1575 if ( name[ pathLength ] ==
'\0' || name[pathLength - 1] !=
'/' ) {
1580 for ( j = pathLength; name[j+1] !=
'\0'; j++ ) {
1581 if ( name[j] ==
'/' ) {
1590 for ( j = 0; j < extensions.
Num(); j++ ) {
1591 if ( length >= extensions[j].Length() && extensions[
j].Icmp( name + length - extensions[j].Length() ) == 0 ) {
1595 if ( j >= extensions.
Num() ) {
1600 if ( fullRelativePath ) {
1601 work = relativePath;
1603 work += name + pathLength;
1607 work = name + pathLength;
1632 GetFileList( relativePath, extensionList, fileList->
list, hashIndex, fullRelativePath, gamedir );
1653 GetFileList( relativePath, slash, folders, folderHashIndex,
true, gamedir );
1654 for ( i = 0; i < folders.
Num(); i++ ) {
1655 if ( folders[i][0] ==
'.' ) {
1658 if ( folders[i].Icmp( relativePath ) == 0 ){
1665 GetFileList( relativePath, extensions, list, hashIndex,
true, gamedir );
1710 const int MAX_DESCRIPTION = 256;
1711 char desc[ MAX_DESCRIPTION ];
1718 const char *search[ 4 ];
1726 for ( isearch = 0; isearch < 4; isearch++ ) {
1740 for( i = 0; i < dirs.
Num(); i++ ) {
1744 if ( !list->
mods.
Find( dirs[ i ] ) ) {
1746 if ( dirs[ i ].Icmp(
"d3xp" ) ||
HasD3XP() ) {
1757 for ( i = 0; i < list->
mods.
Num(); i++ ) {
1759 for ( isearch = 0; isearch < 4; isearch++ ) {
1764 if ( fgets( desc, MAX_DESCRIPTION, f ) ) {
1776 if ( isearch == 4 ) {
1855 if (
dir_cache[j].Matches( directory, extension ) ) {
1896 if ( args.
Argc() < 2 || args.
Argc() > 3 ) {
1897 common->
Printf(
"usage: dir <directory> [extension]\n" );
1901 if ( args.
Argc() == 2 ) {
1902 relativePath = args.
Argv( 1 );
1906 relativePath = args.
Argv( 1 );
1907 extension = args.
Argv( 2 );
1908 if ( extension[0] !=
'.' ) {
1918 fileList = fileSystemLocal.
ListFiles( relativePath, extension );
1939 if ( args.
Argc() < 2 || args.
Argc() > 3 ) {
1940 common->
Printf(
"usage: dirtree <directory> [extension]\n" );
1944 if ( args.
Argc() == 2 ) {
1945 relativePath = args.
Argv( 1 );
1949 relativePath = args.
Argv( 1 );
1950 extension = args.
Argv( 2 );
1951 if ( extension[0] !=
'.' ) {
1961 fileList = fileSystemLocal.
ListFilesTree( relativePath, extension );
1987 status +=
" - addon)\n";
2055 if ( args.
Argc() != 2 ) {
2075 if ( args.
Argc() != 2 ) {
2117 if ( !search->
dir ) {
2141 pakfile[ pakfile.
Length() - 1 ] = 0;
2149 for ( i = 0; i < pakfiles.
Num(); i++ ) {
2205 for ( i = 0; i <
num; i++ ) {
2212 if ( addon_index >= 0 ) {
2216 common->
Printf(
"Addon pk4 %s 0x%x depends on pak %s 0x%x, will be searched\n",
2222 common->
Printf(
"Addon pk4 %s 0x%x depends on unknown pak 0x%x\n",
2239 common->
Printf(
"------ Initializing File System ------\n" );
2267 if ( !( *search )->pack || !( *search )->pack->addon ) {
2268 search = &( ( *search )->next );
2271 pak = ( *search )->pack;
2276 search = &( ( *search )->next );
2280 if ( addon_index >= 0 ) {
2286 search = &( ( *search )->next );
2292 if ( !( *search )->pack || !( *search )->pack->addon ) {
2293 search = &( ( *search )->next );
2296 assert( !( *search )->dir );
2297 pak = ( *search )->pack;
2299 common->
Printf(
"Addon pk4 %s with checksum 0x%x is on the search list\n",
2301 search = &( ( *search )->next );
2305 *search = ( *search )->
next;
2308 common->
Printf(
"Addon pk4 %s with checksum 0x%x is on addon list\n",
2320 if ( !( *search )->pack ) {
2321 search = &( ( *search )->next );
2332 search = &( ( *search )->next );
2337 aux = ( *search )->
next;
2341 common->
Printf(
"found pure checksum %x at index %d, but the end of search path is reached\n", ( *search )->pack->checksum, i );
2354 common->
FatalError(
"Failed to restart with pure mode restrictions for server connect" );
2358 search_end = ( *search )->
next;
2359 while ( search_end->
next ) {
2360 search_end = search_end->
next;
2362 search_end->
next = *search;
2363 *search = ( *search )->
next;
2369 search = &( ( *search )->next );
2386 common->
FatalError(
"Failed to restart with pure mode restrictions for server connect" );
2404 common->
Printf(
"--------------------------------------\n" );
2416 #ifdef ID_DEMO_BUILD
2417 common->
Printf(
"\nRunning in restricted demo mode.\n\n" );
2421 if ( search->
pack ) {
2445 if ( !search->
pack ) {
2488 if ( !search->
pack ) {
2492 for ( pakFile = search->
pack->
hashTable[confHash]; pakFile; pakFile = pakFile->
next ) {
2496 buf =
new char[ confFile->
Length() + 1 ];
2497 confFile->
Read( (
void *)buf, confFile->
Length() );
2498 buf[ confFile->
Length() ] =
'\0';
2500 while ( lexConf->
ReadToken( &token ) ) {
2521 common->
Warning(
"No game code pak reference found for the local OS" );
2527 common->
Warning(
"The current game code doesn't match pak files (net_serverAllowServerMod is off)" );
2542 if ( !search->
pack ) {
2546 return search->
pack;
2549 if ( searchAddons ) {
2553 return search->
pack;
2581 if ( strstr( name.
c_str(),
"pak" ) == name.
c_str() ) {
2589 if ( isBinary != pakBinary ) {
2599 for ( i = 0; i < testList.
Num(); i ++ ) {
2600 if ( testList[ i ].Length() && !testList[
i ].Icmpn( pak->
pakFilename, testList[ i ].Length() ) ) {
2605 if ( i == testList.
Num() ) {
2641 bool success =
true;
2642 bool canPrepend =
true;
2651 missingChecksums[ 0 ] = 0;
2652 assert( missingGamePakChecksum );
2653 *missingGamePakChecksum = 0;
2655 if ( pureChecksums[ 0 ] == 0 ) {
2665 while ( pureChecksums[ i ] ) {
2679 if ( pack && pack->
isNew ) {
2710 missingChecksums[ imissing++ ] = pureChecksums[
i ];
2711 missingChecksums[ imissing ] = 0;
2713 common->
Printf(
"checksum not found - 0x%x\n", pureChecksums[ i ] );
2722 common->
Printf(
"pak %s checksumed 0x%x is an extra reference at the end of local pure list\n",
serverPaks[ j ]->pakFilename.c_str(),
serverPaks[
j ]->checksum );
2728 if ( !_gamePakChecksum ) {
2742 common->
Printf(
"missing the game code pak ( 0x%x )\n", _gamePakChecksum );
2745 *missingGamePakChecksum = _gamePakChecksum;
2758 for ( pakFile = pack->
hashTable[ dllHash ]; pakFile; pakFile = pakFile->
next ) {
2778 common->
Printf(
"SetPureServerChecksums: there are files loaded from dir\n" );
2796 if ( _gamePakChecksum ) {
2816 while ( pureChecksums[ i ] ) {
2819 common->
FatalError(
"SetRestartChecksums failed: no pak for checksum 0x%x\n", pureChecksums[i] );
2946 for ( sp = loop;
sp; sp = next ) {
3005 if ( !
strcmp( path + l - 4,
".cfg" )
3006 || !
strcmp( path + l - 4,
".dat" )
3007 || !
strcmp( path + l - 4,
".dll" )
3008 || !
strcmp( path + l - 3,
".so" )
3009 || ( l > 6 && !
strcmp( path + l - 6,
".dylib" ) )
3010 || ( l > 10 && !
strcmp( path + l - 10,
".scriptcfg" ) )
3012 || !
strcmp( path + l - 4,
".dds" )
3019 if ( strstr( path,
"savegames" ) == path &&
3020 ( !
strcmp( path + l - 4,
".tga" ) || !
strcmp( path + l -4,
".txt" ) || !
strcmp( path + l - 5,
".save" ) ) ) {
3024 if ( strstr( path,
"screenshots" ) == path && !
strcmp( path + l - 4,
".tga" ) ) {
3028 if ( strstr( path,
"maps/game" ) == path &&
3029 !
strcmp( path + l - 4,
".tga" ) ) {
3033 if ( strstr( path,
"guis/assets/splash/addon" ) == path &&
3034 !
strcmp( path + l -4,
".tga" ) ) {
3047 int i,
l, hashindex;
3065 for (
int j = 0; pureExclusions[
j].
func !=
NULL;
j++ ) {
3066 if ( pureExclusions[
j].func( pureExclusions[
j], l, file->
name ) ) {
3110 if ( file->
z ==
NULL ) {
3113 file->
name = relativePath;
3154 if ( !relativePath ) {
3155 common->
FatalError(
"idFileSystemLocal::OpenFileRead: NULL 'relativePath' parameter passed\n" );
3163 if ( relativePath[0] ==
'/' || relativePath[0] ==
'\\' ) {
3170 if ( strstr( relativePath,
".." ) || strstr( relativePath,
"::" ) ) {
3175 if ( relativePath[0] ==
'\0' ) {
3205 if(gamedir && strlen(gamedir)) {
3219 file->
name = relativePath;
3229 common->
FatalError(
"'%s' loaded from directory: Failed to restart with pure mode restrictions for server connect", relativePath );
3231 common->
DPrintf(
"filesystem: switching to pure mode will require a restart. '%s' loaded from directory.\n", relativePath );
3243 copypath += PATHSEPERATOR_STR;
3253 if ( isFromCDPath ) {
3259 if ( isFromCDPath ) {
3261 }
else if ( isFromSavePath || isFromBasePath ) {
3280 if ( isFromCDPath || isFromBasePath ) {
3285 if ( isFromCDPath && !isFromBasePath ) {
3317 for ( pakFile = search->
pack->
hashTable[confHash]; pakFile; pakFile = pakFile->
next ) {
3329 for ( pakFile = pak->
hashTable[hash]; pakFile; pakFile = pakFile->
next ) {
3360 for ( pakFile = pak->
hashTable[hash]; pakFile; pakFile = pakFile->
next ) {
3430 f->
name = relativePath;
3452 common->
Printf(
"idFileSystem::OpenExplicitFileRead: %s\n", OSPath );
3455 common->
DPrintf(
"idFileSystem::OpenExplicitFileRead - reading from: %s\n", OSPath );
3485 common->
Printf(
"idFileSystem::OpenExplicitFileWrite: %s\n", OSPath );
3538 f->
name = relativePath;
3595 return size * nmemb;
3598 return _write( static_cast<idFile_Permanent*>(bgl->
f)->GetFilePtr()->_file, ptr, size * nmemb );
3600 return fwrite( ptr, size, nmemb, static_cast<idFile_Permanent*>(bgl->
f)->GetFilePtr() );
3644 _read( static_cast<idFile_Permanent*>(bgl->
f)->GetFilePtr()->_file, bgl->
file.
buffer, bgl->
file.
length );
3724 Sys_Printf(
"curl_easy_perform failed: %s\n", error_buf );
3751 common->
Warning(
"idFileSystemLocal::StartBackgroundDownloadThread: failed" );
3754 common->
Printf(
"background thread already running\n" );
3765 if ( dynamic_cast<idFile_Permanent *>(bgl->
f) ) {
3811 for ( pakFile = pak->
hashTable[ hash ]; pakFile; pakFile = pakFile->
next ) {
3833 common->
Printf(
"no pak file found for '%s' checksumed %x\n", relativePath, findChecksum );
3851 if ( file->
Read( buf, len ) !=
len ) {
3852 common->
FatalError(
"Short read in idFileSystemLocal::GetFileChecksum()\n" );
3898 common->
Error(
"DLL extraction to fs_savepath failed\n" );
3899 }
else if ( updateChecksum ) {
3902 updateChecksum =
false;
3908 if ( updateChecksum ) {
3913 updateChecksum =
false;
3921 assert( updateChecksum );
3928 for ( pakFile = pak->
hashTable[dllHash]; pakFile; pakFile = pakFile->
next ) {
3937 common->
Error(
"DLL extraction to fs_savepath failed\n" );
3940 updateChecksum =
false;
3947 if ( updateChecksum ) {
3992 }
else if (
d3xp == 1 ) {
4000 for ( i = 0; i < dirs.
Num(); i++ ) {
4001 if ( dirs[i].Icmp(
"d3xp" ) == 0 ) {
4014 const char *search[4];
4020 for ( i = 0; i < 4; i++ ) {
4034 for ( i = 0; i < dirs.
Num(); i++ ) {
4035 if ( dirs[i].Icmp(
"d3xp" ) == 0 ) {
4072 FILE *
f = tmpfile();
4074 common->
Warning(
"idFileSystem::MakeTemporaryFile failed: %s", strerror( errno ) );
4079 file->
name =
"<tempfile>";
4126 for ( i = 0; i < 2; i++ ) {
4129 }
else if ( i == 1 ) {
4132 for ( ; search ; search = search->
next ) {
4155 if ( idecl < numdecls ) {
4159 common->
Error(
"idFileSystemLocal::GetMapDecl %d: not found\n", idecl );
4166 for ( i = 0; i < 2; i++ ) {
4169 }
else if ( i == 1 ) {
4172 for ( ; search ; search = search->
next ) {
4177 if ( idecl < search->pack->addon_info->mapDecls.Num() ) {
4206 int dlen = file->
Length();
4207 char *
data =
new char[ dlen ];
4208 file->
Read( data, dlen );
void Sys_Mkdir(const char *path)
bool excludeExtension(const pureExclusion_t &excl, int l, const idStr &name)
static idCVar fs_caseSensitiveOS
pack_t * FindPakForFileChecksum(const char *relativePath, int fileChecksum, bool bReference)
static int snPrintf(char *dest, int size, const char *fmt,...) id_attribute((format(printf
struct searchpath_s searchpath_t
static idCVar fs_restrict
int gamePakForOS[MAX_GAME_OS]
virtual void UpdatePureServerChecksums(void)
assert(prefInfo.fullscreenBtn)
virtual idFile * OpenFileByMode(const char *relativePath, fsMode_t mode)
bool(* pureExclusionFunc_t)(const struct pureExclusion_s &excl, int l, const idStr &name)
virtual void ResetReadCount(void)
virtual void FreeModList(idModList *modList)
int Cmp(const char *text) const
idCVarSystem * cvarSystem
virtual idFileList * ListFilesTree(const char *relativePath, const char *extension, bool sort=false, const char *gamedir=NULL)
const char * Sys_DefaultSavePath(void)
int unzClose(unzFile file)
int Next(const int index) const
virtual idFile * MakeTemporaryFile(void)
const int DECL_LEXER_FLAGS
virtual void ClearDirCache(void)
idList< idStr > & operator=(const idList< idStr > &other)
int GetFileList(const char *relativePath, const idStrList &extensions, idStrList &list, idHashIndex &hashIndex, bool fullRelativePath, const char *gamedir=NULL)
int ListOSFiles(const char *directory, const char *extension, idStrList &list)
virtual idFile * OpenFileAppend(const char *relativePath, bool sync=false, const char *basePath="fs_basepath")
virtual bool UpdateGamePakChecksums(void)
virtual const char * BuildOSPath(const char *base, const char *game, const char *relativePath)
virtual int ReadFile(const char *relativePath, void **buffer, ID_TIME_T *timestamp=NULL)=0
unzFile unzOpen(const char *path)
virtual void RemoveFile(const char *relativePath)
virtual void SetRestartChecksums(const int pureChecksums[MAX_PURE_PAKS], int gamePakChecksum)
virtual void FreeFileList(idFileList *fileList)
char dlerror[MAX_STRING_CHARS]
int GetNumFiles(void) const
void Init(const char *directory, const char *extension, const idStrList &list)
static idCVar fs_savepath
int DirectFileLength(FILE *o)
virtual idFile * OpenExplicitFileRead(const char *OSPath)
virtual void ClearPureChecksums(void)
void Sys_Printf(const char *msg,...)
fileInPack_t * hashTable[FILE_HASH_SIZE]
struct searchpath_s * next
virtual int WriteFile(const char *relativePath, const void *buffer, int size, const char *basePath="fs_savepath")
void StripTrailing(const char c)
void GetExtensionList(const char *extension, idStrList &extensionList) const
bool FileAllowedFromDir(const char *path)
virtual idModList * ListMods(void)
idFileSystem * fileSystem
idCVar com_developer("developer","0", CVAR_BOOL|CVAR_SYSTEM|CVAR_NOCHEAT,"developer mode")
void SetGranularity(int newgranularity)
virtual findFile_t FindFile(const char *path, bool scheduleAddons)
int unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info)
CURLcode curl_easy_perform(CURL *curl)
#define FSFLAG_BINARY_ONLY
virtual void GetPureServerChecksums(int checksums[MAX_PURE_PAKS], int OS, int *gamePakChecksum)
const char * GetName(void) const
int unzSetCurrentFileInfoPosition(unzFile file, unsigned long pos)
bool excludeFullName(const pureExclusion_t &excl, int l, const idStr &name)
virtual void RemoveCommand(const char *cmdName)=0
int AddUnique(const char *name, idStrList &list, idHashIndex &hashIndex) const
int LoadMemory(const char *ptr, int length, const char *name)
virtual const idDict * GetMapDecl(int i)
void Set(const char *key, const char *value)
static size_t CurlWriteFunction(void *ptr, size_t size, size_t nmemb, void *stream)
CURLcode curl_easy_setopt(CURL *curl, CURLoption option,...)
virtual bool FilenameCompare(const char *s1, const char *s2) const
bool excludePathPrefixAndExtension(const pureExclusion_t &excl, int l, const idStr &name)
virtual const char * GetName(void)
int unzGoToNextFile(unzFile file)
virtual idFile * OpenFileReadFlags(const char *relativePath, int searchFlags, pack_t **foundInPak=NULL, bool allowCopyFiles=true, const char *gamedir=NULL)
int Icmp(const char *text) const
idStr & BackSlashesToSlashes(void)
int First(const int key) const
int restartGamePakChecksum
long Sys_FileTimeStamp(FILE *fp)
static idCVar fs_game_base
int Icmpn(const char *text, int n) const
bool Matches(const char *directory, const char *extension) const
int ReadToken(idToken *token)
void SetupGameDirectories(const char *gameName)
void Sort(cmp_t *compare=(cmp_t *)&idListSortCompare< type >)
int Sys_ListFiles(const char *directory, const char *extension, idStrList &list)
virtual void Shutdown(bool reloading)
void ExtractFileName(idStr &dest) const
int unzOpenCurrentFile(unzFile file)
virtual idFile * OpenFileRead(const char *relativePath, bool allowCopyFiles=true, const char *gamedir=NULL)
#define FSFLAG_SEARCH_DIRS
addonInfo_t * ParseAddonDef(const char *buf, const int len)
void SetString(const char *value)
virtual const char * RelativePathToOSPath(const char *relativePath, const char *basePath)
pack_t * LoadZipFile(const char *zipfile)
virtual int ValidateDownloadPakForChecksum(int checksum, char path[MAX_STRING_CHARS], bool isBinary)
static int CurlProgressFunction(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
static void Path_f(const idCmdArgs &args)
idStr & StripFileExtension(void)
static void Dir_f(const idCmdArgs &args)
long HashFileName(const char *fname) const
struct backgroundDownload_s * next
unsigned long uncompressed_size
idFile_InZip * ReadFileFromZip(pack_t *pak, fileInPack_t *pakFile, const char *relativePath)
virtual void virtual void virtual void DWarning(const char *fmt,...) id_attribute((format(printf
struct fileInPack_s * next
virtual const char * GetCVarString(const char *name) const =0
searchpath_t * searchPaths
GLsizei GLsizei GLenum GLenum const GLvoid * data
virtual void SetCVarBool(const char *name, const bool value, int flags=0)=0
int GetInteger(void) const
virtual void AddToReadCount(int c)
virtual void CreateOSPath(const char *OSPath)
virtual bool FileIsInPAK(const char *relativePath)
FILE * OpenOSFile(const char *name, const char *mode, idStr *caseSensitiveName=NULL)
virtual void virtual void FatalError(const char *fmt,...) id_attribute((format(printf
const char * GetFile(int index) const
virtual int Read(void *buffer, int len)
static void Copynz(char *dest, const char *src, int destsize)
#define FSFLAG_SEARCH_ADDONS
unz_file_info cur_file_info
idDEntry dir_cache[MAX_CACHED_DIRS]
virtual void FreeFile(void *buffer)
dword BackgroundDownloadThread(void *parms)
backgroundDownload_t * backgroundDownloads
type * Find(type const &obj) const
virtual bool HasD3XP(void)
virtual void StartBackgroundDownloadThread(void)
void DeleteContents(bool clear)
unsigned long MD4_BlockChecksum(const void *data, int length)
virtual bool RunningD3XP(void)
xthreadInfo * g_threads[MAX_THREADS]
struct fileInPack_s fileInPack_t
unsigned int(* xthread_t)(void *)
const idKeyValue * FindKey(const char *key) const
virtual void UpdateScreen(bool outOfSequence=true)=0
virtual idFileList * ListFiles(const char *relativePath, const char *extension, bool sort=false, bool fullRelativePath=false, const char *gamedir=NULL)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
int LoadMemory(const char *ptr, int length, const char *name, int startLine=1)
void AppendPath(const char *text)
virtual int Seek(long offset, fsOrigin_t origin)
virtual ID_TIME_T Timestamp(void)
virtual void StartupVariable(const char *match, bool once)=0
idList< pack_t * > serverPaks
idDeclManager * declManager
int GenerateKey(const char *string, bool caseSensitive=true) const
virtual int ReadFile(const char *relativePath, void **buffer, ID_TIME_T *timestamp)
struct pureExclusion_s pureExclusion_t
ID_INLINE void idStrListSortPaths(idStrList &list)
virtual const char * OSPathToRelativePath(const char *OSPath)
virtual int GetNumDecls(declType_t type)=0
virtual void Restart(void)
xthreadInfo backgroundThread
const char * GetString(void) const
bool IsNumeric(void) const
friend dword BackgroundDownloadThread(void *parms)
static int FindChar(const char *str, const char c, int start=0, int end=-1)
int Insert(const type &obj, int index=0)
void ReplaceSeparators(idStr &path, char sep=PATHSEPERATOR_CHAR)
int Append(const type &obj)
void void Warning(const char *str,...) id_attribute((format(printf
GLdouble GLdouble GLdouble r
virtual int GetReadCount(void)
int unzGetCurrentFileInfoPosition(unzFile file, unsigned long *pos)
idList< int > restartChecksums
int unzGoToFirstFile(unzFile file)
idList< int > addonChecksums
unzFile unzReOpen(const char *path, unzFile file)
static WindowRef ValidModeCallbackProc inCallback OSStatus err
static void TouchFile_f(const idCmdArgs &args)
virtual void FindDLL(const char *basename, char dllPath[MAX_OSPATH], bool updateChecksum)
static idCVar fs_searchAddons
idList< idDict * > mapDecls
unsigned long number_entry
backgroundDownload_t defaultBackgroundDownload
static idCVar fs_copyfiles
virtual const idDecl * DeclByIndex(declType_t type, int index, bool forceParse=true)=0
int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
static void ArgCompletion_FileName(const idCmdArgs &args, void(*callback)(const char *s))
const char * Sys_DefaultCDPath(void)
virtual int GetOSMask(void)
void Sys_TriggerEvent(int index)
virtual void BackgroundDownload(backgroundDownload_t *bgl)
bool RemoveIndex(int index)
virtual void DLL_GetFileName(const char *baseName, char *dllName, int maxLength)=0
virtual int AddZipFile(const char *path)
#define DEMO_PAK_CHECKSUM
virtual int Write(const void *buffer, int len)
#define FSFLAG_PURE_NOREF
idFile * com_journalDataFile
static void DirTree_f(const idCmdArgs &args)
virtual bool PerformingCopyFiles(void) const
GLsizei const GLcharARB const GLint * length
void AddGameDirectory(const char *path, const char *dir)
virtual idFile * OpenExplicitFileWrite(const char *OSPath)
virtual void FindMapScreenshot(const char *path, char *buf, int len)
void * Mem_ClearedAlloc(const int size)
const char * c_str(void) const
int SkipUntilString(const char *string)
int JournalLevel(void) const
virtual bool IsInitialized(void) const
int FindIndex(const type &obj) const
virtual bool GetCVarBool(const char *name) const =0
int GetFileChecksum(idFile *file)
const char * Argv(int arg) const
void Add(const int key, const int index)
int IcmpPrefixPath(const char *text) const
idFileSystemLocal fileSystemLocal
void * Mem_Alloc(const int size)
static idCVar fs_basepath
virtual bool IsInitialized(void) const =0
char * va(const char *fmt,...)
virtual void CopyFile(const char *fromOSPath, const char *toOSPath)
virtual int Read(void *buffer, int len)
virtual void DPrintf(const char *fmt,...) id_attribute((format(printf
bool HasUpper(void) const
virtual void Error(const char *fmt,...) id_attribute((format(printf
virtual fsPureReply_t SetPureServerChecksums(const int pureChecksums[MAX_PURE_PAKS], int gamePakChecksum, int missingChecksums[MAX_PURE_PAKS], int *missingGamePakChecksum)
void FollowAddonDependencies(pack_t *pak)
FILE * OpenOSFileCorrectName(idStr &path, const char *mode)
pureStatus_t GetPackStatus(pack_t *pak)
int GetFileListTree(const char *relativePath, const idStrList &extensions, idStrList &list, idHashIndex &hashIndex, const char *gamedir=NULL)
virtual idFile * OpenFileWrite(const char *relativePath, const char *basePath="fs_savepath")
void SetRestrictions(void)
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
#define CURLOPT_WRITEDATA
static void TouchFileList_f(const idCmdArgs &args)
void Sys_LeaveCriticalSection(int index)
void Sys_EnterCriticalSection(int index)
int ReadToken(idToken *token)
int sprintf(idStr &string, const char *fmt,...)
fileInPack_t * buildBuffer
pack_t * GetPackForChecksum(int checksum, bool searchAddons=false)
idStr & StripFilename(void)
virtual void CloseFile(idFile *f)
void Sys_WaitForEvent(int index)
bool Remove(const type &obj)
virtual const char * GetFullPath(void)
const char * Sys_EXEPath(void)
#define FSFLAG_SEARCH_PAKS
virtual void AddCommand(const char *cmdName, cmdFunction_t function, int flags, const char *description, argCompletion_t argCompletion=NULL)=0
CURL * curl_easy_init(void)
void Sys_CreateThread(xthread_t function, void *parms, xthreadPriority priority, xthreadInfo &info, const char *name, xthreadInfo **threads, int *thread_count)
const char * Sys_DefaultBasePath(void)
#define MAX_ZIPPED_FILE_NAME