Archive_Tar::addModify()

Archive_Tar::addModify() -- add files or directories

Synopsis

require_once 'Archive/Tar.php';

boolean addModify (mixed $filelist, string $add_dir [, string $remove_dir = ''])

Description

This methods add files and directories listed in filelist at the end of the existing archive.

If the archive does not exists it attempts to create it. If a file or directory is already in the archive it will only be added at the end of the archive. There is no update of the existing archived file or directory. However while extracting the archive, the last file will replace the first one. This results in a none optimization of the archive size. If a file or directory does not exists, it is ignored.

Parameter

Return value

boolean - Returns TRUE on success, FALSE on failure.

Throws

Table 38-1. Possible PEAR_Error values

Error codeError messageReasonSolution
NULL"Invalid file list"The argument for the function is not correctly formatted or build. Check for typing mistakes in the argument
NULL "Unable to open in write mode file name" The file permissions for an existing file do not allow writing or the file is locked. Check permissions and possible competive programs using the file.
NULL "Invalid file list" Archive is empty or corrupted  
NULL "File filename does not exist" A file you want to add to the archive does not exist. Check for typing mistakes in the function argument.
NULL "Directory dirname can not be read" A directory or a file in it you want to add to the archive does not exists or the permissions for reading the directory does not allow access. Check for typing mistakes in the function argument and permissions.
NULL "Unable to open file filenamein binary read mode" The file to add to the archive could not be read. Check for typing mistakes in the function argument and file permissions.

Note

This function can not be called statically.

Example

On Windows system, Windows path format can be used. However if the files are using a Windows path, the $remove_dir parameter must also be in Windows path format. The $add_dir parameter can be in Windows or Unix path format.