mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-02-01 01:34:17 +00:00
engine: filesystem: fixed current directory changing for Windows
This commit is contained in:
parent
ec95948b69
commit
e4ad8def0d
@ -61,7 +61,6 @@ GNU General Public License for more details.
|
|||||||
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
|
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
|
||||||
#define LoadLibrary( x ) dlopen( x, RTLD_NOW )
|
#define LoadLibrary( x ) dlopen( x, RTLD_NOW )
|
||||||
#define GetProcAddress( x, y ) dlsym( x, y )
|
#define GetProcAddress( x, y ) dlsym( x, y )
|
||||||
#define SetCurrentDirectory( x ) (!chdir( x ))
|
|
||||||
#define FreeLibrary( x ) dlclose( x )
|
#define FreeLibrary( x ) dlclose( x )
|
||||||
#define tell( a ) lseek(a, 0, SEEK_CUR)
|
#define tell( a ) lseek(a, 0, SEEK_CUR)
|
||||||
#define HAVE_DUP
|
#define HAVE_DUP
|
||||||
@ -72,7 +71,6 @@ GNU General Public License for more details.
|
|||||||
#define LoadLibrary( x ) (0)
|
#define LoadLibrary( x ) (0)
|
||||||
#define GetProcAddress( x, y ) (0)
|
#define GetProcAddress( x, y ) (0)
|
||||||
#define FreeLibrary( x ) (0)
|
#define FreeLibrary( x ) (0)
|
||||||
#define SetCurrentDirectory( x ) (!chdir( x ))
|
|
||||||
#endif
|
#endif
|
||||||
//#define MAKEWORD( a, b ) ((short int)(((unsigned char)(a))|(((short int)((unsigned char)(b)))<<8)))
|
//#define MAKEWORD( a, b ) ((short int)(((unsigned char)(a))|(((short int)((unsigned char)(b)))<<8)))
|
||||||
#define max( a, b ) (((a) > (b)) ? (a) : (b))
|
#define max( a, b ) (((a) > (b)) ? (a) : (b))
|
||||||
|
@ -566,6 +566,7 @@ int FS_FileTime( const char *filename, qboolean gamedironly );
|
|||||||
int FS_Print( file_t *file, const char *msg );
|
int FS_Print( file_t *file, const char *msg );
|
||||||
qboolean FS_Rename( const char *oldname, const char *newname );
|
qboolean FS_Rename( const char *oldname, const char *newname );
|
||||||
int FS_FileExists( const char *filename, int gamedironly );
|
int FS_FileExists( const char *filename, int gamedironly );
|
||||||
|
int FS_SetCurrentDirectory( const char *path );
|
||||||
qboolean FS_SysFileExists( const char *path, qboolean casesensitive );
|
qboolean FS_SysFileExists( const char *path, qboolean casesensitive );
|
||||||
qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
|
qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
|
||||||
qboolean FS_Delete( const char *path );
|
qboolean FS_Delete( const char *path );
|
||||||
|
@ -463,6 +463,22 @@ static const char *FS_FixFileCase( const char *path )
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if XASH_WIN32
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
FS_PathToWideChar
|
||||||
|
|
||||||
|
Converts input UTF-8 string to wide char string.
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
const wchar_t *FS_PathToWideChar( const char *path )
|
||||||
|
{
|
||||||
|
static wchar_t pathBuffer[MAX_PATH];
|
||||||
|
MultiByteToWideChar( CP_UTF8, 0, path, -1, pathBuffer, MAX_PATH );
|
||||||
|
return pathBuffer;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
FS_AddFileToPack
|
FS_AddFileToPack
|
||||||
@ -2240,7 +2256,11 @@ static file_t *FS_SysOpen( const char *filepath, const char *mode )
|
|||||||
file->filetime = FS_SysFileTime( filepath );
|
file->filetime = FS_SysFileTime( filepath );
|
||||||
file->ungetc = EOF;
|
file->ungetc = EOF;
|
||||||
|
|
||||||
|
#if XASH_WIN32
|
||||||
|
file->handle = _wopen( FS_PathToWideChar(filepath), mod | opt, 0666 );
|
||||||
|
#else
|
||||||
file->handle = open( filepath, mod|opt, 0666 );
|
file->handle = open( filepath, mod|opt, 0666 );
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !XASH_WIN32
|
#if !XASH_WIN32
|
||||||
if( file->handle < 0 )
|
if( file->handle < 0 )
|
||||||
@ -2394,6 +2414,24 @@ qboolean FS_SysFileExists( const char *path, qboolean caseinsensitive )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
FS_SetCurrentDirectory
|
||||||
|
|
||||||
|
Sets current directory, path should be in UTF-8 encoding
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
int FS_SetCurrentDirectory( const char *path )
|
||||||
|
{
|
||||||
|
#if XASH_WIN32
|
||||||
|
return SetCurrentDirectoryW( FS_PathToWideChar(path) );
|
||||||
|
#elif XASH_POSIX
|
||||||
|
return !chdir( path );
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
FS_SysFolderExists
|
FS_SysFolderExists
|
||||||
|
@ -980,7 +980,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
|||||||
if( len && host.rodir[len - 1] == '/' )
|
if( len && host.rodir[len - 1] == '/' )
|
||||||
host.rodir[len - 1] = 0;
|
host.rodir[len - 1] = 0;
|
||||||
|
|
||||||
if( !COM_CheckStringEmpty( host.rootdir ) || SetCurrentDirectory( host.rootdir ) != 0 )
|
if( !COM_CheckStringEmpty( host.rootdir ) || FS_SetCurrentDirectory( host.rootdir ) != 0 )
|
||||||
Con_Reportf( "%s is working directory now\n", host.rootdir );
|
Con_Reportf( "%s is working directory now\n", host.rootdir );
|
||||||
else
|
else
|
||||||
Sys_Error( "Changing working directory to %s failed.\n", host.rootdir );
|
Sys_Error( "Changing working directory to %s failed.\n", host.rootdir );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user