diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index a6751c67..a253fe1a 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -1152,6 +1152,7 @@ typedef enum } dialogType_t; dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *title ); +qboolean Sys_OpenFolderInFileManager( const char *path, qboolean create ); void Sys_RemovePIDFile( const char *gamedir ); void Sys_InitPIDFile( const char *gamedir ); diff --git a/code/sys/sys_local.h b/code/sys/sys_local.h index 7003bb8f..69c164c5 100644 --- a/code/sys/sys_local.h +++ b/code/sys/sys_local.h @@ -68,6 +68,8 @@ void Sys_AnsiColorPrint( const char *msg ); int Sys_PID( void ); qboolean Sys_PIDIsRunning( int pid ); +qboolean Sys_OpenFolderInPlatformFileManager( const char *path ); + #ifdef PROTOCOL_HANDLER char *Sys_ParseProtocolUri( const char *uri ); #endif diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c index 623a197f..aaa32964 100644 --- a/code/sys/sys_main.c +++ b/code/sys/sys_main.c @@ -277,6 +277,22 @@ void Sys_InitPIDFile( const char *gamedir ) { } } +/* +================= +Sys_OpenFolderInFileManager +================= +*/ +qboolean Sys_OpenFolderInFileManager( const char *path, qboolean create ) +{ + if( create ) + { + if( FS_CreatePath( path ) ) + return qfalse; + } + + return Sys_OpenFolderInPlatformFileManager( path ); +} + /* ================= Sys_Exit @@ -880,4 +896,3 @@ int main( int argc, char **argv ) return 0; } - diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c index 60271015..a7b54e44 100644 --- a/code/sys/sys_unix.c +++ b/code/sys/sys_unix.c @@ -1016,3 +1016,23 @@ qboolean Sys_DllExtension( const char *name ) { return qfalse; } + +/* +============== +Sys_OpenFolderInPlatformFileManager +============== +*/ +qboolean Sys_OpenFolderInPlatformFileManager( const char *path ) +{ + Sys_ClearExecBuffer( ); + +#ifdef __APPLE__ + Sys_AppendToExecBuffer( "open" ); +#else + Sys_AppendToExecBuffer( "xdg-open" ); +#endif + + Sys_AppendToExecBuffer( path ); + + return Sys_Exec( ) == 0; +} diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index 3f70b1fd..7712e8b3 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -915,3 +915,13 @@ Check if filename should be allowed to be loaded as a DLL. qboolean Sys_DllExtension( const char *name ) { return COM_CompareExtension( name, DLL_EXT ); } + +/* +============== +Sys_OpenFolderInPlatformFileManager +============== +*/ +qboolean Sys_OpenFolderInPlatformFileManager( const char *path ) +{ + return ShellExecute( NULL, "explore", path, NULL, NULL, SW_SHOWDEFAULT ) > (HINSTANCE)32; +}