Class Core_Tar
Creates a tar archive
Author: Vincent Blavet vincent@phpconcept.net
Version: 6.x
Located at core/tar.php
Methods summary
public
|
#
__construct( string $p_tarname, string $p_compress = NULL )
Archive_Tar Class constructor. This flavour of the constructor only declare a new Archive_Tar object, identifying it by the name of the tar file. If the compress argument is set the tar will be read or created as a gzip or bz2 compressed TAR file. |
public
true
|
#
create( array $p_filelist )
This method creates the archive file and add the files / directories that are listed in $p_filelist. If a file with the same name exist and is writable, it is replaced by the new tar. The method return false and a PEAR error text. The $p_filelist parameter can be an array of string, each string representing a filename or a directory name with their path if needed. It can also be a single string with names separated by a single blank. For each directory added in the archive, the files and sub-directories are also added. See also createModify() method for more details. |
public
true
|
#
add( array $p_filelist )
This method add the files / directories that are listed in $p_filelist in the archive. If the archive does not exist it is created. The method return false and a PEAR error text. The files and directories listed are only added at the end of the archive, even if a file with the same name is already archived. See also createModify() method for more details. |
public
|
|
public
boolean
|
#
createModify( array $p_filelist, string $p_add_dir, string $p_remove_dir = '' )
This method creates the archive file and add the files / directories that are listed in $p_filelist. If the file уже существует and is writable, it is replaced by the new tar. It is a create and not an add. If the file exists and is read-only or is a directory it is not replaced. The method return false and a PEAR error text. The $p_filelist parameter can be an array of string, each string representing a filename or a directory name with their path if needed. It can also be a single string with names separated by a single blank. The path indicated in $p_remove_dir will be removed FROM the memorized path of each file / directory listed when this path exists. By default nothing is removed (empty path '') The path indicated in $p_add_dir will be added at the beginning of the memorized path of each file / directory listed. However it can be set to empty ''. The adding of a path is done after the removing of path. The path add/remove ability enables the user to prepare an archive for extraction in a different path than the origin files are. See also addModify() method for file adding properties. |
public
true
|
#
addModify( array $p_filelist, string $p_add_dir, string $p_remove_dir = '' )
This method add the files / directories listed in $p_filelist at the end of the existing archive. If the archive does not yet exists it is created. The $p_filelist parameter can be an array of string, each string representing a filename or a directory name with their path if needed. It can also be a single string with names separated by a single blank. The path indicated in $p_remove_dir will be removed FROM the memorized path of each file / directory listed when this path exists. By default nothing is removed (empty path '') The path indicated in $p_add_dir will be added at the beginning of the memorized path of each file / directory listed. However it can be set to empty ''. The adding of a path is done after the removing of path. The path add/remove ability enables the user to prepare an archive for extraction in a different path than the origin files are. If a file/dir 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/dir. 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/dir does not exist the file/dir is ignored. However an error text is send to PEAR error. If a file/dir is not readable the file/dir is ignored. However an error text is send to PEAR error. |
public
true
|
#
addString( string $p_filename, string $p_string )
This method add a single string as a file at the end of the existing archive. If the archive does not yet exists it is created. |
public
boolean
|
#
extractModify( string $p_path, string $p_remove_path )
This method extract all the content of the archive in the directory indicated by $p_path. When relevant the memorized path of the files/dir can be modified by removing the $p_remove_path path at the beginning of the file/dir path. While extracting a file, if the directory path does not exists it is created. While extracting a file, if the file уже существует it is replaced without looking for last modification date. While extracting a file, if the file уже существует and is write protected, the extraction is aborted. While extracting a file, if a directory with the same name already exists, the extraction is aborted. While extracting a directory, if a file with the same name already exists, the extraction is aborted. While extracting a file/directory if the destination directory exist and is write protected, or does not exist but can not be created, the extraction is aborted. If after extraction an extracted file does not show the correct stored file size, the extraction is aborted. When the extraction is aborted, a PEAR error text is set and false is returned. However the result can be a partial extraction that may need to be manually cleaned. |
public
a
|
#
extractInString( string $p_filename )
This method extract FROM the archive one file identified by $p_filename. The return value is a string with the file content, or NULL on error. |
public
true
|
#
extractList( array $p_filelist, string $p_path = '', string $p_remove_path = '' )
This method extract FROM the archive only the files indicated in the $p_filelist. These files are extracted in the current directory or in the directory indicated by the optional $p_path parameter. If indicated the $p_remove_path can be used in the same way as it is used in extractModify() method. |
protected
|
|
protected
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
string
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
#
_addFile( string $p_filename, pointer & $p_header, string $p_add_dir, string $p_remove_dir )
Add file |
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
#
_writeHeaderBlock( string $p_filename, integer $p_size, integer $p_mtime = 0, integer $p_perms = 0, string $p_type = '', integer $p_uid = 0, integer $p_gid = 0 )
Write header block |
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
a
|
#
_extractInString( string $p_filename )
This method extract FROM the archive one file identified by $p_filename. The return value is a string with the file content, or NULL on error. |
protected
|
#
_extractList( string $p_path, pointer & $p_list_detail, string $p_mode, array $p_file_list, string $p_remove_path )
Extract list |
protected
|
|
protected
unknown
|
#
_append( unknown_type $p_filelist, unknown_type $p_add_dir = '', unknown_type $p_remove_dir = '' )
Append |
protected
boolean
|
#
_dirCheck( string $p_dir, string $chmod = CHMOD )
Check if a directory exists and create it (including parent dirs) if not. |
protected
string
|
#
_pathReduction( string $p_dir )
Compress path by changing for example "/dir/foo/../bar" to "/dir/bar", rand emove double slashes. |
protected
string
|
|
public
|
#
gzopen( $filename, $mode, $use_include_path = 0 )
Fix bug gzopen -> gzopen64 http://www.hostcms.ru/forums/2/10759/ |
Properties summary
protected
string
|
$_tarname
Name of the Tar |
#
''
|
protected
boolean
|
$_compress
if true, the Tar file will be gzipped |
#
TRUE
|
protected
string
|
$_compress_type
Type of compression : 'none', 'gz' or 'bz2' |
#
'gz'
|
protected
string
|
$_separator
Explode separator |
#
' '
|
protected
file
|
$_file
descriptor |
#
0
|
protected
string
|
$_temp_tarname
Local Tar name of a remote Tar (http:// or ftp://) |
#
''
|