MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / scanReferencedAssets

Method scanReferencedAssets

Engine/source/assets/assetManager.cpp:2583–2681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2581//-----------------------------------------------------------------------------
2582
2583bool AssetManager::scanReferencedAssets( const char* pPath, const char* pExtension, const bool recurse )
2584{
2585 // Debug Profiling.
2586 PROFILE_SCOPE(AssetManager_ScanReferencedAssets);
2587
2588 // Sanity!
2589 AssertFatal( pPath != NULL, "Cannot scan referenced assets with NULL path." );
2590 AssertFatal( pExtension != NULL, "Cannot scan referenced assets with NULL extension." );
2591
2592 // Expand path location.
2593 String relativePath = Platform::makeRelativePathName(pPath, NULL);
2594 String pattern = "*.";
2595 pattern += pExtension;
2596
2597 Torque::Path scanPath = Torque::FS::GetCwd();
2598 scanPath.setPath(relativePath);
2599
2600 // Find files.
2601 Vector<String> files;
2602 S32 numAssets = Torque::FS::FindByPattern(scanPath, pattern, recurse, files, true);
2603 if (numAssets <= 0)
2604 {
2605 // Failed so warn.
2606 Con::warnf( "Asset Manager: Failed to scan referenced assets in directory '%s'.", pPath );
2607 return false;
2608 }
2609
2610 // Info.
2611 if ( mEchoInfo )
2612 {
2613 Con::printSeparator();
2614 Con::printf( "Asset Manager: Scanning for referenced assets in path '%s' for files with extension '%s'...", pPath, pExtension );
2615 }
2616
2617 TamlAssetReferencedVisitor assetReferencedVisitor;
2618
2619 // Iterate files.
2620 for (S32 i = 0; i < numAssets; ++i)
2621 {
2622 Torque::Path assetPath = files[i];
2623
2624 // Clear referenced assets.
2625 assetReferencedVisitor.clear();
2626
2627 // Format full file-path.
2628 char assetFileBuffer[1024];
2629 dSprintf( assetFileBuffer, sizeof(assetFileBuffer), "%s/%s", assetPath.getPath().c_str(), assetPath.getFullFileName().c_str());
2630
2631 // Format reference file-path.
2632 typeReferenceFilePath referenceFilePath = StringTable->insert( assetFileBuffer );
2633
2634 // Parse the filename.
2635 if ( !mTaml.parse( referenceFilePath, assetReferencedVisitor ) )
2636 {
2637 // Warn.
2638 Con::warnf( "Asset Manager: Failed to parse file containing asset references: '%s'.", referenceFilePath );
2639 continue;
2640 }

Callers

nothing calls this directly

Calls 15

FindByPatternFunction · 0.85
printSeparatorFunction · 0.85
printfFunction · 0.85
dSprintfFunction · 0.85
printBlankLineFunction · 0.85
warnfFunction · 0.50
setPathMethod · 0.45
clearMethod · 0.45
c_strMethod · 0.45
getPathMethod · 0.45
insertMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected