# Quake PAK fixtures (tools/fixtures.py): PAK files written here from the Quake source's dpackheader_t / dpackfile_t # layout (header, file data in order, directory at the end: the layout id's qpak and most tools write), in the Quake # ("PACK", 56-byte names) and SiN ("SPAK", 120-byte names) variants, plus one with the directory first and padding # between files; with the expected entries read back by an independent Python reader here. # tests/gen/pak.luau { { name, variant, data, entries = { { name, size, crc } }, files = { { name, data } } } } import struct, zlib VARIANTS = {"quake": (b"PACK", 56), "sin": (b"SPAK", 120)} def write(files, variant="quake", dir_first=False, pad=0): magic, nl = VARIANTS[variant] dirlen = len(files) * (nl + 8) out = bytearray(magic + b"\0" * 8) if dir_first: dirofs = 12 out += b"\0" * dirlen offs = [] for name, data in files: out += b"\xee" * pad offs.append(len(out)) out += data if not dir_first: dirofs = len(out) out += b"\0" * dirlen for i, (name, data) in enumerate(files): struct.pack_into("<%dsII" % nl, out, dirofs + i * (nl + 8), name.encode(), offs[i], len(data)) struct.pack_into("