mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-20 01:11:18 +00:00
don't seg if files can't be opened
This commit is contained in:
parent
ce3accd4f1
commit
fa31cb73b5
3 changed files with 11 additions and 0 deletions
|
@ -31,6 +31,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
# include <strings.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "QF/dstring.h"
|
||||
#include "QF/quakefs.h"
|
||||
|
@ -523,6 +524,8 @@ LoadMapFile (const char *filename)
|
|||
QFile *file;
|
||||
|
||||
file = Qopen (filename, "rt");
|
||||
if (!file)
|
||||
Sys_Error ("couldn't open %s. %s", filename, strerror(errno));
|
||||
buf = malloc (Qfilesize (file) + 1);
|
||||
buf[Qfilesize (file)] = 0;
|
||||
Qread (file, buf, Qfilesize (file));
|
||||
|
|
|
@ -38,6 +38,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
# include <strings.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "QF/quakefs.h"
|
||||
#include "QF/sys.h"
|
||||
|
@ -579,10 +580,14 @@ UpdateEntLump (void)
|
|||
|
||||
printf ("Updating entities lump...\n");
|
||||
f = Qopen (options.bspfile, "rb");
|
||||
if (!f)
|
||||
Sys_Error ("couldn't open %s. %s", options.bspfile, strerror(errno));
|
||||
bsp = LoadBSPFile (f, Qfilesize (f));
|
||||
Qclose (f);
|
||||
WriteEntitiesToString ();
|
||||
f = Qopen (options.bspfile, "wb");
|
||||
if (!f)
|
||||
Sys_Error ("couldn't open %s. %s", options.bspfile, strerror(errno));
|
||||
WriteBSPFile (bsp, f);
|
||||
Qclose (f);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "QF/dstring.h"
|
||||
#include "QF/qendian.h"
|
||||
|
@ -517,6 +518,8 @@ FinishBSPFile (void)
|
|||
|
||||
// XXX PrintBSPFileSizes ();
|
||||
f = Qopen (options.bspfile, "wb");
|
||||
if (!f)
|
||||
Sys_Error ("couldn't open %s. %s", options.bspfile, strerror(errno));
|
||||
WriteBSPFile (bsp, f);
|
||||
Qclose (f);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue