]> icculus.org git repositories - divverent/darkplaces.git/blob - fs.h
use *64.dll instead of *.dll on win64, this way we can include both 32bit and 64bit...
[divverent/darkplaces.git] / fs.h
1 /*
2         DarkPlaces file system
3
4         Copyright (C) 2003-2005 Mathieu Olivier
5
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.
10
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.
14
15         See the GNU General Public License for more details.
16
17         You should have received a copy of the GNU General Public License
18         along with this program; if not, write to:
19
20                 Free Software Foundation, Inc.
21                 59 Temple Place - Suite 330
22                 Boston, MA  02111-1307, USA
23 */
24
25 #ifndef FS_H
26 #define FS_H
27
28
29 // ------ Types ------ //
30
31 typedef struct qfile_s qfile_t;
32
33 #ifdef WIN32
34 typedef long fs_offset_t; // 32bit
35 //typedef _int64 fs_offset_t; // 64bit (lots of warnings, and lseek/read/write still don't take 64bit on win64)
36 #else
37 typedef long long fs_offset_t;
38 #endif
39
40
41
42 // ------ Variables ------ //
43
44 extern char fs_gamedir [MAX_OSPATH];
45 extern char fs_basedir [MAX_OSPATH];
46
47 extern fs_offset_t fs_filesize;  // set by FS_Open (in "read" mode) and FS_LoadFile
48
49
50 // ------ Main functions ------ //
51
52 // IMPORTANT: the file path is automatically prefixed by the current game directory for
53 // each file created by FS_WriteFile, or opened in "write" or "append" mode by FS_Open
54
55 qfile_t *FS_Open (const char* filepath, const char* mode, qboolean quiet, qboolean nonblocking);
56 int FS_Close (qfile_t* file);
57 fs_offset_t FS_Write (qfile_t* file, const void* data, size_t datasize);
58 fs_offset_t FS_Read (qfile_t* file, void* buffer, size_t buffersize);
59 int FS_Print(qfile_t* file, const char *msg);
60 int FS_Printf(qfile_t* file, const char* format, ...);
61 int FS_VPrintf(qfile_t* file, const char* format, va_list ap);
62 int FS_Getc (qfile_t* file);
63 int FS_UnGetc (qfile_t* file, unsigned char c);
64 int FS_Seek (qfile_t* file, fs_offset_t offset, int whence);
65 fs_offset_t FS_Tell (qfile_t* file);
66 void FS_Purge (qfile_t* file);
67
68 typedef struct fssearch_s
69 {
70         int numfilenames;
71         char **filenames;
72         // array of filenames
73         char *filenamesbuffer;
74 }
75 fssearch_t;
76
77 fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet);
78 void FS_FreeSearch(fssearch_t *search);
79
80 qbyte *FS_LoadFile (const char *path, mempool_t *pool, qboolean quiet);
81 qboolean FS_WriteFile (const char *filename, void *data, fs_offset_t len);
82
83
84 // ------ Other functions ------ //
85
86 void FS_StripExtension (const char *in, char *out, size_t size_out);
87 void FS_DefaultExtension (char *path, const char *extension, size_t size_path);
88
89 qboolean FS_FileExists (const char *filename);          // the file can be into a package
90 qboolean FS_SysFileExists (const char *filename);       // only look for files outside of packages
91
92 void FS_mkdir (const char *path);
93
94
95 #endif