| 365 | #endif |
| 366 | |
| 367 | PakFile::PakFile(StringView path) |
| 368 | { |
| 369 | std::unique_ptr<Stream> s = std::make_unique<FileStream>(path, FileAccess::Read); |
| 370 | DEATH_ASSERT(s->GetSize() > FooterSize + 8, "Invalid .pak file", ); |
| 371 | |
| 372 | // Header size is 18 bytes |
| 373 | std::int64_t footerPosition = s->Seek(-FooterSize, SeekOrigin::End); |
| 374 | DEATH_ASSERT(footerPosition >= 0, ".pak file must be opened from seekable stream", ); |
| 375 | |
| 376 | std::uint8_t signature[sizeof(Signature)]; |
| 377 | s->Read(signature, sizeof(signature)); |
| 378 | |
| 379 | // If signature doesn't match, try to find .pak embedded in PE/ELF executable |
| 380 | if DEATH_UNLIKELY(std::memcmp(signature, Signature, sizeof(Signature)) != 0) { |
| 381 | footerPosition = FindRelocatedFooter(s); |
| 382 | DEATH_ASSERT(footerPosition >= 0, "Invalid .pak file", ); |
| 383 | } |
| 384 | |
| 385 | std::uint16_t fileVersion = s->ReadValueAsLE<std::uint16_t>(); |
| 386 | DEATH_ASSERT(fileVersion == Version, "Unsupported .pak file version", ); |
nothing calls this directly
no test coverage detected