4 Copyright (C) 2003-2005 Mathieu Olivier
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to:
20 Free Software Foundation, Inc.
21 59 Temple Place - Suite 330
22 Boston, MA 02111-1307, USA
29 // ------ Types ------ //
31 typedef struct qfile_s qfile_t;
34 //typedef long fs_offset_t; // 32bit
35 typedef __int64 fs_offset_t; // 64bit (lots of warnings, and read/write still don't take 64bit on win64)
37 typedef long long fs_offset_t;
42 // ------ Variables ------ //
44 extern char fs_gamedir [MAX_OSPATH];
45 extern char fs_basedir [MAX_OSPATH];
47 // list of active game directories (empty if not running a mod)
48 #define MAX_GAMEDIRS 16
49 extern int fs_numgamedirs;
50 extern char fs_gamedirs[MAX_GAMEDIRS][MAX_QPATH];
53 // ------ Main functions ------ //
55 // IMPORTANT: the file path is automatically prefixed by the current game directory for
56 // each file created by FS_WriteFile, or opened in "write" or "append" mode by FS_Open
58 qboolean FS_AddPack(const char *pakfile, qboolean *already_loaded, qboolean keep_plain_dirs); // already_loaded may be NULL if caller does not care
59 const char *FS_WhichPack(const char *filename);
60 qfile_t *FS_Open (const char* filepath, const char* mode, qboolean quiet, qboolean nonblocking);
61 int FS_Close (qfile_t* file);
62 fs_offset_t FS_Write (qfile_t* file, const void* data, size_t datasize);
63 fs_offset_t FS_Read (qfile_t* file, void* buffer, size_t buffersize);
64 int FS_Print(qfile_t* file, const char *msg);
65 int FS_Printf(qfile_t* file, const char* format, ...) DP_FUNC_PRINTF(2);
66 int FS_VPrintf(qfile_t* file, const char* format, va_list ap);
67 int FS_Getc (qfile_t* file);
68 int FS_UnGetc (qfile_t* file, unsigned char c);
69 int FS_Seek (qfile_t* file, fs_offset_t offset, int whence);
70 fs_offset_t FS_Tell (qfile_t* file);
71 fs_offset_t FS_FileSize (qfile_t* file);
72 void FS_Purge (qfile_t* file);
73 const char *FS_FileWithoutPath (const char *in);
74 const char *FS_FileExtension (const char *in);
75 int FS_CheckNastyPath (const char *path, qboolean isgamedir);
76 qboolean FS_CheckGameDir(const char *gamedir);
77 qboolean FS_ChangeGameDirs(int numgamedirs, char gamedirs[][MAX_QPATH], qboolean complain, qboolean failmissing);
78 qboolean FS_IsRegisteredQuakePack(const char *name);
79 int FS_CRCFile(const char *filename, size_t *filesizepointer);
82 typedef struct fssearch_s
87 char *filenamesbuffer;
91 fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet);
92 void FS_FreeSearch(fssearch_t *search);
94 unsigned char *FS_LoadFile (const char *path, mempool_t *pool, qboolean quiet, fs_offset_t *filesizepointer);
95 qboolean FS_WriteFile (const char *filename, void *data, fs_offset_t len);
98 // ------ Other functions ------ //
100 void FS_StripExtension (const char *in, char *out, size_t size_out);
101 void FS_DefaultExtension (char *path, const char *extension, size_t size_path);
103 qboolean FS_FileExists (const char *filename); // the file can be into a package
104 qboolean FS_SysFileExists (const char *filename); // only look for files outside of packages
106 void FS_mkdir (const char *path);