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]
The file consists of three sections, the header, the table of contents and the heap. All fields are stored in big endian order.[4]
Offset# | Size (in bytes) | Purpose | |
---|---|---|---|
0 | 4 | File signature used to identify the file format as Xar. This should always equal xar! | |
4 | 2 | Header size | |
6 | 2 | Version of Xar format to use. Currently there is only version 1. | |
8 | 8 | Length of the TOC compressed data. | |
16 | 8 | Length of the TOC uncompressed data. | |
24 | 4 | Checksum algorithm: | |
28 | 0, 4, 36 | sometimes padding bytes or checksum algorithm name |
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