Difference between revisions of "ZIM file format"

Jump to navigation Jump to search
1,491 bytes removed ,  11:49, 19 April 2013
m
Reverted edits by Ipodsoft (talk) to last revision by Kelson
m (Reverted edits by Ipodsoft (talk) to last revision by Kelson)
Line 2: Line 2:
The '''ZIM file format''' is based on the old and deprecated [[Zeno File Format]].See also a walk through an example at [[ZIM File Example]].
The '''ZIM file format''' is based on the old and deprecated [[Zeno File Format]].See also a walk through an example at [[ZIM File Example]].
It starts with a header, which is described here:
It starts with a header, which is described here:
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Header ==
== Header ==
Line 11: Line 7:


Length in byte, all types are littlendian.
Length in byte, all types are littlendian.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 43: Line 35:
| checksumPos || integer || 72 || 8 || pointer to the md5checksum of this file without the checksum itself. This points always 16 bytes before the end of the file.
| checksumPos || integer || 72 || 8 || pointer to the md5checksum of this file without the checksum itself. This points always 16 bytes before the end of the file.
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== MIME Type List (mimeListPos) ==
== MIME Type List (mimeListPos) ==
Line 52: Line 40:


The MIME types in this list are zero terminated strings. An empty string marks the end of the MIME type list.
The MIME types in this list are zero terminated strings. An empty string marks the end of the MIME type list.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 68: Line 52:
| <last entry / end> || string || n/a ||zero terminated|| empty string - end of MIME type list         
| <last entry / end> || string || n/a ||zero terminated|| empty string - end of MIME type list         
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== URL Pointer List (urlPtrPos) ==
== URL Pointer List (urlPtrPos) ==
Line 79: Line 59:


Since directory entries have variable sizes this is needed for random access.
Since directory entries have variable sizes this is needed for random access.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 97: Line 73:


Zimlib caches directory entries and references the cached entries via the URL pointers.
Zimlib caches directory entries and references the cached entries via the URL pointers.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Title Pointer List (titlePtrPos) ==
== Title Pointer List (titlePtrPos) ==
Line 106: Line 78:
in the URL pointer list. Note that the title pointers are only 4 bytes. They are not offsets in the file but article numbers.
in the URL pointer list. Note that the title pointers are only 4 bytes. They are not offsets in the file but article numbers.
To get the offset of an article from the title pointer list, you have to look it up in the URL pointer list.
To get the offset of an article from the title pointer list, you have to look it up in the URL pointer list.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 126: Line 94:
* the pointer list is only half in size as 4 bytes are enough for each entry
* the pointer list is only half in size as 4 bytes are enough for each entry
* 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.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Directory Entries ==
== Directory Entries ==
Line 135: Line 99:


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.
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.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


=== Article Entry ===
=== Article Entry ===
Line 162: Line 122:
| parameter || data || ||see parameter len|| (not used) extra parameters                         
| parameter || data || ||see parameter len|| (not used) extra parameters                         
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


=== Redirect Entry ===
=== Redirect Entry ===
Line 187: Line 143:
| parameter || data || ||see parameter len|| (not used) extra parameters                         
| parameter || data || ||see parameter len|| (not used) extra parameters                         
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Cluster Pointer List (clusterPtrPos) ==
== Cluster Pointer List (clusterPtrPos) ==
Line 206: Line 158:
| ... || integer || ... || 8 || ...                           
| ... || integer || ... || 8 || ...                           
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Clusters ==
== Clusters ==
Line 217: Line 165:


To find the data of a specific directory entry within a cluster the uncompressed cluster has a list of pointers to blobs within the uncompressed cluster after the first byte.
To find the data of a specific directory entry within a cluster the uncompressed cluster has a list of pointers to blobs within the uncompressed cluster after the first byte.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 247: Line 191:


The offset addresses uncompressed data. The last pointer points to the end of the data area. So there is always one more offset than blobs. Since the first offset points to the start of the first data, the number of offsets can be determined by dividing this offset by 4. The size of one blob is calculated by the difference of two consecutive offsets.
The offset addresses uncompressed data. The last pointer points to the end of the data area. So there is always one more offset than blobs. Since the first offset points to the start of the first data, the number of offsets can be determined by dividing this offset by 4. The size of one blob is calculated by the difference of two consecutive offsets.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Namespaces ==
== Namespaces ==
Line 256: Line 196:


They can be distinguished by prepending the article namespace before the article name in the URL path, eg. ''http://localhost/A/Articlename''.
They can be distinguished by prepending the article namespace before the article name in the URL path, eg. ''http://localhost/A/Articlename''.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 284: Line 220:
| X || fulltext index - see [[ZIM Index Format]]         
| X || fulltext index - see [[ZIM Index Format]]         
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== URLs ==
== URLs ==
Line 296: Line 228:


The URLs in the UrlPointerlist are not encoded. Some readers process the requests that already do the decoding internally whereas most readers will handle the URLs directly. In this case you have to do the decoding before you pass the parameter to zimlib, but zimlib already provides a method to do so.
The URLs in the UrlPointerlist are not encoded. Some readers process the requests that already do the decoding internally whereas most readers will handle the URLs directly. In this case you have to do the decoding before you pass the parameter to zimlib, but zimlib already provides a method to do so.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


=== Local Anchors ===
=== Local Anchors ===
Line 313: Line 241:


Should you render the article contents by yourself you have to consider this and take care of it before you hand requests to zimlib.
Should you render the article contents by yourself you have to consider this and take care of it before you hand requests to zimlib.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Encodings ==
== Encodings ==
Line 323: Line 247:


Old Zeno files used a mixture of Latin1 and UTF-8 so there is still some "auto detection" code left in the ''zimlib'', a workaround for this bug. This will be removed in future versions. Zeno files are not supported anymore.
Old Zeno files used a mixture of Latin1 and UTF-8 so there is still some "auto detection" code left in the ''zimlib'', a workaround for this bug. This will be removed in future versions. Zeno files are not supported anymore.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


=== Integer Encoding ===
=== Integer Encoding ===
Line 334: Line 254:


Old Zeno files used the QUnicode library instead. By switching to UTF-8 the new format is more standard-adherent and easier to understand.
Old Zeno files used the QUnicode library instead. By switching to UTF-8 the new format is more standard-adherent and easier to understand.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== See also ==
== See also ==

Navigation menu