| 408 | : searchPaths(std::move(searchPaths_)) {} |
| 409 | |
| 410 | std::string |
| 411 | FilesystemResourceProvider::Resolve(std::string_view resourceName) const { |
| 412 | const std::string resourcePath(resourceName); |
| 413 | if (resourcePath.empty()) { |
| 414 | throw FileNotFound(resourcePath); |
| 415 | } |
| 416 | |
| 417 | if (IsAbsolutePath(resourcePath)) { |
| 418 | if (IsRegularFileUtf8(resourcePath)) { |
| 419 | return resourcePath; |
| 420 | } |
| 421 | throw FileNotFound(resourcePath); |
| 422 | } |
| 423 | |
| 424 | std::ostringstream searched; |
| 425 | for (size_t i = 0; i < searchPaths.size(); i++) { |
| 426 | const std::string& root = searchPaths[i]; |
| 427 | if (i != 0) { |
| 428 | searched << ", "; |
| 429 | } |
| 430 | searched << root; |
| 431 | |
| 432 | const std::string candidate = JoinPath(root, resourcePath); |
| 433 | if (IsRegularFileUtf8(candidate)) { |
| 434 | return candidate; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | throw FileNotFound(resourcePath + " (searched: " + searched.str() + ")"); |
| 439 | } |
| 440 | |
| 441 | ZipResourceProvider::ZipResourceProvider(std::string zipFileName) |
| 442 | : internal(new Internal(zipFileName)) {} |