PHP Class Archive_Tar, JxLib

Inheritance: extends PEAR
Afficher le fichier Open project: JxLib/JxLib Class Usage Examples

Méthodes publiques

Свойство Type Description
$_compress if true, the Tar file will be gzipped
$_compress_type Type of compression : 'none', 'gz' or 'bz2'
$_file descriptor
$_separator Explode separator
$_tarname Name of the Tar
$_temp_tarname Local Tar name of a remote Tar (http:// or ftp://)

Méthodes publiques

Méthode Description
Archive_Tar ( 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.
_Archive_Tar ( ) {{{ destructor
_addFile ( $p_filename, &$p_header, $p_add_dir, $p_remove_dir ) {{{ _addFile()
_addList ( $p_list, $p_add_dir, $p_remove_dir ) {{{ _addList()
_addString ( $p_filename, $p_string ) {{{ _addString()
_append ( $p_filelist, $p_add_dir = '', $p_remove_dir = '' ) {{{ _append()
_cleanFile ( ) {{{ _cleanFile()
_close ( ) {{{ _close()
_dirCheck ( string $p_dir ) : boolean Check if a directory exists and create it (including parent dirs) if not.
_error ( $p_message ) {{{ _error()
_extractInString ( string $p_filename ) : a This method extract from the archive one file identified by $p_filename.
_extractList ( $p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path ) {{{ _extractList()
_isArchive ( $p_filename = NULL ) {{{ _isArchive()
_jumpBlock ( $p_len = null ) {{{ _jumpBlock()
_maliciousFilename ( string $file ) : boolean Detect and report a malicious file name
_openAppend ( ) {{{ _openAppend()
_openRead ( ) {{{ _openRead()
_openReadWrite ( ) {{{ _openReadWrite()
_openWrite ( ) {{{ _openWrite()
_pathReduction ( string $p_dir ) : string Compress path by changing for example "/dir/foo/.
_readBlock ( ) {{{ _readBlock()
_readHeader ( $v_binary_data, &$v_header ) {{{ _readHeader()
_readLongHeader ( &$v_header ) {{{ _readLongHeader()
_translateWinPath ( $p_path, $p_remove_disk_letter = true ) {{{ _translateWinPath()
_warning ( $p_message ) {{{ _warning()
_writeBlock ( $p_binary_data, $p_len = null ) {{{ _writeBlock()
_writeFooter ( ) {{{ _writeFooter()
_writeHeader ( $p_filename, $p_stored_filename ) {{{ _writeHeader()
_writeHeaderBlock ( $p_filename, $p_size, $p_mtime, $p_perms, $p_type = '', $p_uid, $p_gid ) {{{ _writeHeaderBlock()
_writeLongHeader ( $p_filename ) {{{ _writeLongHeader()
add ( array $p_filelist ) : true This method add the files / directories that are listed in $p_filelist in the archive. If the archive does not exist it is created.
addModify ( array $p_filelist, string $p_add_dir, string $p_remove_dir = '' ) : true 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.
addString ( string $p_filename, string $p_string ) : true 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.
create ( array $p_filelist ) : true This method creates the archive file and add the files / directories that are listed in $p_filelist.
createModify ( array $p_filelist, string $p_add_dir, string $p_remove_dir = '' ) : boolean This method creates the archive file and add the files / directories that are listed in $p_filelist.
extract ( $p_path = '' ) {{{ extract()
extractInString ( string $p_filename ) : a This method extract from the archive one file identified by $p_filename.
extractList ( array $p_filelist, string $p_path = '', string $p_remove_path = '' ) : true 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.
extractModify ( string $p_path, string $p_remove_path ) : boolean 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.
listContent ( ) {{{ listContent()
setAttribute ( ) : true This method set specific attributes of the archive. It uses a variable list of parameters, in the format attribute code + attribute values : $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ',');

Method Details

Archive_Tar() public méthode

If the compress argument is set the tar will be read or created as a gzip or bz2 compressed TAR file.
public Archive_Tar ( string $p_tarname, string $p_compress = null )
$p_tarname string The name of the tar archive to create
$p_compress string can be null, 'gz' or 'bz2'. This parameter indicates if gzip or bz2 compression is required. For compatibility reason the boolean value 'true' means 'gz'.

_Archive_Tar() public méthode

{{{ destructor
public _Archive_Tar ( )

_addFile() public méthode

{{{ _addFile()
public _addFile ( $p_filename, &$p_header, $p_add_dir, $p_remove_dir )

_addList() public méthode

{{{ _addList()
public _addList ( $p_list, $p_add_dir, $p_remove_dir )

_addString() public méthode

{{{ _addString()
public _addString ( $p_filename, $p_string )

_append() public méthode

{{{ _append()
public _append ( $p_filelist, $p_add_dir = '', $p_remove_dir = '' )

_cleanFile() public méthode

{{{ _cleanFile()
public _cleanFile ( )

_close() public méthode

{{{ _close()
public _close ( )

_dirCheck() public méthode

Check if a directory exists and create it (including parent dirs) if not.
public _dirCheck ( string $p_dir ) : boolean
$p_dir string directory to check
Résultat boolean TRUE if the directory exists or was created

_error() public méthode

{{{ _error()
public _error ( $p_message )

_extractInString() public méthode

The return value is a string with the file content, or NULL on error.
public _extractInString ( string $p_filename ) : a
$p_filename string The path of the file to extract in a string.
Résultat a string with the file content or NULL.

_extractList() public méthode

{{{ _extractList()
public _extractList ( $p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path )

_isArchive() public méthode

{{{ _isArchive()
public _isArchive ( $p_filename = NULL )

_jumpBlock() public méthode

{{{ _jumpBlock()
public _jumpBlock ( $p_len = null )

_maliciousFilename() public méthode

Detect and report a malicious file name
public _maliciousFilename ( string $file ) : boolean
$file string
Résultat boolean

_openAppend() public méthode

{{{ _openAppend()
public _openAppend ( )

_openRead() public méthode

{{{ _openRead()
public _openRead ( )

_openReadWrite() public méthode

{{{ _openReadWrite()
public _openReadWrite ( )

_openWrite() public méthode

{{{ _openWrite()
public _openWrite ( )

_pathReduction() public méthode

./bar" to "/dir/bar", rand emove double slashes.
public _pathReduction ( string $p_dir ) : string
$p_dir string path to reduce
Résultat string reduced path

_readBlock() public méthode

{{{ _readBlock()
public _readBlock ( )

_readHeader() public méthode

{{{ _readHeader()
public _readHeader ( $v_binary_data, &$v_header )

_readLongHeader() public méthode

{{{ _readLongHeader()
public _readLongHeader ( &$v_header )

_translateWinPath() public méthode

{{{ _translateWinPath()
public _translateWinPath ( $p_path, $p_remove_disk_letter = true )

_warning() public méthode

{{{ _warning()
public _warning ( $p_message )

_writeBlock() public méthode

{{{ _writeBlock()
public _writeBlock ( $p_binary_data, $p_len = null )

_writeFooter() public méthode

{{{ _writeFooter()
public _writeFooter ( )

_writeHeader() public méthode

{{{ _writeHeader()
public _writeHeader ( $p_filename, $p_stored_filename )

_writeHeaderBlock() public méthode

{{{ _writeHeaderBlock()
public _writeHeaderBlock ( $p_filename, $p_size, $p_mtime, $p_perms, $p_type = '', $p_uid, $p_gid )

_writeLongHeader() public méthode

{{{ _writeLongHeader()
public _writeLongHeader ( $p_filename )

add() public méthode

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.
See also: createModify()
public add ( array $p_filelist ) : true
$p_filelist array An array of filenames and directory names, or a single string with names separated by a single blank space.
Résultat true on success, false on error.

addModify() public méthode

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 addModify ( array $p_filelist, string $p_add_dir, string $p_remove_dir = '' ) : true
$p_filelist array An array of filenames and directory names, or a single string with names separated by a single blank space.
$p_add_dir string A string which contains a path to be added to the memorized path of each element in the list.
$p_remove_dir string A string which contains a path to be removed from the memorized path of each element in the list, when relevant.
Résultat true on success, false on error.

addString() public méthode

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 addString ( string $p_filename, string $p_string ) : true
$p_filename string A string which contains the full filename path that will be associated with the string.
$p_string string The content of the file added in the archive.
Résultat true on success, false on error.

create() public méthode

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.
See also: createModify()
public create ( array $p_filelist ) : true
$p_filelist array An array of filenames and directory names, or a single string with names separated by a single blank space.
Résultat true on success, false on error.

createModify() public méthode

If the file already exists 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.
See also: addModify()
public createModify ( array $p_filelist, string $p_add_dir, string $p_remove_dir = '' ) : boolean
$p_filelist array An array of filenames and directory names, or a single string with names separated by a single blank space.
$p_add_dir string A string which contains a path to be added to the memorized path of each element in the list.
$p_remove_dir string A string which contains a path to be removed from the memorized path of each element in the list, when relevant.
Résultat boolean true on success, false on error.

extract() public méthode

{{{ extract()
public extract ( $p_path = '' )

extractInString() public méthode

The return value is a string with the file content, or NULL on error.
public extractInString ( string $p_filename ) : a
$p_filename string The path of the file to extract in a string.
Résultat a string with the file content or NULL.

extractList() public méthode

If indicated the $p_remove_path can be used in the same way as it is used in extractModify() method.
See also: extractModify()
public extractList ( array $p_filelist, string $p_path = '', string $p_remove_path = '' ) : true
$p_filelist array An array of filenames and directory names, or a single string with names separated by a single blank space.
$p_path string The path of the directory where the files/dir need to by extracted.
$p_remove_path string Part of the memorized path that can be removed if present at the beginning of the file/dir path.
Résultat true on success, false on error.

extractModify() public méthode

While extracting a file, if the directory path does not exists it is created. While extracting a file, if the file already exists it is replaced without looking for last modification date. While extracting a file, if the file already exists 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.
See also: extractList()
public extractModify ( string $p_path, string $p_remove_path ) : boolean
$p_path string The path of the directory where the files/dir need to by extracted.
$p_remove_path string Part of the memorized path that can be removed if present at the beginning of the file/dir path.
Résultat boolean true on success, false on error.

listContent() public méthode

{{{ listContent()
public listContent ( )

setAttribute() public méthode

This method set specific attributes of the archive. It uses a variable list of parameters, in the format attribute code + attribute values : $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ',');
public setAttribute ( ) : true
Résultat true on success, false on error.

Property Details

$_compress public_oe property

if true, the Tar file will be gzipped
public $_compress

$_compress_type public_oe property

Type of compression : 'none', 'gz' or 'bz2'
public $_compress_type

$_file public_oe property

descriptor
public $_file

$_separator public_oe property

Explode separator
public $_separator

$_tarname public_oe property

Name of the Tar
public $_tarname

$_temp_tarname public_oe property

Local Tar name of a remote Tar (http:// or ftp://)
public $_temp_tarname