MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / scanDeclaredAssets

Method scanDeclaredAssets

Engine/source/assets/assetManager.cpp:2313–2513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2311//-----------------------------------------------------------------------------
2312
2313bool AssetManager::scanDeclaredAssets( const char* pPath, const char* pExtension, const bool recurse, ModuleDefinition* pModuleDefinition )
2314{
2315 // Debug Profiling.
2316 PROFILE_SCOPE(AssetManager_ScanDeclaredAssets);
2317
2318 // Sanity!
2319 AssertFatal( pPath != NULL, "Cannot scan declared assets with NULL path." );
2320 AssertFatal( pExtension != NULL, "Cannot scan declared assets with NULL extension." );
2321
2322 // Expand path location.
2323 char pathBuffer[1024];
2324 Con::expandPath( pathBuffer, sizeof(pathBuffer), pPath );
2325
2326 // Find files.
2327 Vector<Platform::FileInfo> files;
2328 if ( !Platform::dumpPath( pathBuffer, files, recurse ? -1 : 0 ) )
2329 {
2330 // Failed so warn.
2331 Con::warnf( "Asset Manager: Failed to scan declared assets in directory '%s'.", pathBuffer );
2332 return false;
2333 }
2334
2335 // Is the asset file-path located within the specified module?
2336 if ( !Con::isBasePath( pathBuffer, pModuleDefinition->getModulePath() ) )
2337 {
2338 // No, so warn.
2339 Con::warnf( "Asset Manager: Could not add declared asset file '%s' as file does not exist with module path '%s'",
2340 pathBuffer,
2341 pModuleDefinition->getModulePath() );
2342 return false;
2343 }
2344
2345 // Info.
2346 if ( mEchoInfo )
2347 {
2348 Con::printSeparator();
2349 Con::printf( "Asset Manager: Scanning for declared assets in path '%s' for files with extension '%s'...", pathBuffer, pExtension );
2350 }
2351
2352 // Fetch extension length.
2353 const U32 extensionLength = dStrlen( pExtension );
2354
2355 // Fetch module assets.
2356 ModuleDefinition::typeModuleAssetsVector& moduleAssets = pModuleDefinition->getModuleAssets();
2357
2358 TamlAssetDeclaredVisitor assetDeclaredVisitor;
2359
2360 // Iterate files.
2361 for ( Vector<Platform::FileInfo>::iterator fileItr = files.begin(); fileItr != files.end(); ++fileItr )
2362 {
2363 // Fetch file info.
2364 Platform::FileInfo& fileInfo = *fileItr;
2365
2366 // Fetch filename.
2367 const char* pFilename = fileInfo.pFileName;
2368
2369 // Find filename length.
2370 const U32 filenameLength = dStrlen( pFilename );

Callers

nothing calls this directly

Calls 15

expandPathFunction · 0.85
warnfFunction · 0.85
isBasePathFunction · 0.85
printSeparatorFunction · 0.85
printfFunction · 0.85
dStricmpFunction · 0.85
dSprintfFunction · 0.85
printBlankLineFunction · 0.85
getModulePathMethod · 0.80
EmptyStringMethod · 0.80
getModuleIdMethod · 0.80
insertEqualMethod · 0.80

Tested by

no test coverage detected