Pike v8.0 release 1738

Method Filesystem.Tar._Tar()->extract()


Method extract

void extract(string src_dir, string dest_dir, void|string|function(string, Filesystem.Stat:int|string) filter, void|int flags)

Description

Extracts files from the tar file in sequential order.

Parameter src_dir

The root directory in the tar file system to extract.

Parameter dest_dir

The root directory in the real file system that will receive the contents of src_dir. It is assumed to exist and be writable.

Parameter filter

A filter for the entries under src_dir to extract. If it's a string then it's taken as a glob pattern which is matched against the path below src_dir. That path always begins with a /. For directory entries it ends with a / too, otherwise not.

If it's a function then it's called for every entry under src_dir, and those where it returns nonzero are extracted. The function receives the path part below src_dir as the first argument, which is the same as in the glob case above, and the stat struct as the second. If the function returns a string, it's taken as the path below dest_dir where this entry should be extracted (any missing directories are created automatically).

If filter is zero, then everything below src_dir is extracted.

Parameter flags

Bitfield of flags to control the extraction:

Filesystem.Tar.EXTRACT_SKIP_MODE

Don't set any permission bits from the tar records.

Filesystem.Tar.EXTRACT_SKIP_EXT_MODE

Don't set set-user-ID, set-group-ID, or sticky bits from the tar records.

Filesystem.Tar.EXTRACT_SKIP_MTIME

Don't set mtime from the tar records.

Filesystem.Tar.EXTRACT_CHOWN

Set owning user and group from the tar records.

Filesystem.Tar.EXTRACT_ERR_ON_UNKNOWN

Throw an error if an entry of an unsupported type is encountered. This is ignored otherwise.

Files and directories are supported on all platforms, and symlinks are supported whereever symlink exists. Other record types are currently not supported.

Throws

I/O errors are thrown.