MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / OpenURL

Method OpenURL

neo/sys/linux/main.cpp:363–403  ·  view source on GitHub ↗

================= Sys_OpenURL ================= */

Source from the content-addressed store, hash-verified

361=================
362*/
363void idSysLocal::OpenURL( const char *url, bool quit ) {
364 const char *script_path;
365 idFile *script_file;
366 char cmdline[ 1024 ];
367
368 static bool quit_spamguard = false;
369
370 if ( quit_spamguard ) {
371 common->DPrintf( "Sys_OpenURL: already in a doexit sequence, ignoring %s\n", url );
372 return;
373 }
374
375 common->Printf( "Open URL: %s\n", url );
376 // opening an URL on *nix can mean a lot of things ..
377 // just spawn a script instead of deciding for the user :-)
378
379 // look in the savepath first, then in the basepath
380 script_path = fileSystem->BuildOSPath( cvarSystem->GetCVarString( "fs_savepath" ), "", "openurl.sh" );
381 script_file = fileSystem->OpenExplicitFileRead( script_path );
382 if ( !script_file ) {
383 script_path = fileSystem->BuildOSPath( cvarSystem->GetCVarString( "fs_basepath" ), "", "openurl.sh" );
384 script_file = fileSystem->OpenExplicitFileRead( script_path );
385 }
386 if ( !script_file ) {
387 common->Printf( "Can't find URL script 'openurl.sh' in either savepath or basepath\n" );
388 common->Printf( "OpenURL '%s' failed\n", url );
389 return;
390 }
391 fileSystem->CloseFile( script_file );
392
393 // if we are going to quit, only accept a single URL before quitting and spawning the script
394 if ( quit ) {
395 quit_spamguard = true;
396 }
397
398 common->Printf( "URL script: %s\n", script_path );
399
400 // StartProcess is going to execute a system() call with that - hence the &
401 idStr::snPrintf( cmdline, 1024, "%s '%s' &", script_path, url );
402 sys->StartProcess( cmdline, quit );
403}
404
405/*
406===============

Callers

nothing calls this directly

Calls 7

BuildOSPathMethod · 0.80
GetCVarStringMethod · 0.80
OpenExplicitFileReadMethod · 0.80
CloseFileMethod · 0.80
DPrintfMethod · 0.45
PrintfMethod · 0.45
StartProcessMethod · 0.45

Tested by

no test coverage detected