mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-22 01:45:19 +01:00
filesystem: verbose error printing in FS_SetCurrentDirectory, move error reporting from engine
This commit is contained in:
parent
cca7744f1c
commit
f13c285287
@ -1077,10 +1077,9 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
||||
|
||||
FS_LoadProgs();
|
||||
|
||||
if( FS_SetCurrentDirectory( host.rootdir ) != 0 )
|
||||
Con_Reportf( "%s is working directory now\n", host.rootdir );
|
||||
else
|
||||
Sys_Error( "Changing working directory to %s failed.\n", host.rootdir );
|
||||
// TODO: this function will cause engine to stop in case of fail
|
||||
// when it will have an option to return string error, restore Sys_Error
|
||||
FS_SetCurrentDirectory( host.rootdir );
|
||||
|
||||
FS_Init();
|
||||
|
||||
|
@ -1703,17 +1703,36 @@ qboolean FS_SysFileOrFolderExists( const char *path )
|
||||
FS_SetCurrentDirectory
|
||||
|
||||
Sets current directory, path should be in UTF-8 encoding
|
||||
TODO: make this non-fatal
|
||||
==================
|
||||
*/
|
||||
int FS_SetCurrentDirectory( const char *path )
|
||||
{
|
||||
#if XASH_WIN32
|
||||
return SetCurrentDirectoryW( FS_PathToWideChar( path ));
|
||||
if( !SetCurrentDirectoryW( FS_PathToWideChar( path )))
|
||||
{
|
||||
char buf[1024];
|
||||
FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(), MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ),
|
||||
buf, sizeof( buf ), NULL );
|
||||
|
||||
Sys_Error( "Changing directory to %s failed: %s\n", path, buf )
|
||||
return false;
|
||||
}
|
||||
#elif XASH_POSIX
|
||||
return !chdir( path );
|
||||
if( chdir( path ) < 0 )
|
||||
{
|
||||
Sys_Error( "Changing directory to %s failed: %s\n", path, strerror( errno ));
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
#error
|
||||
// it may be fine for some systems to skip chdir
|
||||
Con_Printf( "FS_SetCurrentDirectory: not implemented, ignoring...\n" );
|
||||
return true;
|
||||
#endif
|
||||
|
||||
Con_Printf( "%s is working directory now\n", path );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -48,7 +48,7 @@ static int TestNoInit( void )
|
||||
g_fs.AllowDirectPaths( false );
|
||||
if( g_fs.Search( "asfjkajk", 0, 0 ) != 0 )
|
||||
return 0;
|
||||
g_fs.SetCurrentDirectory( "asdasdasdasd" );
|
||||
g_fs.SetCurrentDirectory( "." ); // must succeed!
|
||||
g_fs.FindLibrary( "kek", true, &dllinfo );
|
||||
if( g_fs.Open( "afbvasvwerf", "w+", true ) != 0 )
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user