4 Copyright (C) 2003 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 // ------ Variables ------ //
36 extern char fs_gamedir [MAX_OSPATH];
37 extern char fs_basedir [MAX_OSPATH];
39 extern int fs_filesize; // set by FS_Open (in "read" mode) and FS_LoadFile
42 // ------ Main functions ------ //
44 // IMPORTANT: the file path is automatically prefixed by the current game directory for
45 // each file created by FS_WriteFile, or opened in "write" or "append" mode by FS_Open
47 qfile_t *FS_Open (const char* filepath, const char* mode, qboolean quiet);
48 int FS_Close (qfile_t* file);
49 size_t FS_Write (qfile_t* file, const void* data, size_t datasize);
50 size_t FS_Read (qfile_t* file, void* buffer, size_t buffersize);
51 int FS_Flush (qfile_t* file);
52 int FS_Print(qfile_t* file, const char *msg);
53 int FS_Printf(qfile_t* file, const char* format, ...);
54 int FS_Getc (qfile_t* file);
55 int FS_Seek (qfile_t* file, long offset, int whence);
56 long FS_Tell (qfile_t* file);
57 char *FS_Gets (qfile_t* file, char* buffer, int buffersize);
58 char *FS_Getline (qfile_t *file); // DO NOT FREE the returned buffer
59 int FS_Eof (qfile_t* file);
61 typedef struct fssearch_s
66 char *filenamesbuffer;
70 fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet);
71 void FS_FreeSearch(fssearch_t *search);
73 qbyte *FS_LoadFile (const char *path, qboolean quiet);
74 qboolean FS_WriteFile (const char *filename, void *data, int len);
77 // ------ Other functions ------ //
79 void FS_StripExtension (const char *in, char *out, size_t size_out);
80 void FS_DefaultExtension (char *path, const char *extension, size_t size_path);
82 qboolean FS_FileExists (const char *filename); // the file can be into a package
83 qboolean FS_SysFileExists (const char *filename); // only look for files outside of packages
85 void FS_mkdir (const char *path);