Browse Source

filesystem: make some calls from API safe to use without initialize

pull/2/head
Alibek Omarov 1 year ago
parent
commit
cca7744f1c
  1. 15
      filesystem/filesystem.c

15
filesystem/filesystem.c

@ -1206,12 +1206,12 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll
searchpath_t *search; searchpath_t *search;
int index, start = 0, i, len; int index, start = 0, i, len;
fs_ext_path = directpath;
// check for bad exports // check for bad exports
if( !COM_CheckString( dllname )) if( !COM_CheckString( dllname ))
return false; return false;
fs_ext_path = directpath;
// HACKHACK remove absoulte path to valve folder // HACKHACK remove absoulte path to valve folder
if( !Q_strnicmp( dllname, "..\\valve\\", 9 ) || !Q_strnicmp( dllname, "../valve/", 9 )) if( !Q_strnicmp( dllname, "..\\valve\\", 9 ) || !Q_strnicmp( dllname, "../valve/", 9 ))
start += 9; start += 9;
@ -1419,6 +1419,7 @@ qboolean FS_InitStdio( qboolean unused_set_to_true, const char *rootdir, const c
} }
stringlistfreecontents( &dirs ); stringlistfreecontents( &dirs );
Con_Reportf( "FS_Init: done\n" ); Con_Reportf( "FS_Init: done\n" );
return true; return true;
@ -1821,6 +1822,9 @@ Open a file. The syntax is the same as fopen
*/ */
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly ) file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly )
{ {
if( !fs_searchpaths )
return NULL;
// some stupid mappers used leading '/' or '\' in path to models or sounds // some stupid mappers used leading '/' or '\' in path to models or sounds
if( filepath[0] == '/' || filepath[0] == '\\' ) if( filepath[0] == '/' || filepath[0] == '\\' )
filepath++; filepath++;
@ -2348,9 +2352,7 @@ byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
file = FS_SysOpen( path, "rb" ); file = FS_SysOpen( path, "rb" );
if( !file ) if( !file )
{
return NULL; return NULL;
}
// Try to load // Try to load
filesize = file->real_length; filesize = file->real_length;
@ -2531,6 +2533,9 @@ qboolean FS_Rename( const char *oldname, const char *newname )
char oldname2[MAX_SYSPATH], newname2[MAX_SYSPATH], oldpath[MAX_SYSPATH], newpath[MAX_SYSPATH]; char oldname2[MAX_SYSPATH], newname2[MAX_SYSPATH], oldpath[MAX_SYSPATH], newpath[MAX_SYSPATH];
int ret; int ret;
if( !fs_writepath )
return false;
if( !COM_CheckString( oldname ) || !COM_CheckString( newname )) if( !COM_CheckString( oldname ) || !COM_CheckString( newname ))
return false; return false;
@ -2576,7 +2581,7 @@ qboolean GAME_EXPORT FS_Delete( const char *path )
char path2[MAX_SYSPATH], real_path[MAX_SYSPATH]; char path2[MAX_SYSPATH], real_path[MAX_SYSPATH];
int ret; int ret;
if( !COM_CheckString( path )) if( !fs_writepath || !COM_CheckString( path ))
return false; return false;
Q_strncpy( path2, path, sizeof( path2 )); Q_strncpy( path2, path, sizeof( path2 ));

Loading…
Cancel
Save