=============== idFileSystemLocal::ValidateDownloadPakForChecksum =============== */
| 2454 | =============== |
| 2455 | */ |
| 2456 | int idFileSystemLocal::ValidateDownloadPakForChecksum( int checksum, char path[ MAX_STRING_CHARS ] ) { |
| 2457 | int i; |
| 2458 | idStrList testList; |
| 2459 | idStr name; |
| 2460 | idStr relativePath; |
| 2461 | pack_t *pak = GetPackForChecksum( checksum ); |
| 2462 | |
| 2463 | if ( !pak ) { |
| 2464 | return 0; |
| 2465 | } |
| 2466 | |
| 2467 | // validate this pak for a potential download |
| 2468 | // ignore pak*.pk4 for download. those are reserved to distribution and cannot be downloaded |
| 2469 | name = pak->pakFilename; |
| 2470 | name.StripPath(); |
| 2471 | if ( strstr( name.c_str(), "pak" ) == name.c_str() ) { |
| 2472 | common->DPrintf( "%s is not a donwloadable pak\n", pak->pakFilename.c_str() ); |
| 2473 | return 0; |
| 2474 | } |
| 2475 | |
| 2476 | // extract a path that includes the fs_game: != OSPathToRelativePath |
| 2477 | testList.Append( fs_savepath.GetString() ); |
| 2478 | testList.Append( fs_devpath.GetString() ); |
| 2479 | testList.Append( fs_basepath.GetString() ); |
| 2480 | testList.Append( fs_cdpath.GetString() ); |
| 2481 | for ( i = 0; i < testList.Num(); i ++ ) { |
| 2482 | if ( testList[ i ].Length() && !testList[ i ].Icmpn( pak->pakFilename, testList[ i ].Length() ) ) { |
| 2483 | relativePath = pak->pakFilename.c_str() + testList[ i ].Length() + 1; |
| 2484 | break; |
| 2485 | } |
| 2486 | } |
| 2487 | if ( i == testList.Num() ) { |
| 2488 | common->Warning( "idFileSystem::ValidateDownloadPak: failed to extract relative path for %s", pak->pakFilename.c_str() ); |
| 2489 | return 0; |
| 2490 | } |
| 2491 | idStr::Copynz( path, relativePath, MAX_STRING_CHARS ); |
| 2492 | return pak->length; |
| 2493 | } |
| 2494 | |
| 2495 | /* |
| 2496 | ===================== |