================= Sys_OpenURL ================= */
| 361 | ================= |
| 362 | */ |
| 363 | void 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 | =============== |
nothing calls this directly
no test coverage detected