mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Make pr.load_file 'return' the file size
This commit is contained in:
parent
7e76a96f7d
commit
c296514b95
8 changed files with 22 additions and 11 deletions
|
@ -1550,7 +1550,7 @@ struct progs_s {
|
|||
int no_exec_limit;
|
||||
|
||||
void (*file_error) (progs_t *pr, const char *path);
|
||||
void *(*load_file) (progs_t *pr, const char *path);
|
||||
void *(*load_file) (progs_t *pr, const char *path, off_t *size);
|
||||
void *(*allocate_progs_mem) (progs_t *pr, int size);
|
||||
void (*free_progs_mem) (progs_t *pr, void *mem);
|
||||
|
||||
|
|
|
@ -510,9 +510,11 @@ menu_free_progs_mem (progs_t *pr, void *mem)
|
|||
}
|
||||
|
||||
static void *
|
||||
menu_load_file (progs_t *pr, const char *path)
|
||||
menu_load_file (progs_t *pr, const char *path, off_t *size)
|
||||
{
|
||||
return QFS_LoadFile (QFS_FOpenFile (path), 0);
|
||||
void *data = QFS_LoadFile (QFS_FOpenFile (path), 0);
|
||||
*size = qfs_filesize;
|
||||
return data;
|
||||
}
|
||||
|
||||
static builtin_t builtins[] = {
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
char *name;
|
||||
char *text;
|
||||
off_t size;
|
||||
line_t *lines;
|
||||
pr_uint_t num_lines;
|
||||
progs_t *pr;
|
||||
|
@ -227,7 +228,8 @@ PR_Load_Source_File (progs_t *pr, const char *fname)
|
|||
return 0;
|
||||
for (dir = source_paths; *dir && !f->text; dir++) {
|
||||
f->text = pr->load_file (pr, va ("%s%s%s", *dir, **dir ? "/" : "",
|
||||
fname));
|
||||
fname),
|
||||
&f->size);
|
||||
}
|
||||
if (!f->text) {
|
||||
pr->file_error (pr, fname);
|
||||
|
@ -273,6 +275,7 @@ PR_LoadDebug (progs_t *pr)
|
|||
{
|
||||
char *sym_path;
|
||||
const char *path_end, *sym_file;
|
||||
off_t debug_size;
|
||||
pr_uint_t i;
|
||||
ddef_t *def;
|
||||
pr_type_t *str = 0;
|
||||
|
@ -303,7 +306,7 @@ PR_LoadDebug (progs_t *pr)
|
|||
sym_path = malloc (strlen (sym_file) + (path_end - pr->progs_name) + 1);
|
||||
strncpy (sym_path, pr->progs_name, path_end - pr->progs_name);
|
||||
strcpy (sym_path + (path_end - pr->progs_name), sym_file);
|
||||
pr->debug = pr->load_file (pr, sym_path);
|
||||
pr->debug = pr->load_file (pr, sym_path, &debug_size);
|
||||
if (!pr->debug) {
|
||||
Sys_Printf ("can't load %s for debug info\n", sym_path);
|
||||
free (sym_path);
|
||||
|
|
|
@ -81,9 +81,11 @@ file_error (progs_t *pr, const char *path)
|
|||
}
|
||||
|
||||
static void *
|
||||
load_file (progs_t *pr, const char *path)
|
||||
load_file (progs_t *pr, const char *path, off_t *size)
|
||||
{
|
||||
return QFS_LoadHunkFile (QFS_FOpenFile (path));
|
||||
void *data = QFS_LoadHunkFile (QFS_FOpenFile (path));
|
||||
*size = qfs_filesize;
|
||||
return data;
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
|
@ -176,7 +176,7 @@ file_error (progs_t *pr, const char *name)
|
|||
}
|
||||
|
||||
static void *
|
||||
load_file (progs_t *pr, const char *name)
|
||||
load_file (progs_t *pr, const char *name, off_t *_size)
|
||||
{
|
||||
QFile *file;
|
||||
int size;
|
||||
|
@ -191,6 +191,7 @@ load_file (progs_t *pr, const char *name)
|
|||
sym = malloc (size + 1);
|
||||
sym[size] = 0;
|
||||
Qread (file, sym, size);
|
||||
*_size = size;
|
||||
return sym;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ open_file (const char *path, int *len)
|
|||
}
|
||||
|
||||
static void *
|
||||
load_file (progs_t *pr, const char *name)
|
||||
load_file (progs_t *pr, const char *name, off_t *_size)
|
||||
{
|
||||
QFile *file;
|
||||
int size;
|
||||
|
@ -112,6 +112,7 @@ load_file (progs_t *pr, const char *name)
|
|||
sym = malloc (size + 1);
|
||||
sym[size] = 0;
|
||||
Qread (file, sym, size);
|
||||
*_size = size;
|
||||
return sym;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ open_file (const char *path, int *len)
|
|||
}
|
||||
|
||||
static void *
|
||||
load_file (progs_t *pr, const char *name)
|
||||
load_file (progs_t *pr, const char *name, off_t *_size)
|
||||
{
|
||||
QFile *file;
|
||||
int size;
|
||||
|
@ -81,6 +81,7 @@ load_file (progs_t *pr, const char *name)
|
|||
sym = malloc (size + 1);
|
||||
sym[size] = 0;
|
||||
Qread (file, sym, size);
|
||||
*_size = size;
|
||||
return sym;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ open_file (const char *path, int *len)
|
|||
}
|
||||
|
||||
static void *
|
||||
load_file (progs_t *pr, const char *name)
|
||||
load_file (progs_t *pr, const char *name, off_t *_size)
|
||||
{
|
||||
QFile *file;
|
||||
int size;
|
||||
|
@ -87,6 +87,7 @@ load_file (progs_t *pr, const char *name)
|
|||
sym = malloc (size + 1);
|
||||
sym[size] = 0;
|
||||
Qread (file, sym, size);
|
||||
*_size = size;
|
||||
return sym;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue