1 1.1 christos #------------------------------------------------------------------------------ 2 1.1 christos # $File: pack,v 1.1 2024/08/30 17:29:28 christos Exp $ 3 1.1 christos # file(1) magic for things that have PACK as magic 4 1.1 christos 5 1.1 christos 0 string PACK 6 1.1 christos # Type: Git pack 7 1.1 christos # From: Adam Buchbinder <adam.buchbinder (a] gmail.com> 8 1.1 christos # Update: Joerg Jenderek 9 1.1 christos # URL: http://fileformats.archiveteam.org/wiki/Git 10 1.1 christos # reference: https://github.com/git/git/blob/master/Documentation/technical/pack-format.txt 11 1.1 christos # The actual magic is 'PACK', but that clashes with Doom/Quake packs. However, 12 1.1 christos # those have a little-endian offset immediately following the magic 'PACK', 13 1.1 christos # the first byte of which is never 0, while the first byte of the Git pack 14 1.1 christos # version, since it's a tiny number stored in big-endian format, is always 0. 15 1.1 christos # GRR: line above is too general as it matches also PackDir archive ./acorn 16 1.1 christos # test for major version. Git 2017 accepts version number 2 or 3 17 1.1 christos >4 ubelong <9 18 1.1 christos # Acorn PackDir with method 0 compression has root like ADFS::HardDisc4.$.AsylumSrc 19 1.1 christos # or SystemDevice::foobar 20 1.1 christos >>9 search/13 :: 21 1.1 christos # but in git binary 22 1.1 christos >>9 default x Git pack 23 1.1 christos !:mime application/x-git 24 1.1 christos !:ext pack 25 1.1 christos # 4 GB limit implies unsigned integer 26 1.1 christos >>>4 ubelong x \b, version %u 27 1.1 christos >>>8 ubelong x \b, %u objects 28 1.1 christos 29 1.1 christos # From: Joerg Jenderek 30 1.1 christos # URL: https://www.kyzer.me.uk/pack/xad/#PackDir 31 1.1 christos # reference: https://www.kyzer.me.uk/pack/xad/xad_PackDir.lha/PackDir.c 32 1.1 christos # GRR: line below is too general as it matches also "Git pack" in ./revision 33 1.1 christos # check for valid compression method 0-4 34 1.1 christos >5 ulelong <5 35 1.1 christos # https://www.riscosopen.org/wiki/documentation/show/Introduction%20To%20Filing%20Systems 36 1.1 christos # To skip "Git pack" version 0 test for root directory object like 37 1.1 christos # ADFS::RPC.$.websitezip.FONTFIX 38 1.1 christos >>9 string >ADFS\ PackDir archive (RISC OS) 39 1.1 christos # TrID labels above as "Acorn PackDir compressed Archive" 40 1.1 christos # compression mode y (0 - 4) for GIF LZW with a maximum n bits 41 1.1 christos # (y~n,0~12,1~13,2~14,3~15,4~16) 42 1.1 christos >>>5 ulelong+12 x \b, LZW %u-bits compression 43 1.1 christos # https://www.filebase.org.uk/filetypes 44 1.1 christos # !Packdir compressed archive has three hexadecimal digits code 68E 45 1.1 christos !:mime application/x-acorn-68E 46 1.1 christos !:ext pkd/bin 47 1.1 christos # null terminated root directory object like IDEFS::IDE-4.$.Apps.GRAPHICS.!XFMPdemo 48 1.1 christos >>>9 string x \b, root "%s" 49 1.1 christos # load address 0xFFFtttdd, ttt is the object filetype and dddddddddd is time 50 1.1 christos >>>>&1 ulelong x \b, load address %#x 51 1.1 christos # execution address 0xdddddddd dddddddddd is 40 bit unsigned centiseconds since 1.1.1900 UTC 52 1.1 christos >>>>&5 ulelong x \b, exec address %#x 53 1.1 christos # attributes (bits: 0~owner read,1~owner write,3~no delete,4~public read,5~public write) 54 1.1 christos >>>>&9 ulelong x \b, attributes %#x 55 1.1 christos # number of entries in this directory. for root dir 0 56 1.1 christos #>>>&13 ulelong x \b, entries %#x 57 1.1 christos # the entries start here with object name 58 1.1 christos >>>>&17 string x \b, 1st object "%s" 59 1.1 christos 60 1.1 christos # Update: Joerg Jenderek 61 1.1 christos # URL: http://fileformats.archiveteam.org/wiki/PAK 62 1.1 christos # reference: https://quakewiki.org/wiki/.pak 63 1.1 christos # GRR: line below is too general as it matches also Acorn PackDir compressed Archive 64 1.1 christos # real Quake examples like pak0.pak have only some hundreds like 150 files 65 1.1 christos # So test for few files 66 1.1 christos >8 ulelong <0x01000000 67 1.1 christos # in file version 5.32 test for null terminator is only true for 68 1.1 christos # offset ~< FILE_BYTES_MAX = 1 MB defined in ../../src/file.h 69 1.1 christos # look for null terminator of 1st entry name 70 1.1 christos >>(4.l+55) ubyte 0 Quake I or II world or extension 71 1.1 christos !:mime application/x-dzip 72 1.1 christos !:ext pak 73 1.1 christos #>>>8 ulelong x \b, table size %u 74 1.1 christos # dividing this by entry size (64) gives number of files 75 1.1 christos >>>8 ulelong/64 x \b, %u files 76 1.1 christos # offset to the beginning of the file table 77 1.1 christos >>>4 ulelong x \b, offset %#x 78 1.1 christos # 1st file entry 79 1.1 christos >>>(4.l) use pak-entry 80 1.1 christos # 2nd file entry 81 1.1 christos #>>>4 ulelong+64 x \b, offset %#x 82 1.1 christos #>>>(4.l+64) use pak-entry 83 1.1 christos # 84 1.1 christos # display file table entry of Quake PAK archive 85 1.1 christos 0 name pak-entry 86 1.1 christos # normally entry start after header which implies offset 12 or higher 87 1.1 christos >56 ulelong >11 88 1.1 christos # the offset from the beginning of pak to beginning of this entry file contents 89 1.1 christos >>56 ulelong x at %#x 90 1.1 christos # the size of file for this entry 91 1.1 christos >>60 ulelong x %u bytes 92 1.1 christos # 56 byte null-terminated entry name string includes path like maps/e1m1.bsp 93 1.1 christos >>0 string x '%-.56s' 94 1.1 christos # inspect entry content by jumping to entry offset 95 1.1 christos >>(56) indirect x \b: 96 1.1 christos 97 1.1 christos #0 string -1\x0a Quake I demo 98 1.1 christos #>30 string x version %.4s 99 1.1 christos #>61 string x level %s 100 1.1 christos 101 1.1 christos #0 string 5\x0a Quake I save 102