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;
}
Example #2
0
void V_MakeAbsolutePath( char *pOut, int outLen, const char *pPath, const char *pStartingDir )
{
	if ( V_IsAbsolutePath( pPath ) )
	{
		// pPath is not relative.. just copy it.
		V_strncpy( pOut, pPath, outLen );
	}
	else
	{
		// Make sure the starting directory is absolute..
		if ( pStartingDir && V_IsAbsolutePath( pStartingDir ) )
		{
			V_strncpy( pOut, pStartingDir, outLen );
		}
		else
		{
			if ( !_getcwd( pOut, outLen ) )
				Error( "V_MakeAbsolutePath: _getcwd failed." );

			if ( pStartingDir )
			{
				V_AppendSlash( pOut, outLen );
				V_strncat( pOut, pStartingDir, outLen, COPY_ALL_CHARACTERS );
			}
		}

		// Concatenate the paths.
		V_AppendSlash( pOut, outLen );
		V_strncat( pOut, pPath, outLen, COPY_ALL_CHARACTERS );
	}

	if ( !V_RemoveDotSlashes( pOut ) )
		Error( "V_MakeAbsolutePath: tried to \"..\" past the root." );

	V_FixSlashes( pOut );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool PyFS_IsAbsolutePath( const char *path )
{
	if( !path )
		return false;
	return V_IsAbsolutePath( path );
}