mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-29 12:10:48 +00:00
clean out the cmdlib crap from quakefs.c and nuke qfcc's last dependency
on cmdlib.h (and nuke qfcc's cmdlib.h itself:)
This commit is contained in:
parent
98563c15d6
commit
912db0336e
5 changed files with 38 additions and 93 deletions
|
@ -166,65 +166,6 @@ COM_FileOpenRead (char *path, QFile **hndl)
|
|||
return Qfilesize (f);
|
||||
}
|
||||
|
||||
QFile *
|
||||
COM_SafeOpenRead (const char *filename)
|
||||
{
|
||||
QFile *f;
|
||||
|
||||
f = Qopen (filename, "rb");
|
||||
|
||||
if (!f)
|
||||
Sys_Error ("Error opening %s: %s", filename, strerror (errno));
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
QFile *
|
||||
COM_SafeOpenWrite (const char *filename)
|
||||
{
|
||||
QFile *f;
|
||||
|
||||
f = Qopen (filename, "wb");
|
||||
|
||||
if (!f)
|
||||
Sys_Error ("Error opening %s: %s", filename, strerror (errno));
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
void
|
||||
COM_SafeRead (QFile *f, void *buffer, int count)
|
||||
{
|
||||
if (Qread (f, buffer, count) != (size_t) count)
|
||||
Sys_Error ("File read failure");
|
||||
}
|
||||
|
||||
void
|
||||
COM_SafeWrite (QFile *f, const void *buffer, int count)
|
||||
{
|
||||
if (Qwrite (f, buffer, count) != (size_t) count)
|
||||
Sys_Error ("File read failure");
|
||||
}
|
||||
|
||||
int
|
||||
LoadFile (const char *filename, void **bufferptr)
|
||||
{
|
||||
int length;
|
||||
void *buffer;
|
||||
QFile *f;
|
||||
|
||||
f = COM_SafeOpenRead (filename);
|
||||
length = Qfilesize (f);
|
||||
buffer = malloc (length + 1);
|
||||
SYS_CHECKMEM (buffer);
|
||||
((char *) buffer)[length] = 0;
|
||||
COM_SafeRead (f, buffer, length);
|
||||
Qclose (f);
|
||||
|
||||
*bufferptr = buffer;
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
COM_Path_f (void)
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/* Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
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
|
||||
|
||||
See file, 'COPYING', for details.
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
// cmdlib.h
|
||||
|
||||
#ifndef __CMDLIB__
|
||||
#define __CMDLIB__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int LoadFile (const char *filename, void **bufferptr);
|
||||
|
||||
#endif
|
|
@ -44,7 +44,6 @@ static const char rcsid[] =
|
|||
#include <QF/crc.h>
|
||||
#include <QF/dstring.h>
|
||||
|
||||
#include "cmdlib.h"
|
||||
#include "def.h"
|
||||
#include "qfcc.h"
|
||||
#include "expr.h"
|
||||
|
|
|
@ -66,7 +66,6 @@ static const char rcsid[] =
|
|||
|
||||
#include "qfcc.h"
|
||||
#include "class.h"
|
||||
#include "cmdlib.h"
|
||||
#include "cpp.h"
|
||||
#include "debug.h"
|
||||
#include "def.h"
|
||||
|
@ -598,6 +597,22 @@ separate_compile (void)
|
|||
return err;
|
||||
}
|
||||
|
||||
static const char *
|
||||
load_file (const char *fname)
|
||||
{
|
||||
QFile *file;
|
||||
char *src;
|
||||
|
||||
file = Qopen (fname, "rt");
|
||||
if (!file)
|
||||
return 0;
|
||||
src = malloc (Qfilesize (file) + 1);
|
||||
src[Qfilesize (file)] = 0;
|
||||
Qread (file, src, Qfilesize (file));
|
||||
Qclose (file);
|
||||
return src;
|
||||
}
|
||||
|
||||
static int
|
||||
progs_src_compile (void)
|
||||
{
|
||||
|
@ -616,7 +631,8 @@ progs_src_compile (void)
|
|||
dsprintf (filename, "%s/%s", sourcedir, progs_src);
|
||||
else
|
||||
dsprintf (filename, "%s", progs_src);
|
||||
LoadFile (filename->str, (void *) &src);
|
||||
|
||||
src = load_file (filename->str);
|
||||
|
||||
if (!(src = COM_Parse (src))) {
|
||||
fprintf (stderr, "No destination filename. qfcc --help for info.\n");
|
||||
|
|
|
@ -721,6 +721,26 @@ CreatePath (char *path)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
LoadFile (char *fname, void **buf)
|
||||
{
|
||||
QFile *file;
|
||||
char *src;
|
||||
int len;
|
||||
|
||||
*buf = 0;
|
||||
file = Qopen (fname, "rt");
|
||||
if (!file)
|
||||
return 0;
|
||||
len = Qfilesize (file);
|
||||
src = malloc (len + 1);
|
||||
src[Qfilesize (file)] = 0;
|
||||
Qread (file, src, len);
|
||||
Qclose (file);
|
||||
*buf = src;
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
CopyFile
|
||||
|
|
Loading…
Reference in a new issue