diff --git a/include/QF/quakefs.h b/include/QF/quakefs.h index 0f1e8775a..0279c9237 100644 --- a/include/QF/quakefs.h +++ b/include/QF/quakefs.h @@ -116,6 +116,8 @@ const char *QFS_FileExtension (const char *in); void QFS_GamedirCallback (gamedir_callback_t *); filelist_t *QFS_FilelistNew (void); +void QFS_FilelistAdd (filelist_t *filelist, const char *fname, + const char *ext); void QFS_FilelistFill (filelist_t *list, const char *path, const char *ext, int strip); void QFS_FilelistFree (filelist_t *list); diff --git a/libs/console/filelist.c b/libs/console/filelist.c index 5aacb7fa1..9fdcd8cef 100644 --- a/libs/console/filelist.c +++ b/libs/console/filelist.c @@ -176,7 +176,7 @@ Con_Skyboxlist_f (void) } if (c == 5) - QFS_FilelistFill (cutlist, basename, 0, 0); + QFS_FilelistAdd (cutlist, basename, 0); } } filelist_print (cutlist); diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 245ce761a..ae5ca8847 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -1389,14 +1389,14 @@ QFS_FilelistNew (void) return calloc (1, sizeof (filelist_t)); } -static void -filelist_add_file (filelist_t *filelist, char *fname, const char *ext) +void +QFS_FilelistAdd (filelist_t *filelist, const char *fname, const char *ext) { char **new_list; - char *s; + char *s, *str; while ((s = strchr(fname, '/'))) - fname = s+1; + fname = s + 1; if (filelist->count == filelist->size) { filelist->size += 32; new_list = realloc (filelist->list, filelist->size * sizeof (char *)); @@ -1407,11 +1407,11 @@ filelist_add_file (filelist_t *filelist, char *fname, const char *ext) } filelist->list = new_list; } - fname = strdup (fname); + str = strdup (fname); - if (ext && (s = strstr(fname, va(".%s", ext)))) + if (ext && (s = strstr(str, va(".%s", ext)))) *s = 0; - filelist->list[filelist->count++] = fname; + filelist->list[filelist->count++] = str; } void @@ -1433,7 +1433,7 @@ QFS_FilelistFill (filelist_t *list, const char *path, const char *ext, if (!fnmatch (va("%s*.%s", path, ext), name, FNM_PATHNAME) || !fnmatch (va("%s*.%s.gz", path, ext), name, FNM_PATHNAME)) - filelist_add_file (list, name, strip ? ext : 0); + QFS_FilelistAdd (list, name, strip ? ext : 0); } } else { snprintf (buf, sizeof (buf), "%s/%s", search->filename, path); @@ -1443,7 +1443,7 @@ QFS_FilelistFill (filelist_t *list, const char *path, const char *ext, while ((dirent = readdir (dir_ptr))) if (!fnmatch (va("*.%s", ext), dirent->d_name, 0) || !fnmatch (va("*.%s.gz", ext), dirent->d_name, 0)) - filelist_add_file (list, dirent->d_name, strip ? ext : 0); + QFS_FilelistAdd (list, dirent->d_name, strip ? ext : 0); closedir (dir_ptr); } }