================ idFileSystemLocal::FileIsInPAK ================ */
| 959 | ================ |
| 960 | */ |
| 961 | bool idFileSystemLocal::FileIsInPAK( const char *relativePath ) { |
| 962 | searchpath_t *search; |
| 963 | pack_t *pak; |
| 964 | fileInPack_t *pakFile; |
| 965 | int hash; |
| 966 | |
| 967 | if ( !searchPaths ) { |
| 968 | common->FatalError( "Filesystem call made without initialization\n" ); |
| 969 | } |
| 970 | |
| 971 | if ( !relativePath ) { |
| 972 | common->FatalError( "idFileSystemLocal::FileIsInPAK: NULL 'relativePath' parameter passed\n" ); |
| 973 | } |
| 974 | |
| 975 | // qpaths are not supposed to have a leading slash |
| 976 | if ( relativePath[0] == '/' || relativePath[0] == '\\' ) { |
| 977 | relativePath++; |
| 978 | } |
| 979 | |
| 980 | // make absolutely sure that it can't back up the path. |
| 981 | // The searchpaths do guarantee that something will always |
| 982 | // be prepended, so we don't need to worry about "c:" or "//limbo" |
| 983 | if ( strstr( relativePath, ".." ) || strstr( relativePath, "::" ) ) { |
| 984 | return false; |
| 985 | } |
| 986 | |
| 987 | // |
| 988 | // search through the path, one element at a time |
| 989 | // |
| 990 | |
| 991 | hash = HashFileName( relativePath ); |
| 992 | |
| 993 | for ( search = searchPaths; search; search = search->next ) { |
| 994 | // is the element a pak file? |
| 995 | if ( search->pack && search->pack->hashTable[hash] ) { |
| 996 | |
| 997 | // disregard if it doesn't match one of the allowed pure pak files - or is a localization file |
| 998 | if ( serverPaks.Num() ) { |
| 999 | GetPackStatus( search->pack ); |
| 1000 | if ( search->pack->pureStatus != PURE_NEVER && !serverPaks.Find( search->pack ) ) { |
| 1001 | continue; // not on the pure server pak list |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | // look through all the pak file elements |
| 1006 | pak = search->pack; |
| 1007 | pakFile = pak->hashTable[hash]; |
| 1008 | do { |
| 1009 | // case and separator insensitive comparisons |
| 1010 | if ( !FilenameCompare( pakFile->name, relativePath ) ) { |
| 1011 | return true; |
| 1012 | } |
| 1013 | pakFile = pakFile->next; |
| 1014 | } while( pakFile != NULL ); |
| 1015 | } |
| 1016 | } |
| 1017 | return false; |
| 1018 | } |
no test coverage detected