filesystem: add new export to get fs_rootdir path
This commit is contained in:
parent
df4194ca57
commit
4798cd6d1e
4 changed files with 25 additions and 3 deletions
|
@ -435,9 +435,7 @@ public:
|
||||||
|
|
||||||
bool GetCurrentDirectory( char *p, int size ) override
|
bool GetCurrentDirectory( char *p, int size ) override
|
||||||
{
|
{
|
||||||
Q_strncpy( p, fs_rootdir, size );
|
return FS_GetRootDirectory( p, size );
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintOpenedFiles() override
|
void PrintOpenedFiles() override
|
||||||
|
|
|
@ -1905,6 +1905,24 @@ int FS_SetCurrentDirectory( const char *path )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
FS_GetRootDirectory
|
||||||
|
|
||||||
|
Returns writable root directory path
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
qboolean FS_GetRootDirectory( char *path, size_t size )
|
||||||
|
{
|
||||||
|
size_t dirlen = Q_strlen( fs_rootdir );
|
||||||
|
|
||||||
|
if( dirlen >= size ) // check for possible overflow
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Q_strncpy( path, fs_rootdir, size );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
FS_FindFile
|
FS_FindFile
|
||||||
|
@ -3139,6 +3157,8 @@ const fs_api_t g_api =
|
||||||
FS_FindFileInArchive,
|
FS_FindFileInArchive,
|
||||||
FS_OpenFileFromArchive,
|
FS_OpenFileFromArchive,
|
||||||
FS_LoadFileFromArchive,
|
FS_LoadFileFromArchive,
|
||||||
|
|
||||||
|
FS_GetRootDirectory,
|
||||||
};
|
};
|
||||||
|
|
||||||
int EXPORT GetFSAPI( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *engfuncs );
|
int EXPORT GetFSAPI( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *engfuncs );
|
||||||
|
|
|
@ -223,6 +223,9 @@ typedef struct fs_api_t
|
||||||
// NOTE: for speed reasons, path is case-sensitive here!
|
// NOTE: for speed reasons, path is case-sensitive here!
|
||||||
// Use FindFileInArchive to retrieve real path from caseinsensitive FS emulation!
|
// Use FindFileInArchive to retrieve real path from caseinsensitive FS emulation!
|
||||||
byte *(*LoadFileFromArchive)( searchpath_t *sp, const char *path, int pack_ind, fs_offset_t *filesizeptr, const qboolean sys_malloc );
|
byte *(*LoadFileFromArchive)( searchpath_t *sp, const char *path, int pack_ind, fs_offset_t *filesizeptr, const qboolean sys_malloc );
|
||||||
|
|
||||||
|
// gets current root directory, set by InitStdio
|
||||||
|
qboolean (*GetRootDirectory)( char *path, size_t size );
|
||||||
} fs_api_t;
|
} fs_api_t;
|
||||||
|
|
||||||
typedef struct fs_interface_t
|
typedef struct fs_interface_t
|
||||||
|
|
|
@ -162,6 +162,7 @@ void FS_AddGameHierarchy( const char *dir, uint flags );
|
||||||
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||||
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
|
||||||
int FS_SetCurrentDirectory( const char *path );
|
int FS_SetCurrentDirectory( const char *path );
|
||||||
|
qboolean FS_GetRootDirectory( char *path, size_t size );
|
||||||
void FS_Path_f( void );
|
void FS_Path_f( void );
|
||||||
|
|
||||||
// gameinfo utils
|
// gameinfo utils
|
||||||
|
|
Loading…
Add table
Reference in a new issue