Add Sys_OpenFolderInFileManager

This commit is contained in:
Tim Angus 2025-10-11 13:57:29 +01:00
parent 5c242be241
commit 411f5a6924
5 changed files with 49 additions and 1 deletions

View File

@ -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 );

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}