| 61 | } |
| 62 | |
| 63 | std::vector<std::filesystem::path> AssetResolver::resolvePathPattern( |
| 64 | const std::filesystem::path& path, |
| 65 | const std::string& pattern, |
| 66 | bool firstMatchOnly, |
| 67 | AssetCategory category |
| 68 | ) const |
| 69 | { |
| 70 | FALCOR_CHECK(category < AssetCategory::Count, "Invalid asset category."); |
| 71 | |
| 72 | std::regex regex(pattern); |
| 73 | |
| 74 | // If this is an existing absolute path, or a relative path to the working directory, search it. |
| 75 | std::filesystem::path absolute = std::filesystem::absolute(path); |
| 76 | std::vector<std::filesystem::path> resolved = globFilesInDirectory(absolute, regex, firstMatchOnly); |
| 77 | if (!resolved.empty()) |
| 78 | return resolved; |
| 79 | |
| 80 | // Otherwise, try to resolve using search paths. |
| 81 | // First try resolving for the specified asset category. |
| 82 | resolved = mSearchContexts[size_t(category)].resolvePathPattern(path, regex, firstMatchOnly); |
| 83 | |
| 84 | // If not resolved, try resolving for the Any asset category. |
| 85 | if (category != AssetCategory::Any && resolved.empty()) |
| 86 | resolved = mSearchContexts[size_t(AssetCategory::Any)].resolvePathPattern(path, regex, firstMatchOnly); |
| 87 | |
| 88 | if (resolved.empty()) |
| 89 | logWarning("Failed to resolve path pattern '{}/{}' for asset type '{}'.", path, pattern, category); |
| 90 | |
| 91 | return resolved; |
| 92 | } |
| 93 | |
| 94 | void AssetResolver::addSearchPath(const std::filesystem::path& path, SearchPathPriority priority, AssetCategory category) |
| 95 | { |