mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-02-06 12:14:15 +00: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();
|
FS_LoadProgs();
|
||||||
|
|
||||||
if( FS_SetCurrentDirectory( host.rootdir ) != 0 )
|
// TODO: this function will cause engine to stop in case of fail
|
||||||
Con_Reportf( "%s is working directory now\n", host.rootdir );
|
// when it will have an option to return string error, restore Sys_Error
|
||||||
else
|
FS_SetCurrentDirectory( host.rootdir );
|
||||||
Sys_Error( "Changing working directory to %s failed.\n", host.rootdir );
|
|
||||||
|
|
||||||
FS_Init();
|
FS_Init();
|
||||||
|
|
||||||
|
@ -1703,17 +1703,36 @@ qboolean FS_SysFileOrFolderExists( const char *path )
|
|||||||
FS_SetCurrentDirectory
|
FS_SetCurrentDirectory
|
||||||
|
|
||||||
Sets current directory, path should be in UTF-8 encoding
|
Sets current directory, path should be in UTF-8 encoding
|
||||||
|
TODO: make this non-fatal
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
int FS_SetCurrentDirectory( const char *path )
|
int FS_SetCurrentDirectory( const char *path )
|
||||||
{
|
{
|
||||||
#if XASH_WIN32
|
#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
|
#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
|
#else
|
||||||
#error
|
// it may be fine for some systems to skip chdir
|
||||||
|
Con_Printf( "FS_SetCurrentDirectory: not implemented, ignoring...\n" );
|
||||||
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Con_Printf( "%s is working directory now\n", path );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,7 +48,7 @@ static int TestNoInit( void )
|
|||||||
g_fs.AllowDirectPaths( false );
|
g_fs.AllowDirectPaths( false );
|
||||||
if( g_fs.Search( "asfjkajk", 0, 0 ) != 0 )
|
if( g_fs.Search( "asfjkajk", 0, 0 ) != 0 )
|
||||||
return 0;
|
return 0;
|
||||||
g_fs.SetCurrentDirectory( "asdasdasdasd" );
|
g_fs.SetCurrentDirectory( "." ); // must succeed!
|
||||||
g_fs.FindLibrary( "kek", true, &dllinfo );
|
g_fs.FindLibrary( "kek", true, &dllinfo );
|
||||||
if( g_fs.Open( "afbvasvwerf", "w+", true ) != 0 )
|
if( g_fs.Open( "afbvasvwerf", "w+", true ) != 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user