148 Commits

Author SHA1 Message Date
Alibek Omarov
61f3369957 filesystem: refactor large filesystem.c into smaller files 2026-05-18 12:50:08 +05:00
Alibek Omarov
5d7ed9d8a7 public: add CheckNastyPath from Darkplaces's VFS so it can be used in engine for path traversal checks 2026-05-16 21:28:51 +05:00
Alibek Omarov
9bad17505e filesystem: cleanup unused variables 2026-05-13 10:09:19 +05:00
Alibek Omarov
0aac2e4d32 engine: zone: add small allocation optimization, reducing the size of <255 bytes allocations at the cost of less debug info
Keep it opt-in through a flag at pool alloc time.
Opt-in console related allocations, they are usually small enough strings.
2026-05-13 09:32:50 +05:00
Alibek Omarov
e5d6f66f61 filesystem: strip exec flag and add nowrite flag to archives
pk3dir now disallows executables, which shouldn't be a problem for anybody.
Revised FS_Path command output.
2026-05-09 19:22:10 +05:00
Alibek Omarov
a106924c7f filesystem: avoid scanning game directory as executable in FS_FindLibrary on Android, generic refactoring 2026-05-09 16:57:21 +05:00
Alibek Omarov
95cc6c4445 filesystem: small refactoring, remove double nullptr checks 2026-05-07 10:32:00 +05:00
Alibek Omarov
086cb6aab8 engine: move {gamedir}/downloaded directory to {gamedir}_downloads for compatibility
Some mods like Sven-Coop 4.8 stupidly open game files directly and need this to
load downloaded soundcache.
2026-05-07 10:32:00 +05:00
Alibek Omarov
b8792e4084 filesystem: set qwrap as falldir for Quake games 2026-04-05 07:03:46 +05:00
Alibek Omarov
2713f03ec2 filesystem: fix Quake gamedir check if pak0.pak is written in uppercase, omitting caseinsensitive FS emulation as is VFS is not enabled at this stage 2026-04-05 07:03:46 +05:00
Alibek Omarov
f42e2f59b7 filesystem: mark some fs ops const 2026-03-17 00:19:27 +05:00
Alibek Omarov
ea0fed24ec filesystem: remove unneccessary dependency on const.h 2026-02-26 10:29:09 +05:00
Alibek Omarov
baa005ff71 filesystem: replace COM_CheckString and COM_CheckStringEmpty by COM_StringEmptyOrNULL and COM_StringEmpty 2026-02-21 01:20:34 +05:00
Alibek Omarov
732bc50a3a filesystem: set custom_loader flag even if loading DLLs from archives is unsupported
After all, it's an engine job to figure out whether it wants to load this binary or not.
2026-02-03 17:48:27 +05:00
Alibek Omarov
dae8c6cb9c filesystem: in case of missing/incomplete liblist.gam make c0a0 default start map 2025-12-14 04:41:52 +03:00
Alibek Omarov
0dfeea5213 Migrate to library-suffix library 2025-11-11 06:59:41 +05:00
Alibek Omarov
73950e867f filesystem: initial set of fixes for big endian 2025-11-06 23:26:12 +05:00
Alibek Omarov
9330e44817 filesystem: fix missing newline in anonymous file creation error string. Turn it into a warning, because it's not fatal 2025-10-17 09:08:50 +05:00
lewa_j
37e9ac453b win32: engine: common: client: filesystem: Fix windows build with -Werror=implicit-function-declaration 2025-10-12 00:21:00 +08:00
Alibek Omarov
3d132e0e83 common: port: move filesystem related macros to filesystem module, try to include less globally for faster builds 2025-10-08 05:03:29 +05:00
Alibek Omarov
8b55d01f78 filesystem: fix missing const qualifier on FS_WriteGameInfo 2025-10-03 17:41:34 +08:00
Alibek Omarov
4ef23543ae filesystem: make current set GameInfo const 2025-10-02 22:42:51 +05:00
Alibek Omarov
9c6589fa03 engine: introduce vfs.cfg to properly control user set addon folders
vfs.cfg executed before game directory is mounted, this way we can know which
folders must be mounted before engine initialization.

This commit also removes buggy hot reload of the addon folders.
2025-09-01 01:42:37 +05:00
Alibek Omarov
e9440a8612 filesystem: fix folder exists check in RoDir 2025-06-15 13:01:13 +05:00
Alibek Omarov
d457d7d093 filesystem: archive mounting refactoring 2025-04-28 22:28:30 +03:00
Alibek Omarov
9c49253388 filesystem: allow symlinks when using listdirectory with dirs_only = true
Should fix special setups when game directories are actually symlinks
2025-03-20 20:31:44 +03:00
Alibek Omarov
0c8da36a0b filesystem: disallow path traversal in FS_Delete and FS_Rename 2025-02-23 03:13:46 +03:00
Alibek Omarov
1d99f65e86 filesystem: when shutting down, clean up gameinfo pointers and total games count 2025-02-05 21:14:08 +03:00
Alibek Omarov
674a4e5883 filesystem: add ability to mount HD, LV, addon and language folders by engine request 2025-02-05 18:24:36 +03:00
Alibek Omarov
2457ecf226 filesystem: fix recursive basedir possible cyclic dependency when default game directory uses a basedir that's base directory is undefined
That could happen when default game directory depends on base directory that don't have gameinfo.txt.
Because all game directories with liblist.gam automatically have dependency on default game directory, it causes cyclic dependency.
2025-01-29 09:49:29 +03:00
Alibek Omarov
8cd99885f1 filesystem: clean added status for game folders when purging search paths 2025-01-29 09:46:18 +03:00
Alibek Omarov
f29c588e0f filesystem: take code from DarkPlaces to properly read compressed files 2025-01-21 18:47:42 +03:00
Alibek Omarov
154df00f94 filesystem: don't create full path to rwdir, as cwd is always equal to rwdir
Fixes updating gameinfo.txt.
2025-01-20 19:53:04 +03:00
Alibek Omarov
a1da10fe38 filesystem: set default values for quick/autosave aged count 2025-01-20 16:06:57 +03:00
Alibek Omarov
785632a437 filesystem: minor refactoring in MD5_HashFile, use initializer instead of memset, limit buffer variable scope 2025-01-14 11:36:13 +03:00
Alibek Omarov
69341e36a3 public: expose commit and branch as global variables instead of functions 2025-01-13 20:02:59 +03:00
Alibek Omarov
d4fe3d6f8a filesystem: wscript: check d_type field in struct dirent, as this is an extension and some supported ports (like psvita) don't have it 2025-01-08 01:22:23 +03:00
Alibek Omarov
1907485895 filesystem: re-enable folder check for array returned by listdirectory with dirs_only set to true
According to glibc manual, not all filesystems support it and some might return DT_UNKNOWN.
2025-01-08 01:22:23 +03:00
Alibek Omarov
cfebb3e1d6 filesystem: massively rework how scanning game directories work
* No more conversion from liblist.gam to gameinfo.txt. We are using liblist.gam directly now.
  gameinfo.txt being native format to Xash3D not only remains, it takes priority over liblist.gam.
* Quake game directories now don't receive autogenerated gameinfo.txt.
* Empty directories don't get gameinfo.txt either, finally making it easier to support HD addon folders.
* If user still wishes to generate gameinfo.txt, there is now command fs_make_gameinfo that creates
  gameinfo.txt for currently running game.
* No more creating empty folders for RoDir. They are now created on demand.
2025-01-08 01:22:23 +03:00
Alibek Omarov
3d60770b84 filesystem: add flag to open files in a RAM
On Linux, it uses memfd_create syscall that can be found on Linux 3.17 and
higher. By default memfds are executable, so we set MFD_NOEXEC_SEAL flag to
prevent execution at creation time.
2024-12-19 04:22:25 +03:00
Alibek Omarov
b28c1186b2 filesystem: fix loading dlls by full path as required by metamod-r 2024-12-05 19:20:13 +03:00
Alibek Omarov
4798cd6d1e filesystem: add new export to get fs_rootdir path 2024-11-30 09:28:30 +03:00
Alibek Omarov
b94446161e filesystem: add functions to directly look up into archives 2024-11-23 13:56:53 +03:00
Alibek Omarov
8fd5a5af96 filesystem: simplify ambient number bound check 2024-11-17 13:04:44 +03:00
Alibek Omarov
0313e19674 filesystem: strip upper directory access from FS_FindFile when FS_AllowDirectPath is set to true
Detailed explanation is available in the code comments.
2024-10-29 16:13:31 +03:00
Alibek Omarov
2e5bc31c9e filesystem: set malloc like attribute for imported zone memory allocator functions 2024-09-30 04:00:28 +03:00
Alibek Omarov
a6c7b67d0d filesystem: include errno.h for Win32 2024-08-17 17:32:50 +03:00
Alibek Omarov
3a67aefee2 filesystem: check rodir too when checking falldir existence too, just in case 2024-08-13 17:25:25 +03:00
Alibek Omarov
d114dffcb4 filesystem: add new gameinfo.txt key: demomap 2024-08-13 17:22:06 +03:00
Alibek Omarov
274f9d5846 filesystem: replace same struct type memcpys by assignments 2024-07-31 00:06:15 +03:00