LAR is a simple archive format to pack multiple lua source files and arbitrary other resources into a single file.
A LAR archive file is divided into two parts: the payload and the index lookup table. All segments of the archive are 4 Byte aligned to ease reading and processing of the format. All integers are stored in network byte order, so an implementation has to use htonl() and htons() to properly read them.
Schema:
<payload:
<member:
<N*4 bytes: path of file #1>
<N*4 bytes: data of file #1>
>
<member:
<N*4 bytes: path of file #2>
<N*4 bytes: data of file #2>
>
...
<member:
<N*4 bytes: path of file #N>
<N*4 bytes: data of file #N>
>
>
<index table:
<entry:
<uint32: offset for path of file #1> <uint32: length for path of file #1>
<uint32: offset for data of file #1> <uint32: length for data of file #1>
<uint16: type of file #1> <uint16: flags of file #1>
>
<entry:
<uint32: offset for path of file #2> <uint32: length for path of file #2>
<uint32: offset for data of file #2> <uint32: length for data of file #2>
<uint16: type of file #2> <uint16: flags of file #2>
>
...
<entry:
<uint32: offset for path of file #N> <uint32: length for path of file #N>
<uint32: offset for data of file #N> <uint32: length for data of file #N>
<uint16: type of file #N> <uint16: flags of file #N>
>
>
<uint32: offset for begin of index table>
In order to process an LAR archive, an implementation would have to do the following steps:
A reference implementation can be found here: http://luci.subsignal.org/trac/browser/luci/trunk/contrib/lar
The lar.pl script is a simple packer for LAR archives and cli.c provides a utility to list and dump packed LAR archives.