Difference between revisions of "ZIM file format"

Jump to navigation Jump to search
811 bytes added ,  10:05, 17 October 2010
no edit summary
Line 3: Line 3:


== Header ==
== Header ==
 
A ZIM file starts with a header. This is offset 0.
A ZIM file starts with a header. This starts always at offset 0.


Length in byte, all types are littlendian.
Length in byte, all types are littlendian.
Line 33: Line 32:
| layoutPage            || integer ||  68 ||    4 || layout page or 0xffffffffff if no layout page
| layoutPage            || integer ||  68 ||    4 || layout page or 0xffffffffff if no layout page
|}
|}
Each article in the ZIM file has a directory entry. Since the directory entry has a variable size we have an index pointerlist which is a list of 4-byte offsets. The pointers points to the directory entries.


== MIME Type List (mimeListPos) ==
== MIME Type List (mimeListPos) ==
Line 95: Line 92:
* accessing directory entries by title also makes use of cached directory entries which are referenced by the URL pointers, as implemented in zimlib.
* accessing directory entries by title also makes use of cached directory entries which are referenced by the URL pointers, as implemented in zimlib.


== Directory entries ==
== Directory Entries ==
Directory entries hold the meta information about all articles, images and other objects in a ZIM file.
Directory entries hold the meta information about all articles, images and other objects in a ZIM file.


There are 2 types of directory entries: article entries and redirect entries. If the first two bytes are 0xffff the
There are two types of directory entries: article entries and redirect entries. If the first two bytes are 0xffff the directory entry is a redirect.
directory entrie is a redirect.


=== article entry ===
=== Article Entry ===
{|{{Prettytable}}
{|{{Prettytable}}
! Field Name !! Type !! Offset !! Length !! Description
! Field Name             !! Type   !!Offset!!Length!! Description
|-
|-
| mime || integer || 0 || 2 || mime type number - points to the mime type list
| mimetype              || integer ||   0 ||   2 || MIME type number as defined in the MIME type list
|-
|-
| parameter len || || 2 || 1 || length of extra paramters (which are currently unused an hence this is always 0)
| parameter len         || byte    ||   2 ||   1 || (not used) length of extra paramters
|-
|-
| namespace || char || 3 || 1 ||
| namespace             || char   ||   3 ||   1 || defines to which namespace this directory entry belongs
|-
|-
| version || integer || 4 || 4 ||
| revision              || integer ||   4 ||   4 || (optional) identifies a revision of the contents of this directory entry, needed to identify updates or revisions in the original history
|-
|-
| cluster number || integer || 8 || 4 ||
| cluster number         || integer ||   8 ||   4 || cluster number in which the data of this directory entry is stored
|-
|-
| blob number || integer || 12 || 4 ||
| blob number           || integer ||   12 ||   4 || blob number inside the compressed cluster where the contents are stored
|-
|-
| url || string || 16 || zero terminated || string with the url
| url                   || string ||   16 ||zero terminated|| string with the URL as refered in the URL pointer list
|-
|-
| title || string || || zero terminated || string with title or empty; in case it is empty, the url is used as title
| title                 || string || n/a ||zero terminated|| string with an title as refered in the Title pointer list or empty; in case it is empty, the URL is used as title
|-
| parameter || data || || see extra len || extra parameters
|-
|-
| parameter              || data    ||      ||see parameter len|| (not used) extra parameters
|}
|}


=== redirect entry ===
=== Redirect Entry ===
 
{|{{Prettytable}}
{|{{Prettytable}}
! Field Name !! Type !! Offset !! Length !! Description
! Field Name             !! Type   !!Offset!!Length!! Description
|-
| mime || integer || 0 || 2 || 0xffff for redirect
|-
|-
| parameter len || || 2 || 1 || length of extra paramters (which are currently unused an hence this is always 0)
| mimetype              || integer ||   0 ||   2 || 0xffff for redirect
|-
|-
| namespace || char || 3 || 1 ||
| parameter len          || byte    ||   2 ||   1 || (not used) length of extra paramters
|-
|-
| version || integer || 4 || 4 ||
| namespace              || char    ||   3 ||   1 || defines to which namespace this directory entry belongs
|-
|-
| redirect index || integer || 8 || 4 ||
| revision              || integer ||   4 ||   4 || (optional) identifies a revision of the contents of this directory entry, needed to identify updates or revisions in the original history
|-
|-
| url || string || 12 || zero terminated || string with the url
| redirect index        || integer ||   8 ||   4 || pointer to the directory entry of the redirect target
|-
|-
| title || string || || zero terminated || string with title or empty; in case it is empty, the url is used as title
| url                    || string ||   16 ||zero terminated|| string with the URL as refered in the URL pointer list
|-
|-
| parameter || data || || see extra len || extra parameters
| title                  || string  || n/a ||zero terminated|| string with an title as refered in the Title pointer list or empty; in case it is empty, the URL is used as title
|-
|-
| parameter              || data    ||      ||see parameter len|| (not used) extra parameters
|}
|}


Navigation menu