-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathvfs.h
152 lines (127 loc) · 4.45 KB
/
vfs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: vfs.h,v 1.13 2007-10-13 16:24:50 dkure Exp $
*
*/
#ifndef __VFS_H__
#define __VFS_H__
//=================================
// Quake filesystem
//=================================
extern hashtable_t *filesystemhash;
extern int fs_hash_dups;
extern int fs_hash_files;
typedef struct {
struct searchpath_s *search;
int index;
char rawname[MAX_OSPATH];
int offset;
int len;
} flocation_t;
typedef struct {
void (*PrintPath)(void *handle);
void (*ClosePath)(void *handle);
void (*BuildHash)(void *handle);
qbool (*FindFile)(void *handle, flocation_t *loc, const char *name, void *hashedresult);
// true if found (hashedresult can be NULL)
// note that if rawfile and offset are set, many Com_FileOpens will
// read the raw file otherwise ReadFile will be called instead.
void (*ReadFile)(void *handle, flocation_t *loc, char *buffer);
// reads the entire file
int (*EnumerateFiles)(void *handle, char *match, int (*func)(char *, int, void *), void *parm);
void *(*OpenNew)(vfsfile_t *file, const char *desc);
// returns a handle to a new pak/path
int (*GeneratePureCRC) (void *handle, int seed, int usepure);
vfsfile_t *(*OpenVFS)(void *handle, flocation_t *loc, char *mode);
} searchpathfuncs_t;
typedef struct searchpath_s
{
searchpathfuncs_t *funcs;
qbool copyprotected; // don't allow downloads from here.
qbool istemporary;
void *handle;
int crc_check; // client sorts packs according to this checksum
int crc_reply; // client sends a different crc back to the server,
// for the paks it's actually loaded.
struct searchpath_s *nextpure;
struct searchpath_s *next;
} searchpath_t;
#ifdef WITH_VFS_ARCHIVE_LOADING
int FS_BreakUpArchivePath(const char *filename,
char *archive, size_t archive_len,
char *inside, size_t inside_len);
searchpathfuncs_t *FS_FileNameToSearchFunctions(const char *filename);
#endif
//=================================
// STDIO Files (OS)
//=================================
typedef struct {
vfsfile_t funcs; // <= must be at top/begining of struct
FILE *handle;
} vfsosfile_t;
vfsfile_t *FS_OpenTemp(void);
vfsfile_t *VFSOS_Open(char *osname, char *mode);
extern searchpathfuncs_t osfilefuncs;
//====================
// PACK (*pak) Support
//====================
// in memory
// VFS-FIXME: This is a bad name, it really is just a filename + offset....
typedef struct
{
char name[MAX_QPATH];
int filepos, filelen;
} packfile_t;
extern searchpathfuncs_t packfilefuncs;
//===========================
// ZIP (*.zip, *.pk3) Support
//===========================
#ifdef WITH_ZIP
extern searchpathfuncs_t zipfilefuncs;
#endif // WITH_ZIP
//=============================
// TCP Support - VFS Functions
//=============================
int VFSTCP_ReadBytes (struct vfsfile_s *file, void *buffer, int bytestoread, vfserrno_t *err);
int VFSTCP_WriteBytes (struct vfsfile_s *file, const void *buffer, int bytestowrite);
int VFSTCP_Seek (struct vfsfile_s *file, unsigned long pos, int whence);
unsigned long VFSTCP_Tell (struct vfsfile_s *file);
unsigned long VFSTCP_GetLen (struct vfsfile_s *file);
void VFSTCP_Close (struct vfsfile_s *file);
void VFSTCP_Tick(void);
vfsfile_t *FS_OpenTCP(char *name);
//=====================
// GZIP (*.gz) Support
//=====================
#ifdef WITH_ZLIB
searchpathfuncs_t gzipfilefuncs;
#endif // WITH_ZLIB
//=====================
// TAR (*.tar) Support
//=====================
extern searchpathfuncs_t tarfilefuncs;
//=====================
// Memory Mapped files
//=====================
vfsfile_t *FSMMAP_OpenVFS(void *buf, size_t buf_len);
//=====================
// Doomwad Support
//=====================
#ifdef DOOMWADS
extern searchpathfuncs_t doomwadfilefuncs;
#endif //DOOMWADS
#endif /* __VFS_H__ */