Xar (archiver) explained

XAR
Noextcode:on
Extensions:,,
Mime:application/x-xar[1]
Uniform Type:com.apple.xar-archive
Magic:xar!
Genre:archive file format
Extended From:XML, gzip

XAR (short for eXtensible ARchive format) is an open source file archiver and the archiver’s file format. It was created within the OpenDarwin project and is used in macOS X 10.5 and up for software installation routines, as well as browser extensions in Safari 5.0 and up. Xar replaced the use of gzipped pax files.[2]

One development branch of RPM, RPM5, uses xar.[3]

File structure

The file consists of three sections, the header, the table of contents and the heap. All fields are stored in big endian order.[4]

Header

Offset#Size
(in bytes)
Purpose
04File signature used to identify the file format as Xar.
This should always equal xar!
42Header size
62Version of Xar format to use.
Currently there is only version 1.
88Length of the TOC compressed data.
168Length of the TOC uncompressed data.
244Checksum algorithm:
    280, 4, 36sometimes padding bytes or checksum algorithm name

    Table of contents

    Xar is different from cpio, tar or ar in that it stores the TOC (table of contents) in the beginning of the file, making appending to an archive more complicated, but making it unnecessary to scan through the archive to extract an individual contained file. The table of contents is stored as a zlib compressed, UTF-8 encoded, XML document.[6] [4] Each file that is stored in the Xar is independently compressed/encoded. This gives the ability to have the file(s) encoded using gzip while having another file in the same archive encoded using a different method such as bzip2. On some systems the archive member can also be encoded by xz or lzma compression method.

    Example Table of contents 0 20 staff 20 joe 501 0755 directory com.foobar 20 501 0775 directory Contents 428 20 1005 a5f6f1461213a904f831d4ef6f214638342842ed 21d21a0c90378248ce0dfb6f345376d1b00d65fc 20 501 0664 file Info.plist 20 501 0775 directory Resources 14868 448 274432 efe5c97921de7ccc5aebc158d158e9d4280d6814 45c8be42d1d9afdb57ddd5e9311453010ec46161 20 501 0664 file foobar 17635 15316 45056 3c761ffcc81ee6e232e4f4a1c4a81654c26c4e52 0ea31f8ef0e5987a1838a64ab5c26ebf3ee4bc37 20 501 0664 file docSet.skidx 20 501 0775 directory Documents 35790 32951 209242 5242cd71585c34e722932f324706f8c00e1ae0c5 c0e013e53d829511835e2b429abb5198731e9a3e 20 501 0664 file foobar.html

    External links

    Notes and References

    1. Web site: application/x-xar. en. 2019-03-19.
    2. http://www.nabble.com/xar-in-Mac-OS-X-t2081148.html Nabble – xar in Mac OS X
    3. http://rpm5.org/roadmap.php RPM 5 package manager
    4. Web site: Xarformat · mackyle/Xar Wiki. .
    5. Web site: xar - eXtensible ARchiver mojave man page. 2019-03-26. Braun. Rob. Fuller. Landon. Leimbach. David. Van Vechten. Kevin. 2015-06-04.
    6. Web site: Google Code Archive - Long-term storage for Google Code Project Hosting.