Quake II RTX doxygen
1.0 dev
|
|
#include "shared/shared.h"
#include "shared/list.h"
#include "common/common.h"
#include "common/cvar.h"
#include "common/error.h"
#include "common/files.h"
#include "common/prompt.h"
#include "system/system.h"
#include "client/client.h"
#include "format/pak.h"
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Go to the source code of this file.
|
#define | MAX_FILE_HANDLES 32 |
|
#define | FS_DPrintf(...) |
|
#define | PATH_NOT_CHECKED -1 |
|
#define | FOR_EACH_SYMLINK(link, list) LIST_FOR_EACH(symlink_t, link, list, entry) |
|
#define | FOR_EACH_SYMLINK_SAFE(link, next, list) LIST_FOR_EACH_SAFE(symlink_t, link, next, list, entry) |
|
#define | FS_COUNT_READ (void)0 |
|
#define | FS_COUNT_OPEN (void)0 |
|
#define | FS_COUNT_STRCMP (void)0 |
|
#define | FS_COUNT_STRLWR (void)0 |
|
#define | FS_ERR_READ(fp) (ferror(fp) ? Q_Errno() : Q_ERR_UNEXPECTED_EOF) |
|
#define | FS_ERR_WRITE(fp) (ferror(fp) ? Q_Errno() : Q_ERR_FAILURE) |
|
#define | PAK_EXT ".pak" |
|
|
static pack_t * | pack_get (pack_t *pack) |
|
static void | pack_put (pack_t *pack) |
|
char * | FS_ReplaceSeparators (char *s, int separator) |
|
static qboolean | validate_char (int c) |
|
int | FS_ValidatePath (const char *s) |
|
void | FS_SanitizeFilenameVariable (cvar_t *var) |
|
size_t | FS_NormalizePath (char *out, const char *in) |
|
size_t | FS_NormalizePathBuffer (char *out, const char *in, size_t size) |
|
static file_t * | alloc_handle (qhandle_t *f) |
|
static file_t * | file_for_handle (qhandle_t f) |
|
static void | cleanup_path (char *s) |
|
static symlink_t * | expand_links (list_t *list, char *buffer, size_t *len_p) |
|
ssize_t | FS_Length (qhandle_t f) |
|
ssize_t | FS_Tell (qhandle_t f) |
|
static qerror_t | seek_pak_file (file_t *file, off_t offset) |
|
qerror_t | FS_Seek (qhandle_t f, off_t offset) |
|
qerror_t | FS_CreatePath (char *path) |
|
qerror_t | FS_FilterFile (qhandle_t f) |
|
void | FS_FCloseFile (qhandle_t f) |
|
static qerror_t | get_path_info (const char *path, file_info_t *info) |
|
static qerror_t | get_fp_info (FILE *fp, file_info_t *info) |
|
static FILE * | fopen_hack (const char *path, const char *mode) |
|
static ssize_t | open_file_write (file_t *file, const char *name) |
|
static ssize_t | open_from_pak (file_t *file, pack_t *pack, packfile_t *entry, qboolean unique) |
|
static ssize_t | open_from_disk (file_t *file, const char *fullpath) |
|
qerror_t | FS_LastModified (char const *file, uint64_t *last_modified) |
|
static ssize_t | open_file_read (file_t *file, const char *normalized, size_t namelen, qboolean unique) |
|
static ssize_t | expand_open_file_read (file_t *file, const char *name, qboolean unique) |
|
static ssize_t | read_pak_file (file_t *file, void *buf, size_t len) |
|
static ssize_t | read_phys_file (file_t *file, void *buf, size_t len) |
|
ssize_t | FS_Read (void *buf, size_t len, qhandle_t f) |
|
ssize_t | FS_ReadLine (qhandle_t f, char *buffer, size_t size) |
|
void | FS_Flush (qhandle_t f) |
|
ssize_t | FS_Write (const void *buf, size_t len, qhandle_t f) |
|
ssize_t | FS_FOpenFile (const char *name, qhandle_t *f, unsigned mode) |
|
static qhandle_t | easy_open_read (char *buf, size_t size, unsigned mode, const char *dir, const char *name, const char *ext) |
|
static qhandle_t | easy_open_write (char *buf, size_t size, unsigned mode, const char *dir, const char *name, const char *ext) |
|
qhandle_t | FS_EasyOpenFile (char *buf, size_t size, unsigned mode, const char *dir, const char *name, const char *ext) |
|
ssize_t | FS_LoadFileEx (const char *path, void **buffer, unsigned flags, memtag_t tag) |
|
qerror_t | FS_WriteFile (const char *path, const void *data, size_t len) |
|
qboolean | FS_EasyWriteFile (char *buf, size_t size, unsigned mode, const char *dir, const char *name, const char *ext, const void *data, size_t len) |
|
ssize_t | FS_FPrintf (qhandle_t f, const char *format,...) |
|
static pack_t * | pack_alloc (FILE *fp, filetype_t type, const char *name, unsigned num_files, size_t names_len) |
|
static void | pack_hash_file (pack_t *pack, packfile_t *file) |
|
static pack_t * | load_pak_file (const char *packfile) |
|
static int | pakcmp (const void *p1, const void *p2) |
|
static void | q_printf (2, 3) |
|
file_info_t * | FS_CopyInfo (const char *name, size_t size, time_t ctime, time_t mtime) |
|
void ** | FS_CopyList (void **list, int count) |
|
qboolean | FS_WildCmp (const char *filter, const char *string) |
|
qboolean | FS_ExtCmp (const char *ext, const char *name) |
|
static int | infocmp (const void *p1, const void *p2) |
|
static int | alphacmp (const void *p1, const void *p2) |
|
void ** | FS_ListFiles (const char *path, const char *filter, unsigned flags, int *count_p) |
|
void | FS_FreeList (void **list) |
|
void | FS_File_g (const char *path, const char *ext, unsigned flags, genctx_t *ctx) |
|
static void | print_file_list (const char *path, const char *ext, unsigned flags) |
|
static void | FS_FDir_f (void) |
|
static void | FS_Dir_f (void) |
|
static void | FS_WhereIs_f (void) |
|
static void | FS_Path_f (void) |
|
static void | FS_Link_g (genctx_t *ctx) |
|
static void | FS_Link_c (genctx_t *ctx, int argnum) |
|
static void | free_all_links (list_t *list) |
|
static void | FS_UnLink_f (void) |
|
static void | FS_Link_f (void) |
|
static void | free_search_path (searchpath_t *path) |
|
static void | free_all_paths (void) |
|
static void | free_game_paths (void) |
|
static void | setup_base_paths (void) |
|
static void | setup_game_paths (void) |
|
void | FS_Restart (qboolean total) |
|
static void | FS_Restart_f (void) |
|
void | FS_Shutdown (void) |
|
static void | fs_game_changed (cvar_t *self) |
|
void | FS_Init (void) |
|
◆ FOR_EACH_SYMLINK
#define FOR_EACH_SYMLINK |
( |
|
link, |
|
|
|
list |
|
) |
| LIST_FOR_EACH(symlink_t, link, list, entry) |
◆ FOR_EACH_SYMLINK_SAFE
#define FOR_EACH_SYMLINK_SAFE |
( |
|
link, |
|
|
|
next, |
|
|
|
list |
|
) |
| LIST_FOR_EACH_SAFE(symlink_t, link, next, list, entry) |
◆ FS_COUNT_OPEN
#define FS_COUNT_OPEN (void)0 |
◆ FS_COUNT_READ
#define FS_COUNT_READ (void)0 |
◆ FS_COUNT_STRCMP
#define FS_COUNT_STRCMP (void)0 |
◆ FS_COUNT_STRLWR
#define FS_COUNT_STRLWR (void)0 |
◆ FS_DPrintf
#define FS_DPrintf |
( |
|
... | ) |
|
◆ FS_ERR_READ
#define FS_ERR_READ |
( |
|
fp | ) |
(ferror(fp) ? Q_Errno() : Q_ERR_UNEXPECTED_EOF) |
◆ FS_ERR_WRITE
#define FS_ERR_WRITE |
( |
|
fp | ) |
(ferror(fp) ? Q_Errno() : Q_ERR_FAILURE) |
◆ MAX_FILE_HANDLES
#define MAX_FILE_HANDLES 32 |
◆ PAK_EXT
◆ PATH_NOT_CHECKED
#define PATH_NOT_CHECKED -1 |
◆ packfile_t
◆ searchpath_t
◆ filetype_t
Enumerator |
---|
FS_FREE | |
FS_REAL | |
FS_PAK | |
FS_BAD | |
Definition at line 95 of file files.c.
◆ alloc_handle()
static file_t* alloc_handle |
( |
qhandle_t * |
f | ) |
|
|
static |
◆ alphacmp()
static int alphacmp |
( |
const void * |
p1, |
|
|
const void * |
p2 |
|
) |
| |
|
static |
Definition at line 2703 of file files.c.
2705 char *s1 = *(
char **)p1;
2706 char *s2 = *(
char **)p2;
2708 return FS_pathcmp(s1, s2);
Referenced by FS_ListFiles(), and pakcmp().
◆ cleanup_path()
static void cleanup_path |
( |
char * |
s | ) |
|
|
static |
◆ easy_open_read()
static qhandle_t easy_open_read |
( |
char * |
buf, |
|
|
size_t |
size, |
|
|
unsigned |
mode, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
const char * |
ext |
|
) |
| |
|
static |
Definition at line 1730 of file files.c.
1741 len =
Q_concat(buf, size, dir, name, NULL);
1743 Q_PrintError(
"open", Q_ERR_NAMETOOLONG);
1754 if (len != Q_ERR_NOENT) {
1757 if (!COM_CompareExtension(buf,
ext)) {
1766 Q_PrintError(
"open", Q_ERR_NAMETOOLONG);
1776 Com_Printf(
"Couldn't open %s: %s\n", buf,
Q_ErrorString(len));
Referenced by FS_EasyOpenFile().
◆ easy_open_write()
static qhandle_t easy_open_write |
( |
char * |
buf, |
|
|
size_t |
size, |
|
|
unsigned |
mode, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
const char * |
ext |
|
) |
| |
|
static |
Definition at line 1781 of file files.c.
1784 char normalized[MAX_OSPATH];
1790 if (len >=
sizeof(normalized)) {
1791 Q_PrintError(
"open", Q_ERR_NAMETOOLONG);
1797 Q_PrintError(
"open", Q_ERR_NAMETOOSHORT);
1805 if (!COM_CompareExtension(normalized,
ext)) {
1806 ext = (mode & FS_FLAG_GZIP) ?
"" : NULL;
1810 (mode & FS_FLAG_GZIP) ?
".gz" : NULL, NULL);
1812 Q_PrintError(
"open", Q_ERR_NAMETOOLONG);
1821 if (mode & FS_FLAG_GZIP) {
1833 Com_EPrintf(
"Couldn't open %s: %s\n", buf,
Q_ErrorString(len));
Referenced by FS_EasyOpenFile(), and FS_EasyWriteFile().
◆ expand_links()
static symlink_t* expand_links |
( |
list_t * |
list, |
|
|
char * |
buffer, |
|
|
size_t * |
len_p |
|
) |
| |
|
static |
◆ expand_open_file_read()
static ssize_t expand_open_file_read |
( |
file_t * |
file, |
|
|
const char * |
name, |
|
|
qboolean |
unique |
|
) |
| |
|
static |
Definition at line 1468 of file files.c.
1470 char normalized[MAX_OSPATH];
1476 if (namelen >= MAX_OSPATH) {
1477 return Q_ERR_NAMETOOLONG;
1482 return Q_ERR_NAMETOOLONG;
1487 return Q_ERR_NAMETOOSHORT;
1491 if (ret == Q_ERR_NOENT) {
1494 if (namelen >= MAX_OSPATH) {
1495 return Q_ERR_NAMETOOLONG;
Referenced by FS_FOpenFile(), and FS_LoadFileEx().
◆ file_for_handle()
static file_t* file_for_handle |
( |
qhandle_t |
f | ) |
|
|
static |
Definition at line 430 of file files.c.
442 Com_Error(ERR_FATAL,
"%s: bad file type", __func__);
Referenced by FS_FCloseFile(), FS_FilterFile(), FS_Flush(), FS_Length(), FS_Read(), FS_ReadLine(), FS_Seek(), FS_Tell(), and FS_Write().
◆ fopen_hack()
static FILE* fopen_hack |
( |
const char * |
path, |
|
|
const char * |
mode |
|
) |
| |
|
inlinestatic |
Definition at line 844 of file files.c.
847 if (mode[0] ==
'w' && mode[1] ==
'x') {
849 int flags = _O_WRONLY | _O_CREAT | _O_EXCL | _S_IREAD | _S_IWRITE;
856 fd = _open(path, flags);
860 fp = _fdopen(fd, (flags & _O_BINARY) ?
"wb" :
"w");
866 int flags = O_WRONLY | O_CREAT | O_EXCL;
867 int perm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
871 fd = open(path, flags, perm);
875 fp = fdopen(fd,
"wb");
882 #endif // _GNU_SOURCE
884 return fopen(path, mode);
Referenced by open_file_write().
◆ free_all_links()
static void free_all_links |
( |
list_t * |
list | ) |
|
|
static |
◆ free_all_paths()
◆ free_game_paths()
◆ free_search_path()
◆ FS_CopyInfo()
file_info_t* FS_CopyInfo |
( |
const char * |
name, |
|
|
size_t |
size, |
|
|
time_t |
ctime, |
|
|
time_t |
mtime |
|
) |
| |
◆ FS_CopyList()
Definition at line 2618 of file files.c.
2627 out = FS_Malloc(
sizeof(
void *) * (count + 1));
2628 for (i = 0; i < count; i++) {
◆ FS_CreatePath()
qerror_t FS_CreatePath |
( |
char * |
path | ) |
|
Definition at line 605 of file files.c.
614 if (*path ==
'/' && path[1] ==
'/') {
617 p = strchr(path + 2,
'/');
619 p = strchr(p + 1,
'/');
628 for (; *ofs ==
'/'; ofs++)
631 for (; *ofs; ofs++) {
635 ret = os_mkdir(path);
638 qerror_t
err = Q_Errno();
639 if (
err != Q_ERR_EXIST)
645 return Q_ERR_SUCCESS;
Referenced by copy_file(), open_file_write(), and start_download().
◆ FS_Dir_f()
Definition at line 3029 of file files.c.
3034 Com_Printf(
"Usage: %s <directory> [.extension]\n",
Cmd_Argv(0));
◆ FS_EasyOpenFile()
qhandle_t FS_EasyOpenFile |
( |
char * |
buf, |
|
|
size_t |
size, |
|
|
unsigned |
mode, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
const char * |
ext |
|
) |
| |
Definition at line 1846 of file files.c.
1849 if ((mode & FS_MODE_MASK) == FS_MODE_READ) {
Referenced by CL_PlayDemo_f(), CL_Record_f(), CL_WriteConfig_f(), Con_Dump_f(), create_screenshot(), dummy_record_f(), IMG_List_f(), LOC_Write_f(), logfile_open(), MVD_Play_f(), MVD_StreamedRecord_f(), SCR_ScoreShot_f(), SV_MvdRecord_f(), and writeMaterialsTable().
◆ FS_EasyWriteFile()
qboolean FS_EasyWriteFile |
( |
char * |
buf, |
|
|
size_t |
size, |
|
|
unsigned |
mode, |
|
|
const char * |
dir, |
|
|
const char * |
name, |
|
|
const char * |
ext, |
|
|
const void * |
data, |
|
|
size_t |
len |
|
) |
| |
◆ FS_ExtCmp()
qboolean FS_ExtCmp |
( |
const char * |
ext, |
|
|
const char * |
name |
|
) |
| |
◆ FS_FCloseFile()
void FS_FCloseFile |
( |
qhandle_t |
f | ) |
|
Definition at line 759 of file files.c.
766 switch (file->
type) {
783 close_zip_file(file);
792 memset(file, 0,
sizeof(*file));
Referenced by CL_CleanupDemos(), CL_CleanupDownloads(), CL_GetDemoInfo(), CL_HandleDownload(), CL_PlayDemo_f(), CL_Stop_f(), CL_WriteConfig(), CL_WriteConfig_f(), Con_Dump_f(), demo_destroy(), demo_play_next(), dummy_record_f(), easy_open_write(), finish_udp_download(), FS_EasyWriteFile(), FS_LoadFileEx(), FS_Shutdown(), FS_WriteFile(), get_image_dimensions(), IMG_List_f(), LOC_Write_f(), logfile_close(), logfile_write(), make_screenshot(), MVD_Play_f(), MVD_StopRecord(), Prompt_LoadHistory(), Prompt_SaveHistory(), read_binary_file(), rec_stop(), SCR_ScoreShot_f(), SCR_StopCinematic(), SV_BeginDownload_f(), SV_MvdRecord_f(), WriteCache(), and writeMaterialsTable().
◆ FS_FDir_f()
Definition at line 3004 of file files.c.
3010 Com_Printf(
"Usage: %s <filter> [full_path]\n",
Cmd_Argv(0));
3016 flags = FS_SEARCH_BYFILTER;
3018 flags |= FS_SEARCH_SAVEPATH;
◆ FS_File_g()
void FS_File_g |
( |
const char * |
path, |
|
|
const char * |
ext, |
|
|
unsigned |
flags, |
|
|
genctx_t * |
ctx |
|
) |
| |
◆ FS_FilterFile()
qerror_t FS_FilterFile |
( |
qhandle_t |
f | ) |
|
Definition at line 661 of file files.c.
675 switch (file->
type) {
677 return Q_ERR_SUCCESS;
684 mode = file->
mode & FS_MODE_MASK;
689 return Q_ERR_FILE_TOO_SMALL;
693 if (fseek(file->
fp, 0, SEEK_SET) == -1) {
698 if (fread(&magic, 1, 4, file->
fp) != 4) {
703 if (!CHECK_GZIP_HEADER(magic)) {
704 return Q_ERR_INVALID_FORMAT;
708 if (fseek(file->
fp, file->
length - 4, SEEK_SET) == -1) {
713 if (fread(&magic, 1, 4, file->
fp) != 4) {
717 length = LittleLong(magic);
731 if (fseek(file->
fp, 0, SEEK_SET) == -1) {
735 fd = os_fileno(file->
fp);
739 zfp = gzdopen(fd, modeStr);
741 return Q_ERR_FAILURE;
747 return Q_ERR_SUCCESS;
Referenced by demo_read_first(), easy_open_write(), and read_first_message().
◆ FS_Flush()
void FS_Flush |
( |
qhandle_t |
f | ) |
|
Definition at line 1617 of file files.c.
1624 switch (file->
type) {
1630 gzflush(file->zfp, Z_SYNC_FLUSH);
Referenced by Com_Error().
◆ FS_FOpenFile()
ssize_t FS_FOpenFile |
( |
const char * |
name, |
|
|
qhandle_t * |
f, |
|
|
unsigned |
mode |
|
) |
| |
Definition at line 1692 of file files.c.
1699 Com_Error(ERR_FATAL,
"%s: NULL", __func__);
1716 if ((mode & FS_MODE_MASK) == FS_MODE_READ) {
Referenced by CL_GetDemoInfo(), CL_HandleDownload(), CL_WriteConfig(), create_screenshot(), demo_play_next(), easy_open_read(), easy_open_write(), FS_WriteFile(), get_image_dimensions(), Prompt_LoadHistory(), Prompt_SaveHistory(), read_binary_file(), SCR_PlayCinematic(), SCR_ScoreShot_f(), start_udp_download(), SV_BeginDownload_f(), and WriteCache().
◆ FS_FPrintf()
ssize_t FS_FPrintf |
( |
qhandle_t |
f, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
Definition at line 2039 of file files.c.
2042 char string[MAXPRINTMSG];
2045 va_start(argptr, format);
2046 len =
Q_vsnprintf(
string,
sizeof(
string), format, argptr);
2049 if (len >=
sizeof(
string)) {
2050 return Q_ERR_STRING_TRUNCATED;
Referenced by CL_WriteConfig(), CL_WriteConfig_f(), Com_Error(), Con_Dump_f(), IMG_List_f(), Key_WriteBindings(), LOC_Write_f(), Prompt_SaveHistory(), WriteCache(), and writeMaterialsTable().
◆ FS_FreeList()
◆ fs_game_changed()
static void fs_game_changed |
( |
cvar_t * |
self | ) |
|
|
static |
Definition at line 3650 of file files.c.
3652 char *s =
self->string;
3656 if (!Q_stricmp(s, BASEGAME)) {
3659 Com_Printf(
"'%s' should contain characters [A-Za-z0-9_-] only.\n", self->name);
3676 if (FS_FileExists(
"maps/base1.bsp"))
3681 if (!FS_FileExists(
"pics/colormap.pcx") || !FS_FileExists(
"pics/conchars.pcx") || !FS_FileExists(
"default.cfg"))
3683 Com_Error(ERR_FATAL,
"No game data files detected. Please make sure that there are .pak files"
3684 " in the game directory: %s.\nReinstalling the game can fix the issue.",
fs_gamedir);
3696 if (!FS_FileExistsEx(COM_AUTOEXEC_CFG, FS_TYPE_REAL | FS_PATH_BASE)) {
Referenced by FS_Init().
◆ FS_Init()
Definition at line 3714 of file files.c.
3716 Com_Printf(
"------- FS_Init -------\n");
3724 fs_debug =
Cvar_Get(
"fs_debug",
"0", 0);
3734 Com_Printf(
"-----------------------\n");
Referenced by Qcommon_Init().
◆ FS_LastModified()
qerror_t FS_LastModified |
( |
char const * |
file, |
|
|
uint64_t * |
last_modified |
|
) |
| |
Definition at line 1310 of file files.c.
1312 #ifndef NO_TEXTURE_RELOADS
1313 char fullpath[MAX_OSPATH];
1332 if (valid == PATH_INVALID) {
1337 len =
Q_concat(fullpath,
sizeof(fullpath), search->
filename,
"/", file, NULL);
1338 if (len >=
sizeof(fullpath)) {
1339 return Q_ERR_NAMETOOLONG;
1343 if (stat(fullpath, &lstat) == 0) {
1345 *last_modified = lstat.st_mtime;
1346 return Q_ERR_SUCCESS;
1353 return Q_ERR_INVALID_PATH;
Referenced by _try_image_format(), find_or_load_image(), and IMG_ReloadAll().
◆ FS_Length()
ssize_t FS_Length |
( |
qhandle_t |
f | ) |
|
◆ FS_Link_c()
static void FS_Link_c |
( |
genctx_t * |
ctx, |
|
|
int |
argnum |
|
) |
| |
|
static |
◆ FS_Link_f()
Definition at line 3403 of file files.c.
3408 size_t namelen, targlen;
3409 char name[MAX_OSPATH];
3410 char target[MAX_OSPATH];
3412 if (!strncmp(
Cmd_Argv(0),
"soft", 4))
3421 Com_Printf(
"%s --> %s\n", link->
name, link->
target);
3424 Com_Printf(
"------------------\n"
3425 "%d symbolic link%s listed.\n", count, count == 1 ?
"" :
"s");
3430 Com_Printf(
"Usage: %s <name> <target>\n"
3431 "Creates symbolic link to target with the specified name.\n"
3432 "Virtual quake paths are accepted.\n"
3433 "Links are effective only for reading.\n",
3439 if (namelen == 0 || namelen >=
sizeof(name)) {
3440 Com_Printf(
"Invalid symbolic link name.\n");
3445 if (targlen == 0 || targlen >=
sizeof(target)) {
3446 Com_Printf(
"Invalid symbolic link target.\n");
3452 if (!FS_pathcmp(link->
name, name)) {
3459 link = FS_Malloc(
sizeof(*link) + namelen);
3460 memcpy(link->
name, name, namelen + 1);
3462 List_Append(list, &link->
entry);
3465 link->
target = FS_CopyString(target);
◆ FS_Link_g()
static void FS_Link_g |
( |
genctx_t * |
ctx | ) |
|
|
static |
◆ FS_ListFiles()
void** FS_ListFiles |
( |
const char * |
path, |
|
|
const char * |
filter, |
|
|
unsigned |
flags, |
|
|
int * |
count_p |
|
) |
| |
Definition at line 2716 of file files.c.
2723 void *files[MAX_LISTED_FILES], *info;
2724 int i, j, count, total;
2725 char normalized[MAX_OSPATH], buffer[MAX_OSPATH];
2727 size_t len, pathlen;
2740 if (pathlen >=
sizeof(normalized)) {
2748 if ((flags & FS_SEARCH_DIRSONLY) && (flags & FS_SEARCH_MASK & ~FS_SEARCH_DIRSONLY)) {
2753 if (flags & FS_PATH_MASK) {
2754 if ((flags & search->
mode & FS_PATH_MASK) == 0) {
2759 if ((flags & FS_TYPE_MASK) == FS_TYPE_REAL) {
2769 if (file->
namelen < pathlen) {
2772 if (FS_pathcmpn(s, path, pathlen)) {
2775 if (s[pathlen] !=
'/') {
2778 if (flags & FS_SEARCH_BYFILTER) {
2781 }
else if (path == normalized) {
2782 if (!(flags & FS_SEARCH_DIRSONLY) && strchr(s,
'/')) {
2789 if (flags & FS_SEARCH_BYFILTER) {
2801 if (flags & (FS_SEARCH_DIRSONLY | FS_SEARCH_STRIPEXT)) {
2802 s = strcpy(buffer, s);
2806 if (flags & FS_SEARCH_DIRSONLY) {
2816 for (j = 0; j < count; j++) {
2817 if (!FS_pathcmp(files[j], s)) {
2827 if (!(flags & FS_SEARCH_SAVEPATH)) {
2832 if (flags & FS_SEARCH_STRIPEXT) {
2841 if (flags & FS_SEARCH_EXTRAINFO) {
2844 info = FS_CopyString(s);
2847 files[count++] = info;
2849 if (count >= MAX_LISTED_FILES) {
2854 if ((flags & FS_TYPE_MASK) == FS_TYPE_PAK) {
2861 if (len + pathlen + 1 >= MAX_OSPATH) {
2867 if (valid == PATH_INVALID) {
2870 s = memcpy(buffer, search->
filename, len);
2872 memcpy(s + len, path, pathlen + 1);
2877 if (flags & FS_SEARCH_BYFILTER) {
2884 if (count >= MAX_LISTED_FILES) {
2897 if (flags & FS_SEARCH_EXTRAINFO) {
2899 qsort(files, count,
sizeof(files[0]),
infocmp);
2903 qsort(files, count,
sizeof(files[0]),
alphacmp);
2907 for (i = 1; i < count; i++) {
2908 if (!FS_pathcmp(files[i - 1], files[i])) {
2910 files[i - 1] = NULL;
2917 list = FS_Malloc(
sizeof(
void *) * (total + 1));
2920 for (i = 0; i < count; i++) {
2922 list[total++] = files[i];
Referenced by BSP_Test_f(), BuildList(), Com_MapList_m(), FS_File_g(), list_save_dir(), PlayerModel_Load(), and print_file_list().
◆ FS_LoadFileEx()
ssize_t FS_LoadFileEx |
( |
const char * |
path, |
|
|
void ** |
buffer, |
|
|
unsigned |
flags, |
|
|
memtag_t |
tag |
|
) |
| |
Definition at line 1864 of file files.c.
1872 Com_Error(ERR_FATAL,
"%s: NULL", __func__);
1889 file->
mode = (flags & ~FS_MODE_MASK) | FS_MODE_READ;
1903 if (len > MAX_LOADFILE) {
1914 len = read < 0 ? read : Q_ERR_UNEXPECTED_EOF;
Referenced by Cmd_ExecuteFile(), and LoadCache().
◆ FS_NormalizePath()
size_t FS_NormalizePath |
( |
char * |
out, |
|
|
const char * |
in |
|
) |
| |
Definition at line 331 of file files.c.
339 if (
c ==
'/' ||
c ==
'\\' ||
c == 0) {
340 if ((pre & 0xffffff) == ((
'/' << 16) | (
'.' << 8) |
'.')) {
348 while (out > start && *out !=
'/')
360 if ((pre & 0xffff) == ((
'/' << 8) |
'.')) {
373 if ((pre & 0xff) ==
'/') {
384 pre = (pre << 8) |
c;
Referenced by bsp_mesh_register_textures(), check_and_queue_download(), check_file_len(), Com_TestNorm_f(), easy_open_read(), FS_NormalizePathBuffer(), GL_LoadWorld(), MOD_LoadMD2(), MOD_LoadMD2_GL(), MOD_LoadMD2_RTX(), MOD_LoadSP2(), pack_hash_file(), ProcessTexinfo(), R_RegisterImage(), R_SetSky(), R_SetSky_GL(), R_SetSky_RTX(), S_RegisterSexedSound(), S_RegisterSound(), SV_BeginDownload_f(), and vkpt_textures_prefetch().
◆ FS_NormalizePathBuffer()
size_t FS_NormalizePathBuffer |
( |
char * |
out, |
|
|
const char * |
in, |
|
|
size_t |
size |
|
) |
| |
◆ FS_Path_f()
Definition at line 3223 of file files.c.
3226 int numFilesInPAK = 0;
3228 int numFilesInZIP = 0;
3230 Com_Printf(
"Current search path:\n");
3245 if (numFilesInPAK) {
3246 Com_Printf(
"%i files in PAK files\n", numFilesInPAK);
3250 if (numFilesInZIP) {
3251 Com_Printf(
"%i files in PKZ files\n", numFilesInZIP);
Referenced by fs_game_changed(), and FS_Restart().
◆ FS_Read()
ssize_t FS_Read |
( |
void * |
buf, |
|
|
size_t |
len, |
|
|
qhandle_t |
f |
|
) |
| |
Definition at line 1547 of file files.c.
1557 if ((file->
mode & FS_MODE_MASK) != FS_MODE_READ)
1564 if (len > SSIZE_MAX)
1570 switch (file->
type) {
1577 ret = gzread(file->zfp, buf, len);
1579 return Q_ERR_LIBRARY_ERROR;
1583 return read_zip_file(file, buf, len);
Referenced by demo_load_message(), demo_read_first(), FS_LoadFileEx(), get_image_dimensions(), Huff1TableInit(), read_binary_file(), read_first_message(), read_next_message(), SCR_PlayCinematic(), SCR_ReadNextFrame(), and SV_BeginDownload_f().
◆ FS_ReadLine()
ssize_t FS_ReadLine |
( |
qhandle_t |
f, |
|
|
char * |
buffer, |
|
|
size_t |
size |
|
) |
| |
Definition at line 1590 of file files.c.
1599 if ((file->
mode & FS_MODE_MASK) != FS_MODE_READ)
1606 s = fgets(buffer, size, file->
fp);
1608 return ferror(file->
fp) ? Q_Errno() : 0;
Referenced by Prompt_LoadHistory().
◆ FS_ReplaceSeparators()
char* FS_ReplaceSeparators |
( |
char * |
s, |
|
|
int |
separator |
|
) |
| |
◆ FS_Restart()
void FS_Restart |
( |
qboolean |
total | ) |
|
Definition at line 3556 of file files.c.
3558 Com_Printf(
"----- FS_Restart -----\n");
3577 Com_Printf(
"----------------------\n");
Referenced by CL_RestartFilesystem().
◆ FS_Restart_f()
◆ FS_SanitizeFilenameVariable()
void FS_SanitizeFilenameVariable |
( |
cvar_t * |
var | ) |
|
Definition at line 294 of file files.c.
297 Com_Printf(
"'%s' contains invalid characters for a filename.\n", var->name);
301 if (strchr(var->string,
'/') || strchr(var->string,
'\\')) {
302 Com_Printf(
"'%s' should be a single filename, not a path.\n", var->name);
309 Com_Printf(
"...falling back to %s\n", var->default_string);
Referenced by QAL_Init(), and VID_Init().
◆ FS_Seek()
qerror_t FS_Seek |
( |
qhandle_t |
f, |
|
|
off_t |
offset |
|
) |
| |
Definition at line 564 of file files.c.
571 if (offset > LONG_MAX)
577 switch (file->
type) {
579 if (fseek(file->
fp, (
long)offset, SEEK_SET) == -1) {
582 return Q_ERR_SUCCESS;
587 if (gzseek(file->zfp, (z_off_t)offset, SEEK_SET) == -1) {
590 return Q_ERR_SUCCESS;
Referenced by CL_Seek_f(), and MVD_Seek_f().
◆ FS_Shutdown()
Definition at line 3614 of file files.c.
3626 Com_WPrintf(
"%s: closing handle %d\n", __func__, i + 1);
3639 inflateEnd(&fs_zipstream.stream);
Referenced by Com_Error(), and Com_Quit().
◆ FS_Tell()
ssize_t FS_Tell |
( |
qhandle_t |
f | ) |
|
◆ FS_UnLink_f()
Definition at line 3351 of file files.c.
3353 static const cmd_option_t options[] = {
3354 {
"a",
"all",
"delete all links" },
3355 {
"h",
"help",
"display this message" },
3363 if (!strncmp(
Cmd_Argv(0),
"soft", 4))
3372 Com_Printf(
"Deletes a symbolic link with the specified name.");
3377 Com_Printf(
"Deleted all symbolic links.\n");
3386 Com_Printf(
"Missing name argument.\n");
3392 if (!FS_pathcmp(link->
name, name)) {
3393 List_Remove(&link->
entry);
3400 Com_Printf(
"Symbolic link '%s' does not exist.\n", name);
◆ FS_ValidatePath()
int FS_ValidatePath |
( |
const char * |
s | ) |
|
◆ FS_WhereIs_f()
Definition at line 3055 of file files.c.
3057 char normalized[MAX_OSPATH], fullpath[MAX_OSPATH];
3066 size_t len, namelen;
3067 qboolean report_all;
3070 Com_Printf(
"Usage: %s <path> [all]\n",
Cmd_Argv(0));
3076 if (namelen >= MAX_OSPATH) {
3077 Com_Printf(
"Refusing to lookup oversize path.\n");
3084 if (namelen >= MAX_OSPATH) {
3085 Com_Printf(
"Oversize symbolic link ('%s --> '%s').\n",
3090 Com_Printf(
"Symbolic link ('%s' --> '%s') in effect.\n",
3100 Com_Printf(
"Refusing to lookup empty path.\n");
3107 if (namelen >= MAX_QPATH) {
3108 Com_Printf(
"Not searching for '%s' in pack files "
3109 "since path length exceedes %d characters.\n",
3110 normalized, MAX_QPATH - 1);
3113 hash = FS_HashPath(normalized, 0);
3122 if (namelen >= MAX_QPATH) {
3128 for (; entry; entry = entry->
hash_next) {
3129 if (entry->
namelen != namelen) {
3132 if (!FS_pathcmp(entry->
name, normalized)) {
3134 Com_Printf(
"%s/%s (%"PRIz
" bytes)\n", pak->
filename,
3145 if (valid == PATH_INVALID) {
3147 Com_Printf(
"Not searching for '%s' in physical file "
3148 "system since path contains invalid characters.\n",
3152 if (valid == PATH_INVALID) {
3157 len =
Q_concat(fullpath, MAX_OSPATH,
3158 search->
filename,
"/", normalized, NULL);
3159 if (len >= MAX_OSPATH) {
3160 Com_WPrintf(
"Full path length '%s/%s' exceeded %d characters.\n",
3161 search->
filename, normalized, MAX_OSPATH - 1);
3171 if (ret == Q_ERR_NOENT && valid == PATH_MIXED_CASE) {
3172 Q_strlwr(fullpath + strlen(search->
filename) + 1);
3174 if (ret == Q_ERR_SUCCESS)
3175 Com_Printf(
"Physical path found after converting to lower case.\n");
3179 if (ret == Q_ERR_SUCCESS) {
3180 Com_Printf(
"%s (%"PRIz
" bytes)\n", fullpath, info.size);
3185 }
else if (ret != Q_ERR_NOENT) {
3186 Com_EPrintf(
"Couldn't get info on '%s': %s\n",
3195 if ((total == 0 || report_all) && link == NULL) {
3199 if (namelen >= MAX_OSPATH) {
3200 Com_Printf(
"Oversize symbolic link ('%s --> '%s').\n",
3205 Com_Printf(
"Symbolic link ('%s' --> '%s') in effect.\n",
3212 Com_Printf(
"%d instances of %s\n", total, normalized);
3214 Com_Printf(
"%s was not found\n", normalized);
◆ FS_WildCmp()
qboolean FS_WildCmp |
( |
const char * |
filter, |
|
|
const char * |
string |
|
) |
| |
◆ FS_Write()
ssize_t FS_Write |
( |
const void * |
buf, |
|
|
size_t |
len, |
|
|
qhandle_t |
f |
|
) |
| |
Definition at line 1643 of file files.c.
1651 if ((file->
mode & FS_MODE_MASK) == FS_MODE_READ)
1658 if (len > SSIZE_MAX)
1664 switch (file->
type) {
1666 result = fwrite(buf, 1, len, file->
fp);
1667 if (result != len) {
1674 if (gzwrite(file->zfp, buf, len) == 0) {
1675 file->
error = Q_ERR_LIBRARY_ERROR;
1681 Com_Error(ERR_FATAL,
"%s: bad file type", __func__);
Referenced by CL_Stop_f(), CL_WriteDemoMessage(), FS_EasyWriteFile(), FS_FPrintf(), FS_WriteFile(), logfile_write(), MVD_StopRecord(), MVD_StreamedRecord_f(), MVD_WriteDemoMessage(), rec_frame(), rec_start(), rec_stop(), rec_write(), SCR_ScoreShot_f(), stbi_write(), and write_udp_download().
◆ FS_WriteFile()
qerror_t FS_WriteFile |
( |
const char * |
path, |
|
|
const void * |
data, |
|
|
size_t |
len |
|
) |
| |
◆ get_fp_info()
static qerror_t get_fp_info |
( |
FILE * |
fp, |
|
|
file_info_t * |
info |
|
) |
| |
|
static |
Definition at line 817 of file files.c.
826 if (os_fstat(fd, &
st) == -1)
829 if (Q_ISDIR(
st.st_mode))
832 if (!Q_ISREG(
st.st_mode))
833 return Q_ERR_FILE_NOT_REGULAR;
836 info->size =
st.st_size;
837 info->ctime =
st.st_ctime;
838 info->mtime =
st.st_mtime;
841 return Q_ERR_SUCCESS;
Referenced by open_file_write(), and open_from_disk().
◆ get_path_info()
static qerror_t get_path_info |
( |
const char * |
path, |
|
|
file_info_t * |
info |
|
) |
| |
|
static |
Definition at line 795 of file files.c.
799 if (os_stat(path, &
st) == -1)
802 if (Q_ISDIR(
st.st_mode))
805 if (!Q_ISREG(
st.st_mode))
806 return Q_ERR_FILE_NOT_REGULAR;
809 info->size =
st.st_size;
810 info->ctime =
st.st_ctime;
811 info->mtime =
st.st_mtime;
814 return Q_ERR_SUCCESS;
Referenced by FS_WhereIs_f().
◆ infocmp()
static int infocmp |
( |
const void * |
p1, |
|
|
const void * |
p2 |
|
) |
| |
|
static |
Definition at line 2695 of file files.c.
2697 file_info_t *n1 = *(file_info_t **)p1;
2698 file_info_t *n2 = *(file_info_t **)p2;
2700 return FS_pathcmp(n1->name, n2->name);
Referenced by FS_ListFiles().
◆ load_pak_file()
static pack_t* load_pak_file |
( |
const char * |
packfile | ) |
|
|
static |
Definition at line 2123 of file files.c.
2125 dpackheader_t header;
2128 unsigned i, num_files;
2130 size_t len, names_len;
2133 dpackfile_t info[MAX_FILES_IN_PACK];
2135 fp = fopen(packfile,
"rb");
2137 Com_Printf(
"Couldn't open %s: %s\n", packfile, strerror(errno));
2141 if (fread(&header, 1,
sizeof(header), fp) !=
sizeof(header)) {
2142 Com_Printf(
"Reading header failed on %s\n", packfile);
2146 if (LittleLong(header.ident) != IDPAKHEADER) {
2147 Com_Printf(
"%s is not a 'PACK' file\n", packfile);
2151 header.dirlen = LittleLong(header.dirlen);
2152 if (header.dirlen > INT_MAX || header.dirlen %
sizeof(dpackfile_t)) {
2153 Com_Printf(
"%s has bad directory length\n", packfile);
2157 num_files = header.dirlen /
sizeof(dpackfile_t);
2158 if (num_files < 1) {
2159 Com_Printf(
"%s has no files\n", packfile);
2162 if (num_files > MAX_FILES_IN_PACK) {
2163 Com_Printf(
"%s has too many files: %u > %u\n", packfile, num_files, MAX_FILES_IN_PACK);
2167 header.dirofs = LittleLong(header.dirofs);
2168 if (header.dirofs > LONG_MAX - header.dirlen) {
2169 Com_Printf(
"%s has bad directory offset\n", packfile);
2172 if (fseek(fp, (
long)header.dirofs, SEEK_SET)) {
2173 Com_Printf(
"Seeking to directory failed on %s\n", packfile);
2176 if (fread(info, 1, header.dirlen, fp) != header.dirlen) {
2177 Com_Printf(
"Reading directory failed on %s\n", packfile);
2182 for (i = 0, dfile = info; i < num_files; i++, dfile++) {
2183 dfile->filepos = LittleLong(dfile->filepos);
2184 dfile->filelen = LittleLong(dfile->filelen);
2185 if (dfile->filelen > INT_MAX || dfile->filepos > INT_MAX - dfile->filelen) {
2186 Com_Printf(
"%s has bad directory structure\n", packfile);
2189 dfile->name[
sizeof(dfile->name) - 1] = 0;
2190 names_len += strlen(dfile->name) + 1;
2199 for (i = 0, dfile = info; i < num_files; i++, dfile++) {
2200 len = strlen(dfile->name) + 1;
2202 file->
name = memcpy(name, dfile->name, len);
2205 file->
filepos = dfile->filepos;
2206 file->
filelen = dfile->filelen;
2208 file->coherent = qtrue;
2216 packfile,
pack->num_files,
pack->hash_size);
Referenced by q_printf().
◆ open_file_read()
static ssize_t open_file_read |
( |
file_t * |
file, |
|
|
const char * |
normalized, |
|
|
size_t |
namelen, |
|
|
qboolean |
unique |
|
) |
| |
|
static |
Definition at line 1359 of file files.c.
1361 char fullpath[MAX_OSPATH];
1372 hash = FS_HashPath(normalized, 0);
1378 if (file->
mode & FS_PATH_MASK) {
1379 if ((file->
mode & search->
mode & FS_PATH_MASK) == 0) {
1386 if ((file->
mode & FS_TYPE_MASK) == FS_TYPE_REAL) {
1390 if (namelen >= MAX_QPATH) {
1395 if ((file->
mode & FS_FLAG_DEFLATE) && pak->
type != FS_ZIP) {
1401 for (; entry; entry = entry->
hash_next) {
1402 if (entry->
namelen != namelen) {
1406 if ((file->
mode & FS_FLAG_DEFLATE) && entry->compmtd != Z_DEFLATED) {
1411 if (!FS_pathcmp(entry->
name, normalized)) {
1417 if ((file->
mode & FS_TYPE_MASK) == FS_TYPE_PAK) {
1421 if (file->
mode & FS_FLAG_DEFLATE) {
1431 if (valid == PATH_INVALID) {
1435 len =
Q_concat(fullpath,
sizeof(fullpath),
1436 search->
filename,
"/", normalized, NULL);
1437 if (len >=
sizeof(fullpath)) {
1438 ret = Q_ERR_NAMETOOLONG;
1443 if (ret != Q_ERR_NOENT)
1447 if (valid == PATH_MIXED_CASE) {
1450 Q_strlwr(fullpath + strlen(search->
filename) + 1);
1452 if (ret != Q_ERR_NOENT)
1460 ret = valid ? Q_ERR_NOENT : Q_ERR_INVALID_PATH;
Referenced by expand_open_file_read().
◆ open_file_write()
static ssize_t open_file_write |
( |
file_t * |
file, |
|
|
const char * |
name |
|
) |
| |
|
static |
Definition at line 887 of file files.c.
889 char normalized[MAX_OSPATH], fullpath[MAX_OSPATH];
899 if (len >=
sizeof(normalized)) {
900 return Q_ERR_NAMETOOLONG;
905 return Q_ERR_NAMETOOSHORT;
910 ret = Q_ERR_INVALID_PATH;
915 if ((file->
mode & FS_PATH_MASK) == FS_PATH_BASE) {
917 len =
Q_concat(fullpath,
sizeof(fullpath),
918 sys_homedir->string,
"/" BASEGAME
"/", normalized, NULL);
920 len =
Q_concat(fullpath,
sizeof(fullpath),
921 sys_basedir->string,
"/" BASEGAME
"/", normalized, NULL);
924 len =
Q_concat(fullpath,
sizeof(fullpath),
927 if (len >=
sizeof(fullpath)) {
928 ret = Q_ERR_NAMETOOLONG;
932 mode = file->
mode & FS_MODE_MASK;
935 strcpy(mode_str,
"a");
938 strcpy(mode_str,
"w");
939 if (file->
mode & FS_FLAG_EXCL)
940 strcat(mode_str,
"x");
946 strcpy(mode_str,
"r+");
954 if (!(file->
mode & FS_FLAG_TEXT))
955 strcat(mode_str,
"b");
976 switch (file->
mode & FS_BUF_MASK) {
979 setvbuf(fp, NULL, _IONBF, BUFSIZ);
983 setvbuf(fp, NULL, _IOLBF, BUFSIZ);
987 setvbuf(fp, NULL, _IOFBF, BUFSIZ);
994 if (mode == FS_MODE_RDWR) {
996 if (fseek(fp, 0, SEEK_END) == -1) {
1009 FS_DPrintf(
"%s: %s: %lu bytes\n", __func__, fullpath, pos);
1014 file->
error = Q_ERR_SUCCESS;
Referenced by FS_FOpenFile().
◆ open_from_disk()
static ssize_t open_from_disk |
( |
file_t * |
file, |
|
|
const char * |
fullpath |
|
) |
| |
|
static |
Definition at line 1276 of file files.c.
1284 fp = fopen(fullpath,
"rb");
1299 file->
error = Q_ERR_SUCCESS;
1300 file->
length = info.size;
1302 FS_DPrintf(
"%s: %s: %"PRIz
" bytes\n", __func__, fullpath, info.size);
Referenced by open_file_read().
◆ open_from_pak()
Definition at line 1202 of file files.c.
1208 fp = fopen(
pack->filename,
"rb");
1219 if (
pack->type == FS_ZIP && !entry->coherent) {
1220 ret = check_header_coherency(fp, entry);
1227 if (fseek(fp, (
long)entry->
filepos, SEEK_SET) == -1) {
1234 file->
entry = entry;
1237 file->
error = Q_ERR_SUCCESS;
1242 if (
pack->type == FS_ZIP) {
1243 if (file->
mode & FS_FLAG_DEFLATE) {
1247 file->
length = entry->complen;
1248 }
else if (entry->compmtd) {
1249 open_zip_file(file);
Referenced by open_file_read().
◆ pack_alloc()
static pack_t* pack_alloc |
( |
FILE * |
fp, |
|
|
filetype_t |
type, |
|
|
const char * |
name, |
|
|
unsigned |
num_files, |
|
|
size_t |
names_len |
|
) |
| |
|
static |
Definition at line 2080 of file files.c.
2087 hash_size = npot32(num_files / 3);
2089 len = strlen(name) + 1;
2097 pack->num_files = num_files;
2098 pack->hash_size = hash_size;
2101 pack->filename = (
char *)(
pack->file_hash + hash_size);
2102 pack->names =
pack->filename + len;
2103 memcpy(
pack->filename, name, len);
Referenced by load_pak_file().
◆ pack_get()
◆ pack_hash_file()
◆ pack_put()
◆ pakcmp()
Definition at line 2487 of file files.c.
2489 char *s1 = *(
char **)p1;
2490 char *s2 = *(
char **)p2;
2492 if (!Q_stricmpn(s1,
"pak", 3)) {
2493 if (!Q_stricmpn(s2,
"pak", 3)) {
2494 unsigned long n1 = strtoul(s1 + 3, &s1, 10);
2495 unsigned long n2 = strtoul(s2 + 3, &s2, 10);
2506 if (!Q_stricmpn(s2,
"pak", 3)) {
2511 return Q_stricmp(s1, s2);
Referenced by q_printf().
◆ print_file_list()
static void print_file_list |
( |
const char * |
path, |
|
|
const char * |
ext, |
|
|
unsigned |
flags |
|
) |
| |
|
static |
Definition at line 2977 of file files.c.
2980 int i, listed, total;
2985 listed = total > 128 ? 128 : total;
2986 for (i = 0; i < listed; i++) {
2987 Com_Printf(
"%s\n", (
char *)list[i]);
2992 if (listed == total) {
2993 Com_Printf(
"%i files listed\n", listed);
2995 Com_Printf(
"%i files listed (%d files more)\n", listed, total - listed);
Referenced by FS_Dir_f(), and FS_FDir_f().
◆ q_printf()
static void q_printf |
( |
2 |
, |
|
|
3 |
|
|
) |
| |
|
static |
Definition at line 2516 of file files.c.
2521 void *files[MAX_LISTED_FILES];
2523 char path[MAX_OSPATH];
2526 va_start(argptr, fmt);
2531 Com_EPrintf(
"%s: refusing oversize path\n", __func__);
2540 #define PAK_EXT ".pak;.pkz"
2542 #define PAK_EXT ".pak"
2550 if (!(mode & FS_PATH_GAME) && !count) {
2554 qsort(files, count,
sizeof(files[0]),
pakcmp);
2556 for (i = 0; i < count; i++) {
2558 if (len >=
sizeof(path)) {
2559 Com_EPrintf(
"%s: refusing oversize path\n", __func__);
2564 if (len > 4 && !Q_stricmp(path + len - 4,
".pkz"))
2565 pack = load_zip_file(path);
2572 search->
mode = mode;
2579 for (i = 0; i < count; i++) {
2586 search->
mode = mode;
2587 search->
pack = NULL;
◆ read_pak_file()
static ssize_t read_pak_file |
( |
file_t * |
file, |
|
|
void * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
static |
Definition at line 1504 of file files.c.
1515 result = fread(buf, 1, len, file->
fp);
1516 if (result != len) {
Referenced by FS_Read().
◆ read_phys_file()
static ssize_t read_phys_file |
( |
file_t * |
file, |
|
|
void * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
static |
Definition at line 1527 of file files.c.
1531 result = fread(buf, 1, len, file->
fp);
1532 if (result != len && ferror(file->
fp)) {
1533 file->
error = Q_Errno();
Referenced by FS_Read().
◆ seek_pak_file()
static qerror_t seek_pak_file |
( |
file_t * |
file, |
|
|
off_t |
offset |
|
) |
| |
|
static |
Definition at line 537 of file files.c.
545 if (entry->
filepos > LONG_MAX - offset)
548 filepos = entry->
filepos + offset;
549 if (fseek(file->
fp, filepos, SEEK_SET) == -1)
554 return Q_ERR_SUCCESS;
Referenced by FS_Seek().
◆ setup_base_paths()
◆ setup_game_paths()
◆ validate_char()
static qboolean validate_char |
( |
int |
c | ) |
|
|
inlinestatic |
◆ c_fs
◆ fs_base_searchpaths
◆ fs_files
◆ fs_game
◆ fs_gamedir
char fs_gamedir[MAX_OSPATH] |
Definition at line 171 of file files.c.
Referenced by copy_file(), Expose(), finish_download(), fs_game_changed(), FS_Restart(), OGG_InitTrackList(), open_file_write(), q_printf(), read_level_file(), read_server_file(), remove_file(), setup_game_paths(), start_download(), SV_SpawnServer(), write_level_file(), and write_server_file().
◆ fs_hard_links
◆ fs_searchpaths
Definition at line 174 of file files.c.
Referenced by free_all_paths(), free_game_paths(), FS_FOpenFile(), FS_LastModified(), FS_ListFiles(), FS_LoadFileEx(), FS_Path_f(), FS_Shutdown(), FS_WhereIs_f(), open_file_read(), q_printf(), and setup_base_paths().
◆ fs_shareware
◆ fs_soft_links
static ssize_t read_phys_file(file_t *file, void *buf, size_t len)
size_t Q_strlcat(char *dst, const char *src, size_t size)
static void FS_Link_g(genctx_t *ctx)
file_info_t * FS_CopyInfo(const char *name, size_t size, time_t ctime, time_t mtime)
cvar_t * Cvar_Set(const char *var_name, const char *value)
static qhandle_t easy_open_read(char *buf, size_t size, unsigned mode, const char *dir, const char *name, const char *ext)
#define FOR_EACH_SYMLINK(link, list)
static file_t fs_files[MAX_FILE_HANDLES]
void Sys_ListFiles_r(const char *path, const char *filter, unsigned flags, size_t baselen, int *count_p, void **files, int depth)
static ssize_t read_pak_file(file_t *file, void *buf, size_t len)
static void pack_put(pack_t *pack)
void Com_AddConfigFile(const char *name, unsigned flags)
size_t Q_snprintf(char *dest, size_t size, const char *fmt,...)
static void FS_Restart_f(void)
static qhandle_t easy_open_write(char *buf, size_t size, unsigned mode, const char *dir, const char *name, const char *ext)
ssize_t FS_Read(void *buf, size_t len, qhandle_t f)
qboolean FS_ExtCmp(const char *ext, const char *name)
qboolean COM_IsPath(const char *s)
qerror_t FS_FilterFile(qhandle_t f)
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
const char * Q_ErrorString(qerror_t error)
void Z_LeakTest(memtag_t tag)
static void FS_Path_f(void)
static ssize_t open_file_write(file_t *file, const char *name)
static pack_t * pack_alloc(FILE *fp, filetype_t type, const char *name, unsigned num_files, size_t names_len)
void FS_FreeList(void **list)
static void FS_FDir_f(void)
char * FS_ReplaceSeparators(char *s, int separator)
static pack_t * pack_get(pack_t *pack)
static qboolean validate_char(int c)
void Cmd_PrintUsage(const cmd_option_t *opt, const char *suffix)
size_t Q_vsnprintf(char *dest, size_t size, const char *fmt, va_list argptr)
void Cmd_Deregister(const cmdreg_t *reg)
#define FOR_EACH_SYMLINK_SAFE(link, next, list)
qboolean Prompt_AddMatch(genctx_t *ctx, const char *s)
struct searchpath_s * next
static FILE * fopen_hack(const char *path, const char *mode)
static ssize_t expand_open_file_read(file_t *file, const char *name, qboolean unique)
int FS_ValidatePath(const char *s)
ssize_t FS_FOpenFile(const char *name, qhandle_t *f, unsigned mode)
static ssize_t open_from_disk(file_t *file, const char *fullpath)
static void free_game_paths(void)
static void setup_base_paths(void)
size_t FS_NormalizePathBuffer(char *out, const char *in, size_t size)
void * Z_TagMalloc(size_t size, memtag_t tag)
void Com_Error(error_type_t type, const char *fmt,...)
static void FS_Link_c(genctx_t *ctx, int argnum)
int Cmd_ParseOptions(const cmd_option_t *opt)
void Cmd_Register(const cmdreg_t *reg)
void ** FS_ListFiles(const char *path, const char *filter, unsigned flags, int *count_p)
static int pakcmp(const void *p1, const void *p2)
static void free_all_links(list_t *list)
static void fs_game_changed(cvar_t *self)
static searchpath_t * fs_base_searchpaths
qboolean FS_WildCmp(const char *filter, const char *string)
static void pack_hash_file(pack_t *pack, packfile_t *file)
size_t Q_strlcpy(char *dst, const char *src, size_t size)
static void free_search_path(searchpath_t *path)
static qerror_t get_fp_info(FILE *fp, file_info_t *info)
static const cmdreg_t c_fs[]
static file_t * alloc_handle(qhandle_t *f)
static void print_file_list(const char *path, const char *ext, unsigned flags)
static file_t * file_for_handle(qhandle_t f)
cvar_t * Cvar_FullSet(const char *var_name, const char *value, int flags, from_t from)
static qerror_t seek_pak_file(file_t *file, off_t offset)
qboolean Com_WildCmpEx(const char *filter, const char *string, int term, qboolean ignorecase)
static void FS_WhereIs_f(void)
static void free_all_paths(void)
ssize_t FS_Write(const void *buf, size_t len, qhandle_t f)
void CL_RestartFilesystem(qboolean total)
static searchpath_t * fs_searchpaths
char * COM_SkipPath(const char *pathname)
void Cmd_PrintHelp(const cmd_option_t *opt)
static void setup_game_paths(void)
static symlink_t * expand_links(list_t *list, char *buffer, size_t *len_p)
static list_t fs_soft_links
static uint32_t pack(uint64_t n)
static void FS_Dir_f(void)
static void FS_UnLink_f(void)
qerror_t FS_CreatePath(char *path)
void FS_FCloseFile(qhandle_t f)
size_t Q_concat(char *dest, size_t size,...)
static ssize_t open_from_pak(file_t *file, pack_t *pack, packfile_t *entry, qboolean unique)
static int alphacmp(const void *p1, const void *p2)
static void cleanup_path(char *s)
struct packfile_s * hash_next
char * COM_FileExtension(const char *in)
static ssize_t open_file_read(file_t *file, const char *normalized, size_t namelen, qboolean unique)
static void FS_Link_f(void)
char fs_gamedir[MAX_OSPATH]
static int infocmp(const void *p1, const void *p2)
static pack_t * load_pak_file(const char *packfile)
size_t FS_NormalizePath(char *out, const char *in)
static list_t fs_hard_links
static qerror_t get_path_info(const char *path, file_info_t *info)