filesystem: request win32 error string in wide chars and then transform it to UTF-8 using our utflib
This commit is contained in:
parent
a1191eb4ab
commit
64716e6b42
1 changed files with 7 additions and 4 deletions
|
@ -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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue