static bool SrcPyPathIsInGameFolder( const char *pPath ) { #if 0 if( SrcPySystem()->IsPathProtected() ) { // Verify the file is in the gamefolder char searchPaths[MAX_PATH]; filesystem->GetSearchPath( "MOD", true, searchPaths, sizeof( searchPaths ) ); V_StripTrailingSlash( searchPaths ); if( V_IsAbsolutePath( pPath ) ) { if( V_strnicmp( pPath, searchPaths, V_strlen( searchPaths ) ) != 0 ) return false; } else { char pFullPath[MAX_PATH]; char moddir[MAX_PATH]; filesystem->RelativePathToFullPath( ".", "MOD", moddir, sizeof( moddir ) ); V_MakeAbsolutePath( pFullPath, sizeof( pFullPath ), pPath, moddir ); if( V_strnicmp( pFullPath, searchPaths, V_strlen(searchPaths) ) != 0 ) return false; } } #endif // 0 return true; }
FSReturnCode_t FileSystem_LoadSearchPaths( CFSSearchPathsInit &initInfo ) { if ( !initInfo.m_pFileSystem || !initInfo.m_pDirectoryName ) return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_LoadSearchPaths: Invalid parameters specified." ); KeyValues *pMainFile, *pFileSystemInfo, *pSearchPaths; FSReturnCode_t retVal = LoadGameInfoFile( initInfo.m_pDirectoryName, pMainFile, pFileSystemInfo, pSearchPaths ); if ( retVal != FS_OK ) return retVal; // All paths except those marked with |gameinfo_path| are relative to the base dir. char baseDir[MAX_PATH]; if ( !FileSystem_GetBaseDir( baseDir, sizeof( baseDir ) ) ) return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetBaseDir failed." ); // The MOD directory is always the one that contains gameinfo.txt Q_strncpy( initInfo.m_ModPath, initInfo.m_pDirectoryName, sizeof( initInfo.m_ModPath ) ); #define GAMEINFOPATH_TOKEN "|gameinfo_path|" #define BASESOURCEPATHS_TOKEN "|all_source_engine_paths|" const char *pszExtraSearchPath = CommandLine()->ParmValue( "-insert_search_path" ); if ( pszExtraSearchPath ) { CUtlStringList vecPaths; V_SplitString( pszExtraSearchPath, ",", vecPaths ); FOR_EACH_VEC( vecPaths, idxExtraPath ) { char szAbsSearchPath[MAX_PATH]; Q_StripPrecedingAndTrailingWhitespace( vecPaths[ idxExtraPath ] ); V_MakeAbsolutePath( szAbsSearchPath, sizeof( szAbsSearchPath ), vecPaths[ idxExtraPath ], baseDir ); V_FixSlashes( szAbsSearchPath ); if ( !V_RemoveDotSlashes( szAbsSearchPath ) ) Error( "Bad -insert_search_path - Can't resolve pathname for '%s'", szAbsSearchPath ); V_StripTrailingSlash( szAbsSearchPath ); FileSystem_AddLoadedSearchPath( initInfo, "GAME", szAbsSearchPath, false ); FileSystem_AddLoadedSearchPath( initInfo, "MOD", szAbsSearchPath, false ); } }
CUtlString CUtlString::AbsPath( const char *pStartingDir ) { char szNew[MAX_PATH]; V_MakeAbsolutePath( szNew, sizeof( szNew ), this->String(), pStartingDir ); return CUtlString( szNew ); }