| 342 | #endif |
| 343 | |
| 344 | std::unique_ptr<Stream> ContentResolver::OpenContentFile(StringView path, std::int32_t bufferSize) |
| 345 | { |
| 346 | // Search .paks first, then Content directory and Cache directory |
| 347 | #if !defined(DEATH_TARGET_EMSCRIPTEN) |
| 348 | for (std::size_t i = 0; i < _mountedPaks.size(); i++) { |
| 349 | auto mountPoint = _mountedPaks[i]->GetMountPoint(); |
| 350 | if (path.hasPrefix(mountPoint)) { |
| 351 | auto packedFile = _mountedPaks[i]->OpenFile(path.exceptPrefix(mountPoint.size()), bufferSize); |
| 352 | if (packedFile != nullptr && packedFile->IsValid()) { |
| 353 | return packedFile; |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | #endif |
| 358 | |
| 359 | String fullPath = fs::CombinePath(GetContentPath(), path); |
| 360 | if (fs::IsReadableFile(fullPath)) { |
| 361 | auto realFile = fs::Open(fullPath, FileAccess::Read, bufferSize); |
| 362 | if (realFile->IsValid()) { |
| 363 | return realFile; |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | fullPath = fs::CombinePath(GetCachePath(), path); |
| 368 | return fs::Open(fullPath, FileAccess::Read, bufferSize); |
| 369 | } |
| 370 | |
| 371 | void ContentResolver::BeginLoading() |
| 372 | { |
no test coverage detected