tar.load(path, noser, rawdata)
Returns a table with the data in the archive file.
- path: The path to the file to read, or the file data if rawdata is set
- noser: Set to true to return a list of tar entries (skip unserialization)
- rawdata: Set to true to read raw file data in path instead of from a file
- Returns: A hierarchical table with the contents of the file tree, or a list of file entries if noser is set
tar.unserialize(data)
Unserializes a list of tar objects into a file tree.
- data: The list of file entries to unserialize
- Returns: A hierarchical table of files
tar.extract(data, path)
Writes a hierarchy to a directory.
- data: The data to write (from load())
- path: The directory to write files inside
tar.read(base, p)
Reads a single file into a tar entry.
- base: The base directory to read from
- p: The path to the file in the tarball
- Returns: A tar entry (see below)
tar.pack(base, path)
Reads a directory tree into a hierarchical table.
- base: The base path to start reading from
- path: (optional) The name of the directory as it will be in the tarball
- Returns: A table with the contents of the directory
tar.serialize(data)
Serializes a hierarchy into a list of tar objects.
- data: The file hierarchy to serialize
- Returns: A list of tar objects
tar.save(data, path, noser)
Saves a hierarchy into a TAR file.
- data: The file tree to save
- path: The TAR file to save to, or nil to return the raw data
- noser: Set this to save a non-hierarchical table (a list of tar objects) instead of hierarchy
A file hierarchy might be in the form of:
{
usr = {
bin = {
hello = <tar object>,
},
share = {
hello = {
["hello.txt"] = <tar object>,
},
},
},
etc = {
["hello.conf"] = <tar object>,
},
}
A tar object/tar entry/file entry/file object has these properties:
- name: The full path of the file in the TAR file
- mode: The UNIX file permissions of the file (only useful with CCKernel2)
- owner: The UID of the owner of the file (only useful with CCKernel2)
- group: The group of the file (not useful)
- timestamp: The last modified date of the file (set to time of TAR creation)
- type: The file type (0 = file, 5 = directory, others not useful)
- link: The path the file links to if it's a link (not useful)
- ownerName: The short name of the owner of the file (only useful with CCKernel2)
- groupName: The name of the group of the file (not useful)
- deviceNumber: Two-entry table with the device major and minor number (unknown)
- data: The contents of the file