mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-18 13:12:16 +00:00
strip parameter to QFS_FilelistFill and add rua support
This commit is contained in:
parent
e8f9761d33
commit
616be68bdd
4 changed files with 51 additions and 16 deletions
|
@ -116,7 +116,8 @@ const char *QFS_FileExtension (const char *in);
|
||||||
void QFS_GamedirCallback (gamedir_callback_t *);
|
void QFS_GamedirCallback (gamedir_callback_t *);
|
||||||
|
|
||||||
filelist_t *QFS_FilelistNew (void);
|
filelist_t *QFS_FilelistNew (void);
|
||||||
void QFS_FilelistFill (filelist_t *list, const char *path, const char *ext);
|
void QFS_FilelistFill (filelist_t *list, const char *path, const char *ext,
|
||||||
|
int strip);
|
||||||
void QFS_FilelistFree (filelist_t *list);
|
void QFS_FilelistFree (filelist_t *list);
|
||||||
|
|
||||||
// FIXME: This is here temporarily until fs_usercfg gets sorted out
|
// FIXME: This is here temporarily until fs_usercfg gets sorted out
|
||||||
|
|
|
@ -120,7 +120,7 @@ Con_Maplist_f (void)
|
||||||
{
|
{
|
||||||
filelist_t *maplist = QFS_FilelistNew ();
|
filelist_t *maplist = QFS_FilelistNew ();
|
||||||
|
|
||||||
QFS_FilelistFill (maplist, "maps/", "bsp");
|
QFS_FilelistFill (maplist, "maps/", "bsp", 1);
|
||||||
|
|
||||||
filelist_print (maplist);
|
filelist_print (maplist);
|
||||||
QFS_FilelistFree (maplist);
|
QFS_FilelistFree (maplist);
|
||||||
|
@ -131,7 +131,7 @@ Con_Skinlist_f (void)
|
||||||
{
|
{
|
||||||
filelist_t *skinlist = QFS_FilelistNew ();
|
filelist_t *skinlist = QFS_FilelistNew ();
|
||||||
|
|
||||||
QFS_FilelistFill (skinlist, "skins/", "pcx");
|
QFS_FilelistFill (skinlist, "skins/", "pcx", 1);
|
||||||
|
|
||||||
filelist_print (skinlist);
|
filelist_print (skinlist);
|
||||||
QFS_FilelistFree (skinlist);
|
QFS_FilelistFree (skinlist);
|
||||||
|
@ -156,8 +156,8 @@ Con_Skyboxlist_f (void)
|
||||||
filelist_t *skyboxlist = QFS_FilelistNew ();
|
filelist_t *skyboxlist = QFS_FilelistNew ();
|
||||||
filelist_t *cutlist = QFS_FilelistNew ();
|
filelist_t *cutlist = QFS_FilelistNew ();
|
||||||
|
|
||||||
QFS_FilelistFill (skyboxlist, "env/", "tga");
|
QFS_FilelistFill (skyboxlist, "env/", "tga", 1);
|
||||||
QFS_FilelistFill (skyboxlist, "env/", "pcx");
|
QFS_FilelistFill (skyboxlist, "env/", "pcx", 1);
|
||||||
|
|
||||||
for (i = 0; i < skyboxlist->count; i++) {
|
for (i = 0; i < skyboxlist->count; i++) {
|
||||||
if (strlen(skyboxlist->list[i]) > strlen(sb_endings[0]) && strcmp(skyboxlist->list[i] + strlen(skyboxlist->list[i]) - strlen(sb_endings[0]), sb_endings[0]) == 0) {
|
if (strlen(skyboxlist->list[i]) > strlen(sb_endings[0]) && strcmp(skyboxlist->list[i] + strlen(skyboxlist->list[i]) - strlen(sb_endings[0]), sb_endings[0]) == 0) {
|
||||||
|
@ -176,7 +176,7 @@ Con_Skyboxlist_f (void)
|
||||||
|
|
||||||
}
|
}
|
||||||
if (c == 5)
|
if (c == 5)
|
||||||
QFS_FilelistFill (cutlist, basename, 0);
|
QFS_FilelistFill (cutlist, basename, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filelist_print (cutlist);
|
filelist_print (cutlist);
|
||||||
|
@ -189,7 +189,7 @@ Con_Demolist_QWD_f (void)
|
||||||
{
|
{
|
||||||
filelist_t *demolist = QFS_FilelistNew ();
|
filelist_t *demolist = QFS_FilelistNew ();
|
||||||
|
|
||||||
QFS_FilelistFill (demolist, "", "qwd");
|
QFS_FilelistFill (demolist, "", "qwd", 1);
|
||||||
|
|
||||||
filelist_print (demolist);
|
filelist_print (demolist);
|
||||||
QFS_FilelistFree (demolist);
|
QFS_FilelistFree (demolist);
|
||||||
|
@ -202,7 +202,7 @@ Con_Demolist_DEM_f (void)
|
||||||
{
|
{
|
||||||
filelist_t *demolist = QFS_FilelistNew ();
|
filelist_t *demolist = QFS_FilelistNew ();
|
||||||
|
|
||||||
QFS_FilelistFill (demolist, "", "dem");
|
QFS_FilelistFill (demolist, "", "dem", 1);
|
||||||
|
|
||||||
filelist_print (demolist);
|
filelist_print (demolist);
|
||||||
QFS_FilelistFree (demolist);
|
QFS_FilelistFree (demolist);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
bi_file.c
|
rua_qfs.c
|
||||||
|
|
||||||
CSQC file builtins
|
CSQC file builtins
|
||||||
|
|
||||||
|
@ -46,6 +46,11 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
|
|
||||||
#include "rua_internal.h"
|
#include "rua_internal.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int count;
|
||||||
|
pointer_t list;
|
||||||
|
} qfslist_t;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_buffer (progs_t *pr, pr_type_t *buf, int count, const char *name)
|
check_buffer (progs_t *pr, pr_type_t *buf, int count, const char *name)
|
||||||
{
|
{
|
||||||
|
@ -117,11 +122,39 @@ bi_QFS_WriteFile (progs_t *pr)
|
||||||
QFS_WriteFile (va ("%s/%s", qfs_gamedir->dir.def, filename), buf, count);
|
QFS_WriteFile (va ("%s/%s", qfs_gamedir->dir.def, filename), buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bi_QFS_Filelist (progs_t *pr)
|
||||||
|
{
|
||||||
|
filelist_t *filelist = QFS_FilelistNew ();
|
||||||
|
qfslist_t *list;
|
||||||
|
string_t *strings;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
QFS_FilelistFill (filelist, P_GSTRING (pr, 0), P_GSTRING (pr, 1),
|
||||||
|
P_INT (pr, 2));
|
||||||
|
|
||||||
|
list = PR_Zone_Malloc (pr, sizeof (list) + filelist->count * 4);
|
||||||
|
list->count = filelist->count;
|
||||||
|
strings = (string_t *) list + 1;
|
||||||
|
list->list = POINTER_TO_PROG (pr, strings);
|
||||||
|
for (i = 0; i < filelist->count; i++)
|
||||||
|
strings[i] = PR_SetString (pr, filelist->list[i]);
|
||||||
|
RETURN_POINTER (pr, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bi_QFS_FilelistFree (progs_t *pr)
|
||||||
|
{
|
||||||
|
PR_Zone_Free (pr, P_GPOINTER (pr, 0));
|
||||||
|
}
|
||||||
|
|
||||||
static builtin_t builtins[] = {
|
static builtin_t builtins[] = {
|
||||||
{"QFS_Rename", bi_QFS_Rename, -1},
|
{"QFS_Rename", bi_QFS_Rename, -1},
|
||||||
{"QFS_LoadFile", bi_QFS_LoadFile, -1},
|
{"QFS_LoadFile", bi_QFS_LoadFile, -1},
|
||||||
{"QFS_OpenFile", bi_QFS_OpenFile, -1},
|
{"QFS_OpenFile", bi_QFS_OpenFile, -1},
|
||||||
{"QFS_WriteFile", bi_QFS_WriteFile, -1},
|
{"QFS_WriteFile", bi_QFS_WriteFile, -1},
|
||||||
|
{"QFS_Filelist", bi_QFS_Filelist, -1},
|
||||||
|
{"QFS_FilelistFree", bi_QFS_FilelistFree, -1},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1415,7 +1415,8 @@ filelist_add_file (filelist_t *filelist, char *fname, const char *ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QFS_FilelistFill (filelist_t *list, const char *path, const char *ext)
|
QFS_FilelistFill (filelist_t *list, const char *path, const char *ext,
|
||||||
|
int strip)
|
||||||
{
|
{
|
||||||
searchpath_t *search;
|
searchpath_t *search;
|
||||||
DIR *dir_ptr;
|
DIR *dir_ptr;
|
||||||
|
@ -1432,7 +1433,7 @@ QFS_FilelistFill (filelist_t *list, const char *path, const char *ext)
|
||||||
|
|
||||||
if (!fnmatch (va("%s*.%s", path, ext), name, FNM_PATHNAME)
|
if (!fnmatch (va("%s*.%s", path, ext), name, FNM_PATHNAME)
|
||||||
|| !fnmatch (va("%s*.%s.gz", path, ext), name, FNM_PATHNAME))
|
|| !fnmatch (va("%s*.%s.gz", path, ext), name, FNM_PATHNAME))
|
||||||
filelist_add_file (list, name, ext);
|
filelist_add_file (list, name, strip ? ext : 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
snprintf (buf, sizeof (buf), "%s/%s", search->filename, path);
|
snprintf (buf, sizeof (buf), "%s/%s", search->filename, path);
|
||||||
|
@ -1442,7 +1443,7 @@ QFS_FilelistFill (filelist_t *list, const char *path, const char *ext)
|
||||||
while ((dirent = readdir (dir_ptr)))
|
while ((dirent = readdir (dir_ptr)))
|
||||||
if (!fnmatch (va("*.%s", ext), dirent->d_name, 0)
|
if (!fnmatch (va("*.%s", ext), dirent->d_name, 0)
|
||||||
|| !fnmatch (va("*.%s.gz", ext), dirent->d_name, 0))
|
|| !fnmatch (va("*.%s.gz", ext), dirent->d_name, 0))
|
||||||
filelist_add_file (list, dirent->d_name, ext);
|
filelist_add_file (list, dirent->d_name, strip ? ext : 0);
|
||||||
closedir (dir_ptr);
|
closedir (dir_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue