User Tools

Site Tools


uphp:functions:untar

untar

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Expand a TAR file into the current folder, optionally verbose

Description

int untar ( string $filename [, int $verbosity ] )

This function will attempt to unpack a TAR archive1) into the current working folder, which is the folder that the script was started in or as was set by chdir(). In addition, it will send the filenames that are unpacked to the current output stream such as a web page or terminal, and if the optional verbose parameter is used it will also display the number of bytes and blocks for each file.

Parameters

$filename: If a path is omitted, the current directory will be used to search for the file to unpack (which is also where the unpacked files will be placed). If a path is also specified it should begin with / (relative to the root).

$verbosity: Optional

  • 0 - Not verbose (the default if not specified)
  • 1 - Verbose: also display the number of bytes and blocks for each unpacked file. (Any non-zero “true” value will work.)

Return Values

Integer: 1 if successful, or 0 if the attempt to expand the TAR file failed

See Also

tar_put() - Add a file to an open file in TAR format

tar_finish() - Add the ending header to a TAR file

chdir() - Change the current directory

1)
The TAR format is used to collect many files into one archive file, often referred to as a tarball, for distribution or backup purposes. The name for the TAR utility was derived from Tape ARchive, as it was originally developed to write data to sequential I/O devices with no file system of their own. In addition to the contents of the files the TAR archive can contain information on the file system parameters, such as name, time stamps, ownership, file access permissions and directory organization.
uphp/functions/untar.txt · Last modified: 2021/09/13 05:57 (external edit)