class Tar implements ArchiverInterface (View source)

Defines an archiver implementation for .tar files.

Properties

protected ArchiveTar $tar

The underlying ArchiveTar instance that does the heavy lifting.

Methods

__construct(string $file_path)

Constructs a Tar object.

$this
add(string $file_path)

Adds the specified file or directory to the archive.

$this
remove($file_path)

Removes the specified file from the archive.

$this
extract(string $path, array $files = [])

Extracts multiple files in the archive to the specified path.

array
listContents()

Lists all files in the archive.

Archive_Tar
getArchive()

Retrieves the tar engine itself.

Details

__construct(string $file_path)

Constructs a Tar object.

Parameters

string $file_path

The full system path of the archive to manipulate. Only local files are supported. If the file does not yet exist, it will be created if appropriate.

Exceptions

ArchiverException

$this add(string $file_path)

Adds the specified file or directory to the archive.

Parameters

string $file_path

The full system path of the file or directory to add. Only local files and directories are supported.

Return Value

$this

The called object.

$this remove($file_path)

Removes the specified file from the archive.

Parameters

$file_path

Return Value

$this

The called object.

$this extract(string $path, array $files = [])

Extracts multiple files in the archive to the specified path.

Parameters

string $path

A full system path of the directory to which to extract files.

array $files

Optionally specify a list of files to be extracted. Files are relative to the root of the archive. If not specified, all files in the archive will be extracted.

Return Value

$this

The called object.

array listContents()

Lists all files in the archive.

Return Value

array

An array of file names relative to the root of the archive.

Archive_Tar getArchive()

Retrieves the tar engine itself.

In some cases it may be necessary to directly access the underlying Archive_Tar object for implementation-specific logic. This is for advanced use only as it is not shared by other implementations of ArchiveInterface.

Return Value

Archive_Tar

The Archive_Tar object used by this object.