MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / PakFile

Method PakFile

Sources/Shared/IO/PakFile.cpp:367–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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", );

Callers

nothing calls this directly

Calls 6

DEATH_ASSERTFunction · 0.85
FindRelocatedFooterFunction · 0.85
DEATH_UNLIKELYFunction · 0.70
GetSizeMethod · 0.45
SeekMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected