vkQuake2 doxygen  1.0 dev
files.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 */
20 
21 #include "qcommon.h"
22 
23 // define this to dissalow any data but the demo pak file
24 //#define NO_ADDONS
25 
26 // if a packfile directory differs from this, it is assumed to be hacked
27 // Full version
28 #define PAK0_CHECKSUM 0x40e614e0
29 // Demo
30 //#define PAK0_CHECKSUM 0xb2c6d7ea
31 // OEM
32 //#define PAK0_CHECKSUM 0x78e135c
33 
34 /*
35 =============================================================================
36 
37 QUAKE FILESYSTEM
38 
39 =============================================================================
40 */
41 
42 
43 //
44 // in memory
45 //
46 
47 typedef struct
48 {
49  char name[MAX_QPATH];
50  int filepos, filelen;
51 } packfile_t;
52 
53 typedef struct pack_s
54 {
56  FILE *handle;
57  int numfiles;
59 } pack_t;
60 
65 
66 typedef struct filelink_s
67 {
68  struct filelink_s *next;
69  char *from;
71  char *to;
72 } filelink_t;
73 
75 
76 typedef struct searchpath_s
77 {
79  pack_t *pack; // only one of filename / pack will be used
80  struct searchpath_s *next;
81 } searchpath_t;
82 
84 searchpath_t *fs_base_searchpaths; // without gamedirs
85 
86 
87 /*
88 
89 All of Quake's data access is through a hierchal file system, but the contents of the file system can be transparently merged from several sources.
90 
91 The "base directory" is the path to the directory holding the quake.exe and all game directories. The sys_* files pass this to host_init in quakeparms_t->basedir. This can be overridden with the "-basedir" command line parm to allow code debugging in a different directory. The base directory is
92 only used during filesystem initialization.
93 
94 The "game directory" is the first tree on the search path and directory that all generated files (savegames, screenshots, demos, config files) will be saved to. This can be overridden with the "-game" command line parameter. The game directory can never be changed while quake is executing. This is a precacution against having a malicious server instruct clients to write files over areas they shouldn't.
95 
96 */
97 
98 
99 /*
100 ================
101 FS_filelength
102 ================
103 */
104 int FS_filelength (FILE *f)
105 {
106  int pos;
107  int end;
108 
109  pos = ftell (f);
110  fseek (f, 0, SEEK_END);
111  end = ftell (f);
112  fseek (f, pos, SEEK_SET);
113 
114  return end;
115 }
116 
117 
118 /*
119 ============
120 FS_CreatePath
121 
122 Creates any directories needed to store the given filename
123 ============
124 */
125 void FS_CreatePath (char *path)
126 {
127  char *ofs;
128 
129  for (ofs = path+1 ; *ofs ; ofs++)
130  {
131  if (*ofs == '/')
132  { // create the directory
133  *ofs = 0;
134  Sys_Mkdir (path);
135  *ofs = '/';
136  }
137  }
138 }
139 
140 
141 /*
142 ==============
143 FS_FCloseFile
144 
145 For some reason, other dll's can't just cal fclose()
146 on files returned by FS_FOpenFile...
147 ==============
148 */
149 void FS_FCloseFile (FILE *f)
150 {
151  fclose (f);
152 }
153 
154 
155 // RAFAEL
156 /*
157  Developer_searchpath
158 */
159 int Developer_searchpath (int who)
160 {
161 
162  int ch;
163  // PMM - warning removal
164 // char *start;
165  searchpath_t *search;
166 
167  if (who == 1) // xatrix
168  ch = 'x';
169  else if (who == 2)
170  ch = 'r';
171 
172  for (search = fs_searchpaths ; search ; search = search->next)
173  {
174  if (strstr (search->filename, "xatrix"))
175  return 1;
176 
177  if (strstr (search->filename, "rogue"))
178  return 2;
179 /*
180  start = strchr (search->filename, ch);
181 
182  if (start == NULL)
183  continue;
184 
185  if (strcmp (start ,"xatrix") == 0)
186  return (1);
187 */
188  }
189  return (0);
190 
191 }
192 
193 
194 /*
195 ===========
196 FS_FOpenFile
197 
198 Finds the file in the search path.
199 returns filesize and an open FILE *
200 Used for streaming data out of either a pak file or
201 a seperate file.
202 ===========
203 */
205 #ifndef NO_ADDONS
206 int FS_FOpenFile (char *filename, FILE **file)
207 {
208  searchpath_t *search;
209  char netpath[MAX_OSPATH];
210  pack_t *pak;
211  int i;
212  filelink_t *link;
213 
214  file_from_pak = 0;
215 
216  // check for links first
217  for (link = fs_links ; link ; link=link->next)
218  {
219  if (!strncmp (filename, link->from, link->fromlength))
220  {
221  Com_sprintf (netpath, sizeof(netpath), "%s%s",link->to, filename+link->fromlength);
222  *file = fopen (netpath, "rb");
223  if (*file)
224  {
225  Com_DPrintf ("link file: %s\n",netpath);
226  return FS_filelength (*file);
227  }
228  return -1;
229  }
230  }
231 
232 //
233 // search through the path, one element at a time
234 //
235  for (search = fs_searchpaths ; search ; search = search->next)
236  {
237  // is the element a pak file?
238  if (search->pack)
239  {
240  // look through all the pak file elements
241  pak = search->pack;
242  for (i=0 ; i<pak->numfiles ; i++)
243  if (!Q_strcasecmp (pak->files[i].name, filename))
244  { // found it!
245  file_from_pak = 1;
246  Com_DPrintf ("PackFile: %s : %s\n",pak->filename, filename);
247  // open a new file on the pakfile
248  *file = fopen (pak->filename, "rb");
249  if (!*file)
250  Com_Error (ERR_FATAL, "Couldn't reopen %s", pak->filename);
251  fseek (*file, pak->files[i].filepos, SEEK_SET);
252  return pak->files[i].filelen;
253  }
254  }
255  else
256  {
257  // check a file in the directory tree
258 
259  Com_sprintf (netpath, sizeof(netpath), "%s/%s",search->filename, filename);
260 #ifndef _WIN32
261  // some expansion packs use backslashes in file paths which works only on Windows
262  char *np = netpath;
263  while ( *np++ ) *np = *np == '\\' ? '/' : *np;
264 #endif
265  *file = fopen (netpath, "rb");
266  if (!*file)
267  continue;
268 
269  Com_DPrintf ("FindFile: %s\n",netpath);
270 
271  return FS_filelength (*file);
272  }
273 
274  }
275 
276  Com_DPrintf ("FindFile: can't find %s\n", filename);
277 
278  *file = NULL;
279  return -1;
280 }
281 
282 #else
283 
284 // this is just for demos to prevent add on hacking
285 
286 int FS_FOpenFile (char *filename, FILE **file)
287 {
288  searchpath_t *search;
289  char netpath[MAX_OSPATH];
290  pack_t *pak;
291  int i;
292 
293  file_from_pak = 0;
294 
295  // get config from directory, everything else from pak
296  if (!strcmp(filename, "config.cfg") || !strncmp(filename, "players/", 8))
297  {
298  Com_sprintf (netpath, sizeof(netpath), "%s/%s",FS_Gamedir(), filename);
299 
300  *file = fopen (netpath, "rb");
301  if (!*file)
302  return -1;
303 
304  Com_DPrintf ("FindFile: %s\n",netpath);
305 
306  return FS_filelength (*file);
307  }
308 
309  for (search = fs_searchpaths ; search ; search = search->next)
310  if (search->pack)
311  break;
312  if (!search)
313  {
314  *file = NULL;
315  return -1;
316  }
317 
318  pak = search->pack;
319  for (i=0 ; i<pak->numfiles ; i++)
320  if (!Q_strcasecmp (pak->files[i].name, filename))
321  { // found it!
322  file_from_pak = 1;
323  Com_DPrintf ("PackFile: %s : %s\n",pak->filename, filename);
324  // open a new file on the pakfile
325  *file = fopen (pak->filename, "rb");
326  if (!*file)
327  Com_Error (ERR_FATAL, "Couldn't reopen %s", pak->filename);
328  fseek (*file, pak->files[i].filepos, SEEK_SET);
329  return pak->files[i].filelen;
330  }
331 
332  Com_DPrintf ("FindFile: can't find %s\n", filename);
333 
334  *file = NULL;
335  return -1;
336 }
337 
338 #endif
339 
340 
341 /*
342 =================
343 FS_ReadFile
344 
345 Properly handles partial reads
346 =================
347 */
348 void CDAudio_Stop(void);
349 #define MAX_READ 0x10000 // read in blocks of 64k
350 void FS_Read (void *buffer, int len, FILE *f)
351 {
352  int block, remaining;
353  int read;
354  byte *buf;
355  int tries;
356 
357  buf = (byte *)buffer;
358 
359  // read in chunks for progress bar
360  remaining = len;
361  tries = 0;
362  while (remaining)
363  {
364  block = remaining;
365  if (block > MAX_READ)
366  block = MAX_READ;
367  read = (int)fread (buf, 1, block, f);
368  if (read == 0)
369  {
370  // we might have been trying to read from a CD
371  if (!tries)
372  {
373  tries = 1;
374  CDAudio_Stop();
375  }
376  else
377  Com_Error (ERR_FATAL, "FS_Read: 0 bytes read");
378  }
379 
380  if (read == -1)
381  Com_Error (ERR_FATAL, "FS_Read: -1 bytes read");
382 
383  // do some progress bar thing here...
384 
385  remaining -= read;
386  buf += read;
387  }
388 }
389 
390 /*
391 ============
392 FS_LoadFile
393 
394 Filename are reletive to the quake search path
395 a null buffer will just return the file length without loading
396 ============
397 */
398 int FS_LoadFile (char *path, void **buffer)
399 {
400  FILE *h;
401  byte *buf;
402  int len;
403 
404  buf = NULL; // quiet compiler warning
405 
406 // look for it in the filesystem or pack files
407  len = FS_FOpenFile (path, &h);
408  if (!h)
409  {
410  if (buffer)
411  *buffer = NULL;
412  return -1;
413  }
414 
415  if (!buffer)
416  {
417  fclose (h);
418  return len;
419  }
420 
421  buf = Z_Malloc(len);
422  *buffer = buf;
423 
424  FS_Read (buf, len, h);
425 
426  fclose (h);
427 
428  return len;
429 }
430 
431 
432 /*
433 =============
434 FS_FreeFile
435 =============
436 */
437 void FS_FreeFile (void *buffer)
438 {
439  Z_Free (buffer);
440 }
441 
442 /*
443 =================
444 FS_LoadPackFile
445 
446 Takes an explicit (not game tree related) path to a pak file.
447 
448 Loads the header and directory, adding the files at the beginning
449 of the list so they override previous pack files.
450 =================
451 */
452 pack_t *FS_LoadPackFile (char *packfile)
453 {
454  dpackheader_t header;
455  int i;
456  packfile_t *newfiles;
457  int numpackfiles;
458  pack_t *pack;
459  FILE *packhandle;
461  unsigned checksum;
462 
463  packhandle = fopen(packfile, "rb");
464  if (!packhandle)
465  return NULL;
466 
467  fread (&header, 1, sizeof(header), packhandle);
468  if (LittleLong(header.ident) != IDPAKHEADER)
469  Com_Error (ERR_FATAL, "%s is not a packfile", packfile);
470  header.dirofs = LittleLong (header.dirofs);
471  header.dirlen = LittleLong (header.dirlen);
472 
473  numpackfiles = header.dirlen / sizeof(dpackfile_t);
474 
475  if (numpackfiles > MAX_FILES_IN_PACK)
476  Com_Error (ERR_FATAL, "%s has %i files", packfile, numpackfiles);
477 
478  newfiles = Z_Malloc (numpackfiles * sizeof(packfile_t));
479 
480  fseek (packhandle, header.dirofs, SEEK_SET);
481  fread (info, 1, header.dirlen, packhandle);
482 
483 // crc the directory to check for modifications
484  checksum = Com_BlockChecksum ((void *)info, header.dirlen);
485 
486 #ifdef NO_ADDONS
487  if (checksum != PAK0_CHECKSUM)
488  return NULL;
489 #endif
490 // parse the directory
491  for (i=0 ; i<numpackfiles ; i++)
492  {
493  strcpy (newfiles[i].name, info[i].name);
494  newfiles[i].filepos = LittleLong(info[i].filepos);
495  newfiles[i].filelen = LittleLong(info[i].filelen);
496  }
497 
498  pack = Z_Malloc (sizeof (pack_t));
499  strcpy (pack->filename, packfile);
500  pack->handle = packhandle;
501  pack->numfiles = numpackfiles;
502  pack->files = newfiles;
503 
504  Com_Printf ("Added packfile %s (%i files)\n", packfile, numpackfiles);
505  return pack;
506 }
507 
508 
509 /*
510 ================
511 FS_AddGameDirectory
512 
513 Sets fs_gamedir, adds the directory to the head of the path,
514 then loads and adds pak1.pak pak2.pak ...
515 ================
516 */
517 void FS_AddGameDirectory (char *dir)
518 {
519  int i;
520  searchpath_t *search;
521  pack_t *pak;
522  char pakfile[MAX_OSPATH];
523 
524  strcpy (fs_gamedir, dir);
525 
526  //
527  // add the directory to the search path
528  //
529  search = Z_Malloc (sizeof(searchpath_t));
530  strcpy (search->filename, dir);
531  search->next = fs_searchpaths;
532  fs_searchpaths = search;
533 
534  //
535  // add any pak files in the format pak0.pak pak1.pak, ...
536  //
537  for (i=0; i<10; i++)
538  {
539  Com_sprintf (pakfile, sizeof(pakfile), "%s/pak%i.pak", dir, i);
540  pak = FS_LoadPackFile (pakfile);
541  if (!pak)
542  continue;
543  search = Z_Malloc (sizeof(searchpath_t));
544  search->pack = pak;
545  search->next = fs_searchpaths;
546  fs_searchpaths = search;
547  }
548 
549 
550 }
551 
552 /*
553 ============
554 FS_Gamedir
555 
556 Called to find where to write a file (demos, savegames, etc)
557 ============
558 */
559 char *FS_Gamedir (void)
560 {
561  if (*fs_gamedir)
562  return fs_gamedir;
563  else
564  return BASEDIRNAME;
565 }
566 
567 /*
568 =============
569 FS_ExecAutoexec
570 =============
571 */
572 void FS_ExecAutoexec (void)
573 {
574  char *dir;
575  char name [MAX_QPATH];
576 
577  dir = Cvar_VariableString("gamedir");
578  if (*dir)
579  Com_sprintf(name, sizeof(name), "%s/%s/autoexec.cfg", fs_basedir->string, dir);
580  else
581  Com_sprintf(name, sizeof(name), "%s/%s/autoexec.cfg", fs_basedir->string, BASEDIRNAME);
583  Cbuf_AddText ("exec autoexec.cfg\n");
584  Sys_FindClose();
585 }
586 
587 
588 /*
589 ================
590 FS_SetGamedir
591 
592 Sets the gamedir and path to a different directory.
593 ================
594 */
595 void FS_SetGamedir (char *dir)
596 {
598 
599  if (strstr(dir, "..") || strstr(dir, "/")
600  || strstr(dir, "\\") || strstr(dir, ":") )
601  {
602  Com_Printf ("Gamedir should be a single filename, not a path\n");
603  return;
604  }
605 
606  //
607  // free up any current game dir info
608  //
610  {
611  if (fs_searchpaths->pack)
612  {
613  fclose (fs_searchpaths->pack->handle);
616  }
620  }
621 
622  //
623  // flush all data, so it will be forced to reload
624  //
625  if (dedicated && !dedicated->value)
626  Cbuf_AddText ("vid_restart\nsnd_restart\n");
627 
628  Com_sprintf (fs_gamedir, sizeof(fs_gamedir), "%s/%s", fs_basedir->string, dir);
629 
630  if (!strcmp(dir,BASEDIRNAME) || (*dir == 0))
631  {
632  Cvar_FullSet ("gamedir", "", CVAR_SERVERINFO|CVAR_NOSET);
634  }
635  else
636  {
637  Cvar_FullSet ("gamedir", dir, CVAR_SERVERINFO|CVAR_NOSET);
638  if (fs_cddir->string[0])
639  FS_AddGameDirectory (va("%s/%s", fs_cddir->string, dir) );
640  FS_AddGameDirectory (va("%s/%s", fs_basedir->string, dir) );
641  }
642 }
643 
644 
645 /*
646 ================
647 FS_Link_f
648 
649 Creates a filelink_t
650 ================
651 */
652 void FS_Link_f (void)
653 {
654  filelink_t *l, **prev;
655 
656  if (Cmd_Argc() != 3)
657  {
658  Com_Printf ("USAGE: link <from> <to>\n");
659  return;
660  }
661 
662  // see if the link already exists
663  prev = &fs_links;
664  for (l=fs_links ; l ; l=l->next)
665  {
666  if (!strcmp (l->from, Cmd_Argv(1)))
667  {
668  Z_Free (l->to);
669  if (!strlen(Cmd_Argv(2)))
670  { // delete it
671  *prev = l->next;
672  Z_Free (l->from);
673  Z_Free (l);
674  return;
675  }
676  l->to = CopyString (Cmd_Argv(2));
677  return;
678  }
679  prev = &l->next;
680  }
681 
682  // create a new link
683  l = Z_Malloc(sizeof(*l));
684  l->next = fs_links;
685  fs_links = l;
686  l->from = CopyString(Cmd_Argv(1));
687  l->fromlength = (int)strlen(l->from);
688  l->to = CopyString(Cmd_Argv(2));
689 }
690 
691 /*
692 ** FS_ListFiles
693 */
694 char **FS_ListFiles( char *findname, int *numfiles, unsigned musthave, unsigned canthave )
695 {
696  char *s;
697  int nfiles = 0;
698  char **list = 0;
699 
700  s = Sys_FindFirst( findname, musthave, canthave );
701  while ( s )
702  {
703  if ( s[strlen(s)-1] != '.' )
704  nfiles++;
705  s = Sys_FindNext( musthave, canthave );
706  }
707  Sys_FindClose ();
708 
709  if ( !nfiles )
710  return NULL;
711 
712  nfiles++; // add space for a guard
713  *numfiles = nfiles;
714 
715  list = malloc( sizeof( char * ) * nfiles );
716  memset( list, 0, sizeof( char * ) * nfiles );
717 
718  s = Sys_FindFirst( findname, musthave, canthave );
719  nfiles = 0;
720  while ( s )
721  {
722  if ( s[strlen(s)-1] != '.' )
723  {
724  list[nfiles] = strdup( s );
725 #ifdef _WIN32
726  strlwr( list[nfiles] );
727 #endif
728  nfiles++;
729  }
730  s = Sys_FindNext( musthave, canthave );
731  }
732  Sys_FindClose ();
733 
734  return list;
735 }
736 
737 /*
738 ** FS_Dir_f
739 */
740 void FS_Dir_f( void )
741 {
742  char *path = NULL;
743  char findname[1024];
744  char wildcard[1024] = "*.*";
745  char **dirnames;
746  int ndirs;
747 
748  if ( Cmd_Argc() != 1 )
749  {
750  strcpy( wildcard, Cmd_Argv( 1 ) );
751  }
752 
753  while ( ( path = FS_NextPath( path ) ) != NULL )
754  {
755  char *tmp = findname;
756 
757  Com_sprintf( findname, sizeof(findname), "%s/%s", path, wildcard );
758 
759  while ( *tmp != 0 )
760  {
761  if ( *tmp == '\\' )
762  *tmp = '/';
763  tmp++;
764  }
765  Com_Printf( "Directory of %s\n", findname );
766  Com_Printf( "----\n" );
767 
768  if ( ( dirnames = FS_ListFiles( findname, &ndirs, 0, 0 ) ) != 0 )
769  {
770  int i;
771 
772  for ( i = 0; i < ndirs-1; i++ )
773  {
774  if ( strrchr( dirnames[i], '/' ) )
775  Com_Printf( "%s\n", strrchr( dirnames[i], '/' ) + 1 );
776  else
777  Com_Printf( "%s\n", dirnames[i] );
778 
779  free( dirnames[i] );
780  }
781  free( dirnames );
782  }
783  Com_Printf( "\n" );
784  };
785 }
786 
787 /*
788 ============
789 FS_Path_f
790 
791 ============
792 */
793 void FS_Path_f (void)
794 {
795  searchpath_t *s;
796  filelink_t *l;
797 
798  Com_Printf ("Current search path:\n");
799  for (s=fs_searchpaths ; s ; s=s->next)
800  {
801  if (s == fs_base_searchpaths)
802  Com_Printf ("----------\n");
803  if (s->pack)
804  Com_Printf ("%s (%i files)\n", s->pack->filename, s->pack->numfiles);
805  else
806  Com_Printf ("%s\n", s->filename);
807  }
808 
809  Com_Printf ("\nLinks:\n");
810  for (l=fs_links ; l ; l=l->next)
811  Com_Printf ("%s : %s\n", l->from, l->to);
812 }
813 
814 /*
815 ================
816 FS_NextPath
817 
818 Allows enumerating all of the directories in the search path
819 ================
820 */
821 char *FS_NextPath (char *prevpath)
822 {
823  searchpath_t *s;
824  char *prev;
825 
826  if (!prevpath)
827  return fs_gamedir;
828 
829  prev = fs_gamedir;
830  for (s=fs_searchpaths ; s ; s=s->next)
831  {
832  if (s->pack)
833  continue;
834  if (prevpath == prev)
835  return s->filename;
836  prev = s->filename;
837  }
838 
839  return NULL;
840 }
841 
842 
843 /*
844 ================
845 FS_InitFilesystem
846 ================
847 */
848 void FS_InitFilesystem (void)
849 {
850  Cmd_AddCommand ("path", FS_Path_f);
851  Cmd_AddCommand ("link", FS_Link_f);
852  Cmd_AddCommand ("dir", FS_Dir_f );
853 
854  //
855  // basedir <path>
856  // allows the game to run from outside the data tree
857  //
858  fs_basedir = Cvar_Get ("basedir", ".", CVAR_NOSET);
859 
860  //
861  // cddir <path>
862  // Logically concatenates the cddir after the basedir for
863  // allows the game to run from outside the data tree
864  //
865  fs_cddir = Cvar_Get ("cddir", "", CVAR_NOSET);
866  if (fs_cddir->string[0])
868 
869  //
870  // start up with baseq2 by default
871  //
873 
874  // any set gamedirs will be freed up to here
876 
877  // check for game override
879  if (fs_gamedirvar->string[0])
881 }
882 
883 
884 
CDAudio_Stop
void CDAudio_Stop(void)
Definition: cd_win.c:194
dpackheader_t::dirofs
int dirofs
Definition: qfiles.h:45
FS_Read
void FS_Read(void *buffer, int len, FILE *f)
Definition: files.c:350
dedicated
cvar_t * dedicated
Definition: common.c:47
searchpath_s::filename
char filename[MAX_OSPATH]
Definition: files.c:78
pack_t
struct pack_s pack_t
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:80
FS_LoadPackFile
pack_t * FS_LoadPackFile(char *packfile)
Definition: files.c:452
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
FS_Path_f
void FS_Path_f(void)
Definition: files.c:793
file_from_pak
int file_from_pak
Definition: files.c:204
CVAR_NOSET
#define CVAR_NOSET
Definition: q_shared.h:319
Sys_Mkdir
void Sys_Mkdir(char *path)
Definition: q_shwin.c:135
fs_cddir
cvar_t * fs_cddir
Definition: files.c:63
fs_links
filelink_t * fs_links
Definition: files.c:74
BASEDIRNAME
#define BASEDIRNAME
Definition: qcommon.h:28
FS_SetGamedir
void FS_SetGamedir(char *dir)
Definition: files.c:595
cvar_s::string
char * string
Definition: q_shared.h:327
i
int i
Definition: q_shared.c:305
fs_basedir
cvar_t * fs_basedir
Definition: files.c:62
FS_Dir_f
void FS_Dir_f(void)
Definition: files.c:740
dpackfile_t
Definition: qfiles.h:36
buffer
GLenum GLfloat * buffer
Definition: qgl_win.c:151
FS_NextPath
char * FS_NextPath(char *prevpath)
Definition: files.c:821
pack_s::numfiles
int numfiles
Definition: files.c:57
CopyString
char * CopyString(char *in)
Definition: common.c:1038
Cvar_Get
cvar_t * Cvar_Get(char *var_name, char *var_value, int flags)
Definition: cvar.c:127
FS_CreatePath
void FS_CreatePath(char *path)
Definition: files.c:125
cvar_s
Definition: q_shared.h:324
packfile_t::filelen
int filelen
Definition: files.c:50
FS_FOpenFile
int FS_FOpenFile(char *filename, FILE **file)
Definition: files.c:206
CVAR_SERVERINFO
#define CVAR_SERVERINFO
Definition: q_shared.h:318
PAK0_CHECKSUM
#define PAK0_CHECKSUM
Definition: files.c:28
packfile_t::name
char name[MAX_QPATH]
Definition: files.c:49
dpackheader_t
Definition: qfiles.h:42
Cmd_Argv
char * Cmd_Argv(int arg)
Definition: cmd.c:517
va
char * va(char *format,...)
Definition: q_shared.c:1050
Cmd_Argc
int Cmd_Argc(void)
Definition: cmd.c:507
FS_Link_f
void FS_Link_f(void)
Definition: files.c:652
searchpath_s::next
struct searchpath_s * next
Definition: files.c:80
searchpath_s
Definition: files.c:76
IDPAKHEADER
#define IDPAKHEADER
Definition: qfiles.h:34
MAX_READ
#define MAX_READ
Definition: files.c:349
LittleLong
int LittleLong(int l)
Definition: q_shared.c:948
Sys_FindFirst
char * Sys_FindFirst(char *path, unsigned musthave, unsigned canthave)
Definition: q_shwin.c:173
Cvar_FullSet
cvar_t * Cvar_FullSet(char *var_name, char *value, int flags)
Definition: cvar.c:288
searchpath_t
struct searchpath_s searchpath_t
FS_AddGameDirectory
void FS_AddGameDirectory(char *dir)
Definition: files.c:517
pack_s::handle
FILE * handle
Definition: files.c:56
FS_ExecAutoexec
void FS_ExecAutoexec(void)
Definition: files.c:572
Cmd_AddCommand
void Cmd_AddCommand(char *cmd_name, xcommand_t function)
Definition: cmd.c:691
FS_LoadFile
int FS_LoadFile(char *path, void **buffer)
Definition: files.c:398
cvar_s::value
float value
Definition: q_shared.h:331
Cbuf_AddText
void Cbuf_AddText(char *text)
Definition: cmd.c:90
pack_s
Definition: files.c:53
MAX_OSPATH
#define MAX_OSPATH
Definition: q_shared.h:81
fs_base_searchpaths
searchpath_t * fs_base_searchpaths
Definition: files.c:84
NULL
#define NULL
Definition: q_shared.h:67
FS_ListFiles
char ** FS_ListFiles(char *findname, int *numfiles, unsigned musthave, unsigned canthave)
Definition: files.c:694
FS_InitFilesystem
void FS_InitFilesystem(void)
Definition: files.c:848
CVAR_LATCH
#define CVAR_LATCH
Definition: q_shared.h:321
FS_filelength
int FS_filelength(FILE *f)
Definition: files.c:104
Com_Error
void Com_Error(int code, char *fmt,...)
Definition: common.c:181
packfile_t
Definition: files.c:47
filelink_t
struct filelink_s filelink_t
Z_Malloc
void * Z_Malloc(int size)
Definition: common.c:1200
name
cvar_t * name
Definition: cl_main.c:79
Developer_searchpath
int Developer_searchpath(int who)
Definition: files.c:159
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
s
static fixed16_t s
Definition: r_scan.c:30
FS_FCloseFile
void FS_FCloseFile(FILE *f)
Definition: files.c:149
Sys_FindNext
char * Sys_FindNext(unsigned musthave, unsigned canthave)
Definition: q_shwin.c:191
pack_s::filename
char filename[MAX_OSPATH]
Definition: files.c:55
Com_BlockChecksum
unsigned Com_BlockChecksum(void *buffer, int length)
Definition: md4.c:213
qcommon.h
MAX_FILES_IN_PACK
#define MAX_FILES_IN_PACK
Definition: qfiles.h:49
Z_Free
void Z_Free(void *ptr)
Definition: common.c:1122
searchpath_s::pack
pack_t * pack
Definition: files.c:79
fs_searchpaths
searchpath_t * fs_searchpaths
Definition: files.c:83
FS_Gamedir
char * FS_Gamedir(void)
Definition: files.c:559
packfile_t::filepos
int filepos
Definition: files.c:50
Sys_FindClose
void Sys_FindClose(void)
Definition: q_shwin.c:206
Com_DPrintf
void Com_DPrintf(char *fmt,...)
Definition: common.c:157
FS_FreeFile
void FS_FreeFile(void *buffer)
Definition: files.c:437
Com_Printf
void Com_Printf(char *fmt,...)
Definition: common.c:104
SFF_HIDDEN
#define SFF_HIDDEN
Definition: q_shared.h:287
Q_strcasecmp
int Q_strcasecmp(char *s1, char *s2)
Definition: q_shared.c:1216
pack_s::files
packfile_t * files
Definition: files.c:58
Cvar_VariableString
char * Cvar_VariableString(char *var_name)
Definition: cvar.c:79
fs_gamedir
char fs_gamedir[MAX_OSPATH]
Definition: files.c:61
SFF_SUBDIR
#define SFF_SUBDIR
Definition: q_shared.h:289
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1223
fs_gamedirvar
cvar_t * fs_gamedirvar
Definition: files.c:64
SFF_SYSTEM
#define SFF_SYSTEM
Definition: q_shared.h:290
dpackheader_t::dirlen
int dirlen
Definition: qfiles.h:46
dpackheader_t::ident
int ident
Definition: qfiles.h:44