When handler is not specified, the entries of the TAR file are printed.
> readTar(zcat("webapps.tar.gz"))
drwxr-xr-x tomatsu/tomatsu 0 2003-07-25 10:44:38 webapps/
drwxr-xr-x tomatsu/tomatsu 0 2003-08-11 18:08:19 webapps/wiki/
drwxrwxrwx tomatsu/tomatsu 0 2003-08-11 19:33:03 webapps/wiki/Codemgr_wsdata/
-rw-rw-rw- tomatsu/tomatsu 1789 2003-07-23 17:58:56 webapps/wiki/Codemgr_wsdata/access_control
....
When handler is specified, the function is called with two arguments; a TarEntry object that represents each entry of the TAR file, and InputStream object from which the content of the entry is read.
TarEntry has the following properties.
Type Property Name Remark String name java.util.Date modTime boolean directory Read-Only long size Need to read input until EOF is found, or just call input.closeEntry(), before accessing this property
For instance, the following function writes the content of a file in a TAR file to the specified OutputStream.
function extract(tarfile, name, out){
readTar(tarfile, function (e, in) if (e.name == name) read(in, out))
}
writeTar() creates a TAR file from the specified files or directories.
writeTar("/tmp/hogehoge.tar", "/home")