Separate file search from loading.

QFS_LoadFile (and its wrappers) now  take a file handle rather than a
path. This will make vpath usage a little cleaner to implement.
This commit is contained in:
Bill Currie 2014-01-23 11:57:57 +09:00
parent 328b997843
commit 3efb0c538f
47 changed files with 108 additions and 112 deletions

View file

@ -216,17 +216,12 @@ void QFS_WriteFile (const char *filename, const void *data, int len);
substitution. substitution.
\param filename The name of the file to open. \param filename The name of the file to open.
\param gzfile Address of file handle pointer.
\param zip If true and the file has been compressed with gzip, the \param zip If true and the file has been compressed with gzip, the
file will be opened such that it decompresses on the fly. file will be opened such that it decompresses on the fly.
Otherwise, the file will be read as-is. Otherwise, the file will be read as-is.
\return The amount of bytes that can be read from the file handle. \return The file handle or NULL if there is an error.
This will be either the files true size if \a zip is true,
or the compressed size of \a zip is false. If an error
occurs while opening the file, this will be -1 and
\a *gzfile will be set to NULL.
*/ */
int _QFS_FOpenFile (const char *filename, QFile **gzfile, int zip); QFile *_QFS_FOpenFile (const char *filename, int zip);
/** Open a file for reading. /** Open a file for reading.
@ -235,31 +230,28 @@ int _QFS_FOpenFile (const char *filename, QFile **gzfile, int zip);
_QFS_FOpenFile() for more details. _QFS_FOpenFile() for more details.
\param filename The name of the file to open. \param filename The name of the file to open.
\param gzfile Address of file handle pointer. \return The file handle pointer, or NULL if there is an error.
\return The amount of bytes that can be read from the file handle.
If an error occurs while opening the file, this will be
-1 and \a *gzfile will be set to NULL.
*/ */
int QFS_FOpenFile (const char *filename, QFile **gzfile); QFile *QFS_FOpenFile (const char *filename);
/** Load a file into memory. /** Load a file into memory.
This is a convenience wrapper for QFS_FOpenFile(). The file will be loaded The file will be loaded into memory allocated from the location indicated
in memory allocated from the location inicated by usehunk. by \a usehunk.
\param path The name of the file to load. \param file The handle of the file to load.
\param usehunk The location from which to allocate memory for the file's \param usehunk The location from which to allocate memory for the file's
data. Use 0. data. Use 0.
\return Pointer to the file's data, or NULL on error. \return Pointer to the file's data, or NULL on error.
\todo remove \a usehunk \todo remove \a usehunk
*/ */
byte *QFS_LoadFile (const char *path, int usehunk); byte *QFS_LoadFile (QFile *file, int usehunk);
/** Load a file into memeory. /** Load a file into memeory.
The file is loaded into memory allocated from the hunk. The file is loaded into memory allocated from the hunk.
*/ */
byte *QFS_LoadHunkFile (const char *path); byte *QFS_LoadHunkFile (QFile *file);
/** Load a file into memeory. /** Load a file into memeory.
@ -267,7 +259,7 @@ byte *QFS_LoadHunkFile (const char *path);
\deprecated This should go away soon. \deprecated This should go away soon.
*/ */
void QFS_LoadCacheFile (const char *path, struct cache_user_s *cu); void QFS_LoadCacheFile (QFile *file, struct cache_user_s *cu);
/** Rename a file. /** Rename a file.

View file

@ -143,7 +143,7 @@ Load_Tracklist (void)
{ {
QFile *oggfile = NULL; QFile *oggfile = NULL;
char *buffile = NULL; char *buffile = NULL;
int size = -1; int size;
/* kill off the old tracklist, and make sure we're not playing anything */ /* kill off the old tracklist, and make sure we're not playing anything */
I_OGGMus_Shutdown (); I_OGGMus_Shutdown ();
@ -155,8 +155,8 @@ Load_Tracklist (void)
return -1; // bail if we don't have a valid filename return -1; // bail if we don't have a valid filename
} }
size = QFS_FOpenFile (mus_ogglist->string, &oggfile); oggfile = QFS_FOpenFile (mus_ogglist->string);
if (size < 0) { if (!oggfile) {
Sys_Printf ("Mus_OggInit: open of file \"%s\" failed\n", Sys_Printf ("Mus_OggInit: open of file \"%s\" failed\n",
mus_ogglist->string); mus_ogglist->string);
return -1; return -1;

View file

@ -315,7 +315,7 @@ flac_callback_load (void *object, cache_allocator_t allocator)
sfxblock_t *block = (sfxblock_t *) object; sfxblock_t *block = (sfxblock_t *) object;
QFS_FOpenFile (block->file, &file); file = QFS_FOpenFile (block->file);
if (!file) if (!file)
return; //FIXME Sys_Error? return; //FIXME Sys_Error?
@ -374,7 +374,7 @@ flac_stream_open (sfx_t *sfx)
QFile *file; QFile *file;
void *f; void *f;
QFS_FOpenFile (stream->file, &file); file = QFS_FOpenFile (stream->file);
if (!file) if (!file)
return 0; return 0;

View file

@ -148,7 +148,7 @@ midi_stream_open (sfx_t *sfx)
unsigned long int local_buffer_size; unsigned long int local_buffer_size;
midi_file_t *mf; midi_file_t *mf;
QFS_FOpenFile (stream->file, &file); file = QFS_FOpenFile (stream->file);
local_buffer_size = Qfilesize (file); local_buffer_size = Qfilesize (file);

View file

@ -302,7 +302,7 @@ SND_Load (sfx_t *sfx)
sfx->close = snd_noop; sfx->close = snd_noop;
sfx->open = snd_open_fail; sfx->open = snd_open_fail;
QFS_FOpenFile (sfx->name, &file); file = QFS_FOpenFile (sfx->name);
if (!file) { if (!file) {
Sys_Printf ("Couldn't load %s\n", sfx->name); Sys_Printf ("Couldn't load %s\n", sfx->name);
return -1; return -1;

View file

@ -196,7 +196,7 @@ vorbis_callback_load (void *object, cache_allocator_t allocator)
sfxblock_t *block = (sfxblock_t *) object; sfxblock_t *block = (sfxblock_t *) object;
QFS_FOpenFile (block->file, &file); file = QFS_FOpenFile (block->file);
if (!file) if (!file)
return; //FIXME Sys_Error? return; //FIXME Sys_Error?
@ -260,7 +260,7 @@ vorbis_stream_open (sfx_t *sfx)
QFile *file; QFile *file;
vorbis_file_t *f; vorbis_file_t *f;
QFS_FOpenFile (stream->file, &file); file = QFS_FOpenFile (stream->file);
if (!file) if (!file)
return 0; return 0;

View file

@ -67,7 +67,7 @@ wav_callback_load (void *object, cache_allocator_t allocator)
sfxbuffer_t *buffer; sfxbuffer_t *buffer;
wavinfo_t *info = &block->wavinfo; wavinfo_t *info = &block->wavinfo;
QFS_FOpenFile (name, &file); file = QFS_FOpenFile (name);
if (!file) if (!file)
return; //FIXME Sys_Error? return; //FIXME Sys_Error?
@ -152,7 +152,7 @@ wav_stream_open (sfx_t *sfx)
QFile *file; QFile *file;
wav_file_t *wf; wav_file_t *wf;
QFS_FOpenFile (stream->file, &file); file = QFS_FOpenFile (stream->file);
if (!file) if (!file)
return 0; return 0;

View file

@ -512,7 +512,7 @@ menu_free_progs_mem (progs_t *pr, void *mem)
static void * static void *
menu_load_file (progs_t *pr, const char *path) menu_load_file (progs_t *pr, const char *path)
{ {
return QFS_LoadFile (path, 0); return QFS_LoadFile (QFS_FOpenFile (path), 0);
} }
static builtin_t builtins[] = { static builtin_t builtins[] = {
@ -615,7 +615,8 @@ Menu_Load (void)
top_menu = 0; top_menu = 0;
menu_pr_state.progs = 0; menu_pr_state.progs = 0;
if ((size = QFS_FOpenFile (menu_pr_state.progs_name, &file)) != -1) { if ((file = QFS_FOpenFile (menu_pr_state.progs_name))) {
size = Qfilesize (file);
PR_LoadProgsFile (&menu_pr_state, file, size, 0, 1024 * 1024); PR_LoadProgsFile (&menu_pr_state, file, size, 0, 1024 * 1024);
Qclose (file); Qclose (file);

View file

@ -83,7 +83,7 @@ file_error (progs_t *pr, const char *path)
static void * static void *
load_file (progs_t *pr, const char *path) load_file (progs_t *pr, const char *path)
{ {
return QFS_LoadHunkFile (path); return QFS_LoadHunkFile (QFS_FOpenFile (path));
} }
static void * static void *
@ -382,7 +382,7 @@ VISIBLE void
PR_LoadProgs (progs_t *pr, const char *progsname, int max_edicts, int zone) PR_LoadProgs (progs_t *pr, const char *progsname, int max_edicts, int zone)
{ {
QFile *file; QFile *file;
QFS_FOpenFile (progsname, &file); file = QFS_FOpenFile (progsname);
pr->progs_name = progsname; pr->progs_name = progsname;
if (file) { if (file) {

View file

@ -792,7 +792,7 @@ GIB_File_Read_f (void)
if (!(ret = GIB_Return (0))) if (!(ret = GIB_Return (0)))
return; return;
path = GIB_Argv (1); path = GIB_Argv (1);
QFS_FOpenFile (path, &file); file = QFS_FOpenFile (path);
if (file) { if (file) {
len = Qfilesize (file); len = Qfilesize (file);
ret->size = len + 1; ret->size = len + 1;

View file

@ -70,7 +70,7 @@ GIB_Exec_Override_f (void)
} }
mark = Hunk_LowMark (); mark = Hunk_LowMark ();
f = (char *) QFS_LoadHunkFile (Cmd_Argv (1)); f = (char *) QFS_LoadHunkFile (QFS_FOpenFile (Cmd_Argv (1)));
if (!f) { if (!f) {
Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1)); Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1));
return; return;

View file

@ -62,7 +62,7 @@ LoadImage (const char *imageFile)
// Check for a .png // Check for a .png
dstring_replace (tmpFile, tmp, tmpFile->size, ".png", 5); dstring_replace (tmpFile, tmp, tmpFile->size, ".png", 5);
QFS_FOpenFile (tmpFile->str, &fp); fp = QFS_FOpenFile (tmpFile->str);
if (fp) { if (fp) {
tex = LoadPNG (fp); tex = LoadPNG (fp);
Qclose (fp); Qclose (fp);
@ -72,7 +72,7 @@ LoadImage (const char *imageFile)
// Check for a .tga // Check for a .tga
dstring_replace (tmpFile, tmp, tmpFile->size, ".tga", 5); dstring_replace (tmpFile, tmp, tmpFile->size, ".tga", 5);
QFS_FOpenFile (tmpFile->str, &fp); fp = QFS_FOpenFile (tmpFile->str);
if (fp) { if (fp) {
tex = LoadTGA (fp); tex = LoadTGA (fp);
Qclose (fp); Qclose (fp);
@ -83,7 +83,7 @@ LoadImage (const char *imageFile)
/* /*
// Check for a .jpg // Check for a .jpg
dstring_replace (tmpFile, tmp, tmpFile->size, ".jpg", 5); dstring_replace (tmpFile, tmp, tmpFile->size, ".jpg", 5);
QFS_FOpenFile (tmpFile->str, &fp); fp = QFS_FOpenFile (tmpFile->str);
if (fp) { if (fp) {
tex = LoadJPG (fp); tex = LoadJPG (fp);
Qclose (fp); Qclose (fp);
@ -94,7 +94,7 @@ LoadImage (const char *imageFile)
// Check for a .pcx // Check for a .pcx
dstring_replace (tmpFile, tmp, tmpFile->size, ".pcx", 5); dstring_replace (tmpFile, tmp, tmpFile->size, ".pcx", 5);
QFS_FOpenFile (tmpFile->str, &fp); fp = QFS_FOpenFile (tmpFile->str);
if (fp) { if (fp) {
tex = LoadPCX (fp, 1, NULL); // Convert, some users don't grok paletted tex = LoadPCX (fp, 1, NULL); // Convert, some users don't grok paletted
Qclose (fp); Qclose (fp);

View file

@ -366,7 +366,7 @@ gl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
cache->str + strlen ("glquake/")); cache->str + strlen ("glquake/"));
dstring_appendstr (cache, ".qfms"); dstring_appendstr (cache, ".qfms");
QFS_FOpenFile (cache->str, &f); f = QFS_FOpenFile (cache->str);
if (f) { if (f) {
unsigned char d1[MDFOUR_DIGEST_BYTES]; unsigned char d1[MDFOUR_DIGEST_BYTES];
unsigned char d2[MDFOUR_DIGEST_BYTES]; unsigned char d2[MDFOUR_DIGEST_BYTES];

View file

@ -148,7 +148,7 @@ gl_Mod_LoadLighting (bsp_t *bsp)
// LordHavoc: check for a .lit file to load // LordHavoc: check for a .lit file to load
QFS_StripExtension (litfilename->str, litfilename->str); QFS_StripExtension (litfilename->str, litfilename->str);
dstring_appendstr (litfilename, ".lit"); dstring_appendstr (litfilename, ".lit");
data = (byte *) QFS_LoadHunkFile (litfilename->str); data = (byte *) QFS_LoadHunkFile (QFS_FOpenFile (litfilename->str));
if (data) { if (data) {
if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I'
&& data[3] == 'T') { && data[3] == 'T') {

View file

@ -171,7 +171,7 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
uint32_t *buf; uint32_t *buf;
// load the file // load the file
buf = (uint32_t *) QFS_LoadFile (mod->name, 0); buf = (uint32_t *) QFS_LoadFile (QFS_FOpenFile (mod->name), 0);
if (!buf) { if (!buf) {
if (crash) if (crash)
Sys_Error ("Mod_LoadModel: %s not found", mod->name); Sys_Error ("Mod_LoadModel: %s not found", mod->name);

View file

@ -177,7 +177,7 @@ Skin_SetSkin (skin_t *skin, int cmap, const char *skinname)
break; break;
} }
QFS_FOpenFile (va ("skins/%s.pcx", name), &file); file = QFS_FOpenFile (va ("skins/%s.pcx", name));
if (!file) { if (!file) {
Sys_Printf ("Couldn't load skin %s\n", name); Sys_Printf ("Couldn't load skin %s\n", name);
free (name); free (name);

View file

@ -106,7 +106,7 @@ bi_QFS_LoadFile (progs_t *pr)
int size; int size;
void *buffer; void *buffer;
QFS_FOpenFile (filename, &file); file = QFS_FOpenFile (filename);
if (!file) { if (!file) {
RETURN_POINTER (pr, 0); RETURN_POINTER (pr, 0);
return; return;
@ -129,7 +129,7 @@ bi_QFS_OpenFile (progs_t *pr)
QFile *file; QFile *file;
const char *filename = P_GSTRING (pr, 0); const char *filename = P_GSTRING (pr, 0);
QFS_FOpenFile (filename, &file); file = QFS_FOpenFile (filename);
if (!file) { if (!file) {
R_INT (pr) = 0; R_INT (pr) = 0;
return; return;

View file

@ -490,7 +490,7 @@ Cmd_Exec_f (void)
} }
mark = Hunk_LowMark (); mark = Hunk_LowMark ();
f = (char *) QFS_LoadHunkFile (Cmd_Argv (1)); f = (char *) QFS_LoadHunkFile (QFS_FOpenFile (Cmd_Argv (1)));
if (!f) { if (!f) {
Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1)); Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1));
return; return;
@ -638,7 +638,7 @@ Cmd_Exec_File (cbuf_t *cbuf, const char *path, int qfs)
if (!path || !*path) if (!path || !*path)
return; return;
if (qfs) { if (qfs) {
QFS_FOpenFile (path, &file); file = QFS_FOpenFile (path);
} else { } else {
char *newpath = Sys_ExpandSquiggle (path); char *newpath = Sys_ExpandSquiggle (path);
file = Qopen (newpath, "r"); file = Qopen (newpath, "r");

View file

@ -1032,9 +1032,10 @@ open_file (int_findfile_t *found, QFile **gzfile, int zip)
} }
} }
VISIBLE int VISIBLE QFile *
_QFS_FOpenFile (const char *filename, QFile **gzfile, int zip) _QFS_FOpenFile (const char *filename, int zip)
{ {
QFile *gzfile;
int_findfile_t *found; int_findfile_t *found;
char *path; char *path;
const char *fnames[4]; const char *fnames[4];
@ -1083,26 +1084,25 @@ _QFS_FOpenFile (const char *filename, QFile **gzfile, int zip)
found = qfs_findfile (fnames, 0, 0); found = qfs_findfile (fnames, 0, 0);
if (found) { if (found) {
open_file (found, gzfile, zip_flags[found->fname_index]); open_file (found, &gzfile, zip_flags[found->fname_index]);
free(path); free(path);
return qfs_filesize; return gzfile;
} }
Sys_MaskPrintf (SYS_FS_NF, "FindFile: can't find %s\n", filename); Sys_MaskPrintf (SYS_FS_NF, "FindFile: can't find %s\n", filename);
error: error:
*gzfile = NULL;
qfs_filesize = -1; qfs_filesize = -1;
free (path); free (path);
return -1; return 0;
} }
VISIBLE int VISIBLE QFile *
QFS_FOpenFile (const char *filename, QFile **gzfile) QFS_FOpenFile (const char *filename)
{ {
return _QFS_FOpenFile (filename, gzfile, 1); return _QFS_FOpenFile (filename, 1);
} }
cache_user_t *loadcache; static cache_user_t *loadcache;
/* /*
QFS_LoadFile QFS_LoadFile
@ -1111,20 +1111,22 @@ cache_user_t *loadcache;
Always appends a 0 byte to the loaded data. Always appends a 0 byte to the loaded data.
*/ */
VISIBLE byte * VISIBLE byte *
QFS_LoadFile (const char *path, int usehunk) QFS_LoadFile (QFile *file, int usehunk)
{ {
QFile *h;
byte *buf = NULL; byte *buf = NULL;
char *base; char *base;
int len; int len;
// look for it in the filesystem or pack files // look for it in the filesystem or pack files
len = qfs_filesize = QFS_FOpenFile (path, &h); if (!file)
if (!h)
return NULL; return NULL;
base = strdup ("QFS_LoadFile");
len = qfs_filesize = Qfilesize (file);
// extract the filename base name for hunk tag // extract the filename base name for hunk tag
base = QFS_FileBase (path); //base = QFS_FileBase (path);
if (usehunk == 1) if (usehunk == 1)
buf = Hunk_AllocName (len + 1, base); buf = Hunk_AllocName (len + 1, base);
@ -1138,11 +1140,12 @@ QFS_LoadFile (const char *path, int usehunk)
Sys_Error ("QFS_LoadFile: bad usehunk"); Sys_Error ("QFS_LoadFile: bad usehunk");
if (!buf) if (!buf)
Sys_Error ("QFS_LoadFile: not enough space for %s", path); Sys_Error ("QFS_LoadFile: not enough space");
//Sys_Error ("QFS_LoadFile: not enough space for %s", path);
buf[len] = 0; buf[len] = 0;
Qread (h, buf, len); Qread (file, buf, len);
Qclose (h); Qclose (file);
free (base); free (base);
@ -1150,16 +1153,16 @@ QFS_LoadFile (const char *path, int usehunk)
} }
VISIBLE byte * VISIBLE byte *
QFS_LoadHunkFile (const char *path) QFS_LoadHunkFile (QFile *file)
{ {
return QFS_LoadFile (path, 1); return QFS_LoadFile (file, 1);
} }
VISIBLE void VISIBLE void
QFS_LoadCacheFile (const char *path, struct cache_user_s *cu) QFS_LoadCacheFile (QFile *file, struct cache_user_s *cu)
{ {
loadcache = cu; loadcache = cu;
QFS_LoadFile (path, 3); QFS_LoadFile (file, 3);
} }
/* /*

View file

@ -81,7 +81,7 @@ W_LoadWadFile (const char *filename)
int i; int i;
int infotableofs; int infotableofs;
wad_base = QFS_LoadHunkFile (filename); wad_base = QFS_LoadHunkFile (QFS_FOpenFile (filename));
if (!wad_base) if (!wad_base)
Sys_Error ("W_LoadWadFile: unable to load %s", filename); Sys_Error ("W_LoadWadFile: unable to load %s", filename);

View file

@ -229,7 +229,7 @@ gl_Draw_CachePic (const char *path, qboolean alpha)
if (!strcmp (path + strlen (path) - 4, ".lmp")) { if (!strcmp (path + strlen (path) - 4, ".lmp")) {
// Load the picture.. // Load the picture..
qpic_t *dat = (qpic_t *) QFS_LoadFile (path, 0); qpic_t *dat = (qpic_t *) QFS_LoadFile (QFS_FOpenFile (path), 0);
if (!dat) if (!dat)
Sys_Error ("Draw_CachePic: failed to load %s", path); Sys_Error ("Draw_CachePic: failed to load %s", path);

View file

@ -213,7 +213,7 @@ gl_R_ReadPointFile_f (void)
name = va ("%s.pts", mapname); name = va ("%s.pts", mapname);
free (mapname); free (mapname);
QFS_FOpenFile (name, &f); f = QFS_FOpenFile (name);
if (!f) { if (!f) {
Sys_Printf ("couldn't open %s\n", name); Sys_Printf ("couldn't open %s\n", name);
return; return;

View file

@ -744,7 +744,7 @@ GL_SetPalette (const byte *palette)
return; return;
palflag = true; palflag = true;
QFS_FOpenFile ("glquake/15to8.pal", &f); f = QFS_FOpenFile ("glquake/15to8.pal");
if (f) { if (f) {
Qread (f, gl_15to8table, 1 << 15); Qread (f, gl_15to8table, 1 << 15);
Qclose (f); Qclose (f);

View file

@ -283,7 +283,7 @@ glsl_Draw_CachePic (const char *path, qboolean alpha)
if ((cpic = Hash_Find (pic_cache, path))) if ((cpic = Hash_Find (pic_cache, path)))
return cpic->pic; return cpic->pic;
if (strlen (path) < 4 || strcmp (path + strlen (path) - 4, ".lmp") if (strlen (path) < 4 || strcmp (path + strlen (path) - 4, ".lmp")
|| !(p = (qpic_t *) QFS_LoadFile (path, 0))) { || !(p = (qpic_t *) QFS_LoadFile (QFS_FOpenFile (path), 0))) {
//FIXME load a null texture //FIXME load a null texture
Sys_Error ("Draw_CachePic: failed to load %s", path); Sys_Error ("Draw_CachePic: failed to load %s", path);
} }
@ -407,7 +407,7 @@ glsl_Draw_Init (void)
conchars = pic_data ("conchars", 128, 128, draw_chars); conchars = pic_data ("conchars", 128, 128, draw_chars);
pic = (qpic_t *) QFS_LoadFile ("gfx/conback.lmp", 0); pic = (qpic_t *) QFS_LoadFile (QFS_FOpenFile ("gfx/conback.lmp"), 0);
if (pic) { if (pic) {
SwapPic (pic); SwapPic (pic);
conback_texture = GLSL_LoadQuakeTexture ("conback", conback_texture = GLSL_LoadQuakeTexture ("conback",

View file

@ -321,7 +321,7 @@ glsl_R_ReadPointFile_f (void)
name = va ("%s.pts", mapname); name = va ("%s.pts", mapname);
free (mapname); free (mapname);
QFS_FOpenFile (name, &f); f = QFS_FOpenFile (name);
if (!f) { if (!f) {
Sys_Printf ("couldn't open %s\n", name); Sys_Printf ("couldn't open %s\n", name);
return; return;

View file

@ -148,7 +148,7 @@ Draw_CachePic (const char *path, qboolean alpha)
return dat; return dat;
// load the pic from disk // load the pic from disk
QFS_LoadCacheFile (path, &pic->cache); QFS_LoadCacheFile (QFS_FOpenFile (path), &pic->cache);
dat = (qpic_t *) pic->cache.data; dat = (qpic_t *) pic->cache.data;
if (!dat) { if (!dat) {

View file

@ -91,7 +91,7 @@ R_ReadPointFile_f (void)
name = va ("maps/%s.pts", mapname); name = va ("maps/%s.pts", mapname);
free (mapname); free (mapname);
QFS_FOpenFile (name, &f); f = QFS_FOpenFile (name);
if (!f) { if (!f) {
Sys_Printf ("couldn't open %s\n", name); Sys_Printf ("couldn't open %s\n", name);
return; return;

View file

@ -151,7 +151,7 @@ sw32_Draw_CachePic (const char *path, qboolean alpha)
return dat; return dat;
// load the pic from disk // load the pic from disk
QFS_LoadCacheFile (path, &pic->cache); QFS_LoadCacheFile (QFS_FOpenFile (path), &pic->cache);
dat = (qpic_t *) pic->cache.data; dat = (qpic_t *) pic->cache.data;
if (!dat) { if (!dat) {

View file

@ -96,7 +96,7 @@ sw32_R_ReadPointFile_f (void)
name = va ("maps/%s.pts", mapname); name = va ("maps/%s.pts", mapname);
free (mapname); free (mapname);
QFS_FOpenFile (name, &f); f = QFS_FOpenFile (name);
if (!f) { if (!f) {
Sys_Printf ("couldn't open %s\n", name); Sys_Printf ("couldn't open %s\n", name);
return; return;

View file

@ -454,7 +454,7 @@ CL_StartDemo (void)
QFS_DefaultExtension (name, ".dem"); QFS_DefaultExtension (name, ".dem");
Sys_Printf ("Playing demo from %s.\n", name->str); Sys_Printf ("Playing demo from %s.\n", name->str);
QFS_FOpenFile (name->str, &cls.demofile); cls.demofile = QFS_FOpenFile (name->str);
if (!cls.demofile) { if (!cls.demofile) {
Sys_Printf ("ERROR: couldn't open.\n"); Sys_Printf ("ERROR: couldn't open.\n");
cls.demonum = -1; // stop demo loop cls.demonum = -1; // stop demo loop

View file

@ -529,10 +529,10 @@ CL_Init (cbuf_t *cbuf)
{ {
byte *basepal, *colormap; byte *basepal, *colormap;
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp"); basepal = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/palette.lmp"));
if (!basepal) if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp"); Sys_Error ("Couldn't load gfx/palette.lmp");
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp"); colormap = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/colormap.lmp"));
if (!colormap) if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp"); Sys_Error ("Couldn't load gfx/colormap.lmp");

View file

@ -268,7 +268,7 @@ map_cfg (const char *mapname, int all)
QFS_StripExtension (mapname, name); QFS_StripExtension (mapname, name);
strcat (name, ".cfg"); strcat (name, ".cfg");
QFS_FOpenFile (name, &f); f = QFS_FOpenFile (name);
if (f) { if (f) {
Qclose (f); Qclose (f);
Cmd_Exec_File (cbuf, name, 1); Cmd_Exec_File (cbuf, name, 1);
@ -294,7 +294,7 @@ map_ent (const char *mapname)
QFS_StripExtension (mapname, name); QFS_StripExtension (mapname, name);
strcat (name, ".ent"); strcat (name, ".ent");
if ((buf = (char *) QFS_LoadFile (name, 0))) { if ((buf = (char *) QFS_LoadFile (QFS_FOpenFile (name), 0))) {
edicts = ED_Parse (&edpr, buf); edicts = ED_Parse (&edpr, buf);
free (buf); free (buf);
} else { } else {

View file

@ -57,7 +57,7 @@ Game_CheckRegistered (void)
{ {
QFile *h; QFile *h;
QFS_FOpenFile ("gfx/pop.lmp", &h); h = QFS_FOpenFile ("gfx/pop.lmp");
static_registered = 0; static_registered = 0;
if (h) { if (h) {

View file

@ -817,7 +817,7 @@ check_quakerc (void)
int ret = 1; int ret = 1;
QFile *f; QFile *f;
QFS_FOpenFile ("quake.rc", &f); f = QFS_FOpenFile ("quake.rc");
if (!f) if (!f)
return 1; return 1;
while ((l = Qgetline (f))) { while ((l = Qgetline (f))) {

View file

@ -279,7 +279,7 @@ Host_Map_f (void)
// check to make sure the level exists // check to make sure the level exists
expanded = va ("maps/%s.bsp", Cmd_Argv (1)); expanded = va ("maps/%s.bsp", Cmd_Argv (1));
QFS_FOpenFile (expanded, &f); f = QFS_FOpenFile (expanded);
if (!f) { if (!f) {
Sys_Printf ("Can't find %s\n", expanded); Sys_Printf ("Can't find %s\n", expanded);
return; return;

View file

@ -1101,7 +1101,7 @@ SV_SaveSpawnparms (void)
void void
SV_SpawnServer (const char *server) SV_SpawnServer (const char *server)
{ {
char *buf; byte *buf;
int i; int i;
edict_t *ent; edict_t *ent;
@ -1211,8 +1211,8 @@ SV_SpawnServer (const char *server)
*sv_globals.serverflags = svs.serverflags; *sv_globals.serverflags = svs.serverflags;
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
if ((buf = (char *) QFS_LoadFile (va ("maps/%s.ent", server), 0))) { if ((buf = QFS_LoadFile (QFS_FOpenFile (va ("maps/%s.ent", server)), 0))) {
ED_LoadFromFile (&sv_pr_state, buf); ED_LoadFromFile (&sv_pr_state, (char *) buf);
free (buf); free (buf);
} else { } else {
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities); ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);

View file

@ -993,11 +993,11 @@ CL_StartDemo (void)
name = dstring_strdup (demoname); name = dstring_strdup (demoname);
QFS_DefaultExtension (name, ".mvd"); QFS_DefaultExtension (name, ".mvd");
QFS_FOpenFile (name->str, &cls.demofile); cls.demofile = QFS_FOpenFile (name->str);
if (!cls.demofile) { if (!cls.demofile) {
dstring_copystr (name, demoname); dstring_copystr (name, demoname);
QFS_DefaultExtension (name, ".qwd"); QFS_DefaultExtension (name, ".qwd");
QFS_FOpenFile (name->str, &cls.demofile); cls.demofile = QFS_FOpenFile (name->str);
} }
if (!cls.demofile) { if (!cls.demofile) {

View file

@ -1169,10 +1169,10 @@ CL_Init (void)
{ {
byte *basepal, *colormap; byte *basepal, *colormap;
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp"); basepal = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/palette.lmp"));
if (!basepal) if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp"); Sys_Error ("Couldn't load gfx/palette.lmp");
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp"); colormap = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/colormap.lmp"));
if (!colormap) if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp"); Sys_Error ("Couldn't load gfx/colormap.lmp");
@ -1716,7 +1716,7 @@ check_quakerc (void)
int ret = 1; int ret = 1;
QFile *f; QFile *f;
QFS_FOpenFile ("quake.rc", &f); f = QFS_FOpenFile ("quake.rc");
if (!f) if (!f)
return 1; return 1;
while ((l = Qgetline (f))) { while ((l = Qgetline (f))) {

View file

@ -237,7 +237,7 @@ CL_CheckOrDownloadFile (const char *filename)
return true; return true;
} }
*/ */
QFS_FOpenFile (filename, &f); f = QFS_FOpenFile (filename);
if (f) { // it exists, no need to download if (f) { // it exists, no need to download
Qclose (f); Qclose (f);
return true; return true;
@ -280,7 +280,7 @@ map_ent (const char *mapname)
QFS_StripExtension (mapname, name); QFS_StripExtension (mapname, name);
strcat (name, ".ent"); strcat (name, ".ent");
if ((buf = (char *) QFS_LoadFile (name, 0))) { if ((buf = (char *) QFS_LoadFile (QFS_FOpenFile (name), 0))) {
edicts = ED_Parse (&edpr, buf); edicts = ED_Parse (&edpr, buf);
free (buf); free (buf);
} else { } else {

View file

@ -62,7 +62,7 @@ Game_CheckRegistered (void)
{ {
QFile *h; QFile *h;
QFS_FOpenFile ("gfx/pop.lmp", &h); h = QFS_FOpenFile ("gfx/pop.lmp");
static_registered = 0; static_registered = 0;
if (h) { if (h) {

View file

@ -136,7 +136,7 @@ locs_load (const char *filename)
QFile *file; QFile *file;
tmp = va ("maps/%s", filename); tmp = va ("maps/%s", filename);
QFS_FOpenFile (tmp, &file); file = QFS_FOpenFile (tmp);
if (!file) { if (!file) {
Sys_Printf ("Couldn't load %s\n", tmp); Sys_Printf ("Couldn't load %s\n", tmp);
return; return;

View file

@ -55,7 +55,7 @@ map_cfg (const char *mapname, int all)
QFS_StripExtension (mapname, name); QFS_StripExtension (mapname, name);
strcat (name, ".cfg"); strcat (name, ".cfg");
QFS_FOpenFile (name, &f); f = QFS_FOpenFile (name);
if (f) { if (f) {
Qclose (f); Qclose (f);
Cmd_Exec_File (cbuf, name, 1); Cmd_Exec_File (cbuf, name, 1);

View file

@ -453,7 +453,7 @@ SV_Map_f (void)
// check to make sure the level exists // check to make sure the level exists
expanded = nva ("maps/%s.bsp", level); expanded = nva ("maps/%s.bsp", level);
QFS_FOpenFile (expanded, &f); f = QFS_FOpenFile (expanded);
if (!f) { if (!f) {
SV_Printf ("Can't find %s\n", expanded); SV_Printf ("Can't find %s\n", expanded);
free (expanded); free (expanded);

View file

@ -290,7 +290,7 @@ SV_CheckModel (const char *mdl)
// int len; // int len;
buf = (byte *) QFS_LoadFile (mdl, 0); buf = (byte *) QFS_LoadFile (QFS_FOpenFile (mdl), 0);
if (buf) { if (buf) {
crc = CRC_Block (buf, qfs_filesize); crc = CRC_Block (buf, qfs_filesize);
free (buf); free (buf);
@ -312,7 +312,7 @@ SV_CheckModel (const char *mdl)
void void
SV_SpawnServer (const char *server) SV_SpawnServer (const char *server)
{ {
char *buf; byte *buf;
edict_t *ent; edict_t *ent;
int i; int i;
void *so_buffers; void *so_buffers;
@ -433,8 +433,8 @@ SV_SpawnServer (const char *server)
// load and spawn all other entities // load and spawn all other entities
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
if ((buf = (char *) QFS_LoadFile (va ("maps/%s.ent", server), 0))) { if ((buf = QFS_LoadFile (QFS_FOpenFile (va ("maps/%s.ent", server)), 0))) {
ED_LoadFromFile (&sv_pr_state, buf); ED_LoadFromFile (&sv_pr_state, (char *) buf);
free (buf); free (buf);
} else { } else {
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities); ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);

View file

@ -390,7 +390,7 @@ PF_validatefile (progs_t *pr)
st = P_GSTRING (pr, 0); st = P_GSTRING (pr, 0);
QFS_FOpenFile (st, &f); f = QFS_FOpenFile (st);
if (!f) { if (!f) {
retval = 0.0; retval = 0.0;
} else { } else {

View file

@ -717,7 +717,7 @@ static void
SV_BeginDownload_f (void *unused) SV_BeginDownload_f (void *unused)
{ {
const char *name; const char *name;
int http, size, zip; int http, zip;
QFile *file; QFile *file;
name = Cmd_Argv (1); name = Cmd_Argv (1);
@ -753,10 +753,10 @@ SV_BeginDownload_f (void *unused)
http = sv_http_url_base->string[0] http = sv_http_url_base->string[0]
&& strchr (Info_ValueForKey (host_client->userinfo, "*cap"), 'h'); && strchr (Info_ValueForKey (host_client->userinfo, "*cap"), 'h');
size = _QFS_FOpenFile (name, &file, !zip); file = _QFS_FOpenFile (name, !zip);
host_client->download = file; host_client->download = file;
host_client->downloadsize = size; host_client->downloadsize = Qfilesize (file);
host_client->downloadcount = 0; host_client->downloadcount = 0;
if (!host_client->download if (!host_client->download

View file

@ -167,10 +167,10 @@ BI_Init (progs_t *pr)
Mod_Init_Cvars (); Mod_Init_Cvars ();
S_Init_Cvars (); S_Init_Cvars ();
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp"); basepal = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/palette.lmp"));
if (!basepal) if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp"); Sys_Error ("Couldn't load gfx/palette.lmp");
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp"); colormap = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/colormap.lmp"));
if (!colormap) if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp"); Sys_Error ("Couldn't load gfx/colormap.lmp");