mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
filesystem: dir: hand off file existence check to the OS if path starts with .. or ../
This commit is contained in:
@@ -292,8 +292,6 @@ static inline qboolean FS_AppendToPath( char *dst, size_t *pi, const size_t len,
|
||||
|
||||
qboolean FS_FixFileCase( dir_t *dir, const char *path, char *dst, const size_t len, qboolean createpath )
|
||||
{
|
||||
const char *prev;
|
||||
const char *next;
|
||||
size_t i = 0;
|
||||
|
||||
if( !FS_AppendToPath( dst, &i, len, dir->name, path, "init" ))
|
||||
@@ -303,7 +301,19 @@ qboolean FS_FixFileCase( dir_t *dir, const char *path, char *dst, const size_t l
|
||||
if( COM_StringEmpty( path ))
|
||||
return true;
|
||||
|
||||
for( prev = path, next = Q_strchrnul( prev, '/' );
|
||||
// we can't and shouldn't track parent directories to not track the whole filesystem
|
||||
// exit early for this case
|
||||
// FIXME: track the path to catch other cases
|
||||
if( !Q_strncmp( path, "..", 2 ) && ( path[2] == '\0' || path[2] == '/' ))
|
||||
{
|
||||
if( !FS_AppendToPath( dst, &i, len, path, path, "escape to parent directory" ))
|
||||
return false;
|
||||
|
||||
// check file existense
|
||||
return createpath ? true : FS_SysFileOrFolderExists( dst );
|
||||
}
|
||||
|
||||
for( const char *prev = path, *next = Q_strchrnul( prev, '/' );
|
||||
;
|
||||
prev = next + 1, next = Q_strchrnul( prev, '/' ))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user