Beispiel #1
0
//////////////////////////////////////////////////////////////////////////
// shouldImportResource
BcBool CsCore::shouldImportResource( const BcPath& FileName, BcBool ForceImport )
{
	BcBool Import = BcFalse;

	// Only attempt import if the resource filename is valid.
	if( isValidResource( FileName ) )
	{
		// Only force import if the resource is actually valid.
		Import = ForceImport;

		// Check if the packed resource exists.
		BcPath PackedPath( "./PackedContent" );
		PackedPath.join( FileName.getFileName() );
		if( FsCore::pImpl()->fileExists( (*PackedPath).c_str() ) == BcFalse )
		{
			Import = BcTrue;
		}

		// Only do a dependancy check if we have a packed file.
		// Dependancies will be regenerated on import.
		if( Import == BcFalse )
		{
			// Load dependancies if we don't have any resident in memory.
			if( DependancyMap_.find( *FileName ) == DependancyMap_.end() )
			{
				loadDependancies( FileName );
			}
	
			// Grab dependancy list for file so we don't do more work than required.
			if( DependancyMap_.find( *FileName ) != DependancyMap_.end() )
			{
				CsDependancyList& DependancyList = DependancyMap_[ *FileName ];
		
				for( CsDependancyListIterator It( DependancyList.begin() ); It != DependancyList.end(); ++It )
				{
					if( (*It).hasChanged() == BcTrue )
					{
						// Update dependancy stats.
						(*It).updateStats();
		
						// Set import to true.
						Import = BcTrue;
					}
				}
			}
			else
			{
				// No dependancy list, do the import.
				Import = BcTrue;
			}
		}
	}

	return Import;	
}