| 38 | } |
| 39 | |
| 40 | std::filesystem::path AssetResolver::resolvePath(const std::filesystem::path& path, AssetCategory category) const |
| 41 | { |
| 42 | FALCOR_CHECK(category < AssetCategory::Count, "Invalid asset category."); |
| 43 | |
| 44 | // If this is an existing absolute path, or a relative path to the working directory, return it. |
| 45 | std::filesystem::path absolute = std::filesystem::absolute(path); |
| 46 | if (std::filesystem::exists(absolute)) |
| 47 | return std::filesystem::canonical(absolute); |
| 48 | |
| 49 | // Otherwise, try to resolve using search paths. |
| 50 | // First try resolving for the specified asset category. |
| 51 | std::filesystem::path resolved = mSearchContexts[size_t(category)].resolvePath(path); |
| 52 | |
| 53 | // If not resolved, try resolving for the Any asset category. |
| 54 | if (category != AssetCategory::Any && resolved.empty()) |
| 55 | resolved = mSearchContexts[size_t(AssetCategory::Any)].resolvePath(path); |
| 56 | |
| 57 | if (resolved.empty()) |
| 58 | logWarning("Failed to resolve path '{}' for asset type '{}'.", path, category); |
| 59 | |
| 60 | return resolved; |
| 61 | } |
| 62 | |
| 63 | std::vector<std::filesystem::path> AssetResolver::resolvePathPattern( |
| 64 | const std::filesystem::path& path, |