| 2389 | //----------------------------------------------------------------------------- |
| 2390 | |
| 2391 | bool AssetManager::scanDeclaredAssets( const char* pPath, const char* pExtension, const bool recurse, ModuleDefinition* pModuleDefinition ) |
| 2392 | { |
| 2393 | // Debug Profiling. |
| 2394 | PROFILE_SCOPE(AssetManager_ScanDeclaredAssets); |
| 2395 | |
| 2396 | // Sanity! |
| 2397 | AssertFatal( pPath != NULL, "Cannot scan declared assets with NULL path." ); |
| 2398 | AssertFatal( pExtension != NULL, "Cannot scan declared assets with NULL extension." ); |
| 2399 | |
| 2400 | // Expand path location. |
| 2401 | String relativePath = Platform::makeRelativePathName(pPath, NULL); |
| 2402 | // Strip any trailing slash off the path. |
| 2403 | if (relativePath.endsWith("/")) |
| 2404 | relativePath = relativePath.substr(0, relativePath.length() - 1); |
| 2405 | |
| 2406 | Torque::Path scanPath = Torque::FS::GetCwd(); |
| 2407 | scanPath.setPath(relativePath); |
| 2408 | |
| 2409 | // Find files. |
| 2410 | Vector<String> files; |
| 2411 | S32 numAssets = Torque::FS::FindByPattern(scanPath, pExtension, recurse, files, true); |
| 2412 | if (numAssets <= 0) |
| 2413 | { |
| 2414 | // Failed so warn. or don't... Common error when scanning modules with no assets |
| 2415 | //Con::warnf( "Asset Manager: No declared assets found in directory '%s'.", relativePath.c_str()); |
| 2416 | return false; |
| 2417 | } |
| 2418 | |
| 2419 | // Is the asset file-path located within the specified module? |
| 2420 | if ( !Con::isBasePath(relativePath.c_str(), pModuleDefinition->getModulePath()) ) |
| 2421 | { |
| 2422 | // No, so warn. |
| 2423 | Con::warnf( "Asset Manager: Could not add declared asset file '%s' as file does not exist with module path '%s'", |
| 2424 | pPath, |
| 2425 | pModuleDefinition->getModulePath() ); |
| 2426 | return false; |
| 2427 | } |
| 2428 | |
| 2429 | // Info. |
| 2430 | if ( mEchoInfo ) |
| 2431 | { |
| 2432 | Con::printSeparator(); |
| 2433 | Con::printf( "Asset Manager: Scanning for declared assets in path '%s' for files with extension '%s'...", relativePath.c_str(), pExtension ); |
| 2434 | } |
| 2435 | |
| 2436 | // Fetch module assets. |
| 2437 | ModuleDefinition::typeModuleAssetsVector& moduleAssets = pModuleDefinition->getModuleAssets(); |
| 2438 | |
| 2439 | TamlAssetDeclaredVisitor assetDeclaredVisitor; |
| 2440 | |
| 2441 | // Iterate files. |
| 2442 | for (S32 i = 0; i < numAssets; ++i) |
| 2443 | { |
| 2444 | Torque::Path assetPath = files[i]; |
| 2445 | |
| 2446 | // Clear declared assets. |
| 2447 | assetDeclaredVisitor.clear(); |
| 2448 |
nothing calls this directly
no test coverage detected