2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-22 01:45:19 +01:00

filesystem: request win32 error string in wide chars and then transform it to UTF-8 using our utflib

This commit is contained in:
Alibek Omarov 2024-07-09 08:25:15 +03:00
parent a1191eb4ab
commit 64716e6b42

View File

@ -1357,7 +1357,7 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll
{ {
// NOTE: gamedll might resolve it's own path using dladdr() and expects absolute path // NOTE: gamedll might resolve it's own path using dladdr() and expects absolute path
// NOTE: the only allowed case when searchpath is set by absolute path is the RoDir // NOTE: the only allowed case when searchpath is set by absolute path is the RoDir
// rather than figuring out whether path is absolute, just check if it matches // rather than figuring out whether path is absolute, just check if it matches
if( !Q_strnicmp( search->filename, fs_rodir, Q_strlen( fs_rodir ))) if( !Q_strnicmp( search->filename, fs_rodir, Q_strlen( fs_rodir )))
{ {
Q_snprintf( dllInfo->fullPath, sizeof( dllInfo->fullPath ), "%s%s", search->filename, dllInfo->shortPath ); Q_snprintf( dllInfo->fullPath, sizeof( dllInfo->fullPath ), "%s%s", search->filename, dllInfo->shortPath );
@ -1845,10 +1845,13 @@ int FS_SetCurrentDirectory( const char *path )
#if XASH_WIN32 #if XASH_WIN32
if( !SetCurrentDirectoryW( FS_PathToWideChar( path ))) if( !SetCurrentDirectoryW( FS_PathToWideChar( path )))
{ {
const DWORD fm_flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK;
DWORD errorcode;
wchar_t wide_buf[1024];
char buf[1024]; char buf[1024];
FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ), FormatMessageW( fm_flags, NULL, GetLastError(), 0, wide_buf, sizeof( wide_buf ) / sizeof( wide_buf[0] ), NULL );
buf, sizeof( buf ), NULL ); Q_UTF16ToUTF8( buf, sizeof( buf ), wide_buf, sizeof( wide_buf ) / sizeof( wide_buf[0] ));
Sys_Error( "Changing directory to %s failed: %s\n", path, buf ); Sys_Error( "Changing directory to %s failed: %s\n", path, buf );
return false; return false;