local tar = require "tar"
The tar
module can read and write tar archives. Only files and
directories are supported.
tar.tar(files, [xform])
returns a string that can be saved as a tar file.
files
is a list of file names orstat
like structures.stat
structures shall contain these fields:
name
: file namemtime
: last modification timecontent
: file content (the default value is the actual content of the filename
).Note: these structures can also be produced by
fs.stat
.
xform
is an optional function used to transform filenames in the archive.
tar.untar(archive, [xform])
returns a list of files (
stat
like structures with acontent
field).
xform
is an optional function used to transform filenames in the archive.
tar.chain(xforms)
returns a filename transformation function that applies all functions from
funcs
.
tar.strip(x)
returns a transformation function that removes part of the beginning of a filename. If
x
is a number, the function removesx
path components in the filename. Ifx
is a string, the function removesx
at the beginning of the filename.
tar.add(p)
returns a transformation function that adds
p
at the beginning of a filename.
tar.xform(x, y)
returns a transformation function that chains
tar.strip(x)
andtar.add(y)
.