Archive_Tar
[ class tree: Archive_Tar ] [ index: Archive_Tar ] [ all elements ]

Class: Archive_Tar

Source Location: /Archive_Tar-1.4.9/Archive/Tar.php

Class Overview

PEAR
   |
   --Archive_Tar

Creates a (compressed) Tar archive


Author(s):

Version:

  • $Revision$

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 80]
Creates a (compressed) Tar archive


[ Top ]


Class Variables

$buffer_length =

[line 132]

  • Var: Length of the read buffer in bytes
  • Access: protected

Type:   int


[ Top ]

$error_object =  null

[line 120]

  • Var: object
  • Access: public

Type:   object PEAR_Error


[ Top ]

$_compress =  false

[line 90]

  • Var: if true, the Tar file will be gzipped
  • Access: public

Type:   boolean


[ Top ]

$_compress_type =  'none'

[line 95]

  • Var: Type of compression : 'none', 'gz', 'bz2' or 'lzma2'
  • Access: public

Type:   string


[ Top ]

$_file =  0

[line 105]

  • Var: descriptor
  • Access: public

Type:   file


[ Top ]

$_fmt =  ''

[line 127]

Format for data extraction
  • Access: public

Type:   string


[ Top ]

$_ignore_regexp =  ''

[line 115]

  • Var: regular expression for ignoring files or directories
  • Access: public

Type:   string


[ Top ]

$_separator =  ' '

[line 100]

  • Var: Explode separator
  • Access: public

Type:   string


[ Top ]

$_tarname =  ''

[line 85]

  • Var: Name of the Tar
  • Access: public

Type:   string


[ Top ]

$_temp_tarname =  ''

[line 110]

  • Var: Local Tar name of a remote Tar (http:// or ftp://)
  • Access: public

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 150]

bool __construct( string $p_tarname, [string $p_compress = null], [int $buffer_length = 512])

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.

  • Access: public

Parameters:

string   $p_tarname   —  The name of the tar archive to create
string   $p_compress   —  can be null, 'gz', 'bz2' or 'lzma2'. This parameter indicates if gzip, bz2 or lzma2 compression is required. For compatibility reason the boolean value 'true' means 'gz'.
int   $buffer_length   —  Length of the read buffer in bytes

[ Top ]

__destruct (Destructor)   [line 256]

void __destruct( )

  • Access: public

[ Top ]

add   [line 307]

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.


Parameters:

array   $p_filelist   —  An array of filenames and directory names, or a single string with names separated by a single blank space.

[ Top ]

addModify   [line 448]

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.

  • Return: on success, false on error.
  • Access: public

Parameters:

array   $p_filelist   —  An array of filenames and directory names, or a single string with names separated by a single blank space.
string   $p_add_dir   —  A string which contains a path to be added to the memorized path of each element in the list.
string   $p_remove_dir   —  A string which contains a path to be removed from the memorized path of each element in the list, when relevant.

[ Top ]

addString   [line 501]

true addString( string $p_filename, string $p_string, [bool|int $p_datetime = false], [array $p_params = array()])

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.
  • Return: on success, false on error.
  • Access: public

Parameters:

string   $p_filename   —  A string which contains the full filename path that will be associated with the string.
string   $p_string   —  The content of the file added in the archive.
bool|int   $p_datetime   —  A custom date/time (unix timestamp) for the file (optional).
array   $p_params   —  An array of optional params: stamp => the datetime (replaces datetime above if it exists) mode => the permissions on the file (600 by default) type => is this a link? See the tar specification for details. (default = regular file) uid => the user ID of the file (default = 0 = root) gid => the group ID of the file (default = 0 = root)

[ Top ]

create   [line 286]

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.


Parameters:

array   $p_filelist   —  An array of filenames and directory names, or a single string with names separated by a single blank space.

[ Top ]

createModify   [line 376]

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 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.


Parameters:

array   $p_filelist   —  An array of filenames and directory names, or a single string with names separated by a single blank space.
string   $p_add_dir   —  A string which contains a path to be added to the memorized path of each element in the list.
string   $p_remove_dir   —  A string which contains a path to be removed from the memorized path of each element in the list, when relevant.

[ Top ]

extract   [line 318]

bool extract( [string $p_path = ''], [bool $p_preserve = false], [bool $p_symlinks = true])

  • Access: public

Parameters:

string   $p_path   — 
bool   $p_preserve   — 
bool   $p_symlinks   — 

[ Top ]

extractInString   [line 595]

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.

  • Return: string with the file content or NULL.
  • Access: public

Parameters:

string   $p_filename   —  The path of the file to extract in a string.

[ Top ]

extractList   [line 628]

true extractList( array $p_filelist, [string $p_path = ''], [string $p_remove_path = ''], [boolean $p_preserve = false], [boolean $p_symlinks = 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.

If indicated the $p_remove_path can be used in the same way as it is used in extractModify() method.


Parameters:

array   $p_filelist   —  An array of filenames and directory names, or a single string with names separated by a single blank space.
string   $p_path   —  The path of the directory where the files/dir need to by extracted.
string   $p_remove_path   —  Part of the memorized path that can be removed if present at the beginning of the file/dir path.
boolean   $p_preserve   —  Preserve user/group ownership of files
boolean   $p_symlinks   —  Allow symlinks.

[ Top ]

extractModify   [line 566]

boolean extractModify( string $p_path, string $p_remove_path, [boolean $p_preserve = false], [boolean $p_symlinks = true])

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 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.


Parameters:

string   $p_path   —  The path of the directory where the files/dir need to by extracted.
string   $p_remove_path   —  Part of the memorized path that can be removed if present at the beginning of the file/dir path.
boolean   $p_preserve   —  Preserve user/group ownership of files
boolean   $p_symlinks   —  Allow symlinks.

[ Top ]

listContent   [line 326]

array|int listContent( )

  • Access: public

[ Top ]

setAttribute   [line 665]

true setAttribute( )

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, ',');
  • Return: on success, false on error.
  • Access: public

[ Top ]

setIgnoreList   [line 732]

void setIgnoreList( array $list)

This method sets the regular expression for ignoring all files and directories matching the filenames in the array list at import, for example: $arch->setIgnoreList(array('CVS', '.svn', 'bin/tool'));
  • Access: public

Parameters:

array   $list   —  a list of file or directory names to ignore

[ Top ]

setIgnoreRegexp   [line 718]

void setIgnoreRegexp( string $regexp)

This method sets the regular expression for ignoring files and directories at import, for example: $arch->setIgnoreRegexp("#CVS|\.svn#");
  • Access: public

Parameters:

string   $regexp   —  regular expression defining which files or directories to ignore

[ Top ]

_addFile   [line 1217]

bool _addFile( string $p_filename, &$p_header, string $p_add_dir, string $p_remove_dir, [null $v_stored_filename = null], mixed $p_header)

  • Access: public

Parameters:

string   $p_filename   — 
mixed   $p_header   — 
string   $p_add_dir   — 
string   $p_remove_dir   — 
null   $v_stored_filename   — 
   &$p_header   — 

[ Top ]

_addList   [line 1131]

bool _addList( array $p_list, string $p_add_dir, string $p_remove_dir)

  • Access: public

Parameters:

array   $p_list   — 
string   $p_add_dir   — 
string   $p_remove_dir   — 

[ Top ]

_addString   [line 1303]

bool _addString( string $p_filename, string $p_string, [bool $p_datetime = false], [array $p_params = array()])

  • Access: public

Parameters:

string   $p_filename   — 
string   $p_string   — 
bool   $p_datetime   — 
array   $p_params   — 

[ Top ]

_append   [line 2369]

bool _append( $p_filelist $p_filelist, [string $p_add_dir = ''], [string $p_remove_dir = ''])

  • Access: public

Parameters:

string   $p_add_dir   — 
string   $p_remove_dir   — 
$p_filelist   $p_filelist   — 

[ Top ]

_cleanFile   [line 967]

bool _cleanFile( )

  • Access: public

[ Top ]

_close   [line 926]

bool _close( )

  • Access: public

[ Top ]

_dirCheck   [line 2392]

bool _dirCheck( string $p_dir)

Check if a directory exists and create it (including parent dirs) if not.
  • Return: true if the directory exists or was created
  • Access: public

Parameters:

string   $p_dir   —  directory to check

[ Top ]

_error   [line 742]

void _error( string $p_message)

  • Access: public

Parameters:

string   $p_message   — 

[ Top ]

_extractList   [line 1928]

bool _extractList( string $p_path, &$p_list_detail, string $p_mode, string $p_file_list, string $p_remove_path, [bool $p_preserve = false], [bool $p_symlinks = true], string $p_list_detail)

  • Access: public

Parameters:

string   $p_path   — 
string   $p_list_detail   — 
string   $p_mode   — 
string   $p_file_list   — 
string   $p_remove_path   — 
bool   $p_preserve   — 
bool   $p_symlinks   — 
   &$p_list_detail   — 

[ Top ]

_isArchive   [line 759]

bool _isArchive( [string $p_filename = null])

  • Access: public

Parameters:

string   $p_filename   — 

[ Top ]

_jumpBlock   [line 1075]

bool _jumpBlock( [null $p_len = null])

  • Access: public

Parameters:

null   $p_len   — 

[ Top ]

_openAppend   [line 2229]

bool _openAppend( )

  • Access: public

[ Top ]

_openRead   [line 809]

bool _openRead( )

  • Access: public

[ Top ]

_openReadWrite   [line 880]

bool _openReadWrite( )

  • Access: public

[ Top ]

_openWrite   [line 771]

bool _openWrite( )

  • Access: public

[ Top ]

_readBlock   [line 1043]

null|string _readBlock( )

  • Access: public

[ Top ]

_readHeader   [line 1668]

bool _readHeader( mixed $v_binary_data, &$v_header, mixed $v_header)

  • Access: public

Parameters:

mixed   $v_binary_data   — 
mixed   $v_header   — 
   &$v_header   — 

[ Top ]

_readLongHeader   [line 1813]

bool _readLongHeader( $v_header &$v_header)

  • Access: public

Parameters:

$v_header   &$v_header   — 

[ Top ]

_translateWinPath   [line 2471]

string _translateWinPath( $p_path $p_path, [bool $p_remove_disk_letter = true])

  • Access: public

Parameters:

bool   $p_remove_disk_letter   — 
$p_path   $p_path   — 

[ Top ]

_warning   [line 750]

void _warning( string $p_message)

  • Access: public

Parameters:

string   $p_message   — 

[ Top ]

_writeBlock   [line 990]

bool _writeBlock( mixed $p_binary_data, [integer $p_len = null])

  • Access: public

Parameters:

mixed   $p_binary_data   — 
integer   $p_len   — 

[ Top ]

_writeFooter   [line 1115]

bool _writeFooter( )

  • Access: public

[ Top ]

_writeHeader   [line 1355]

bool _writeHeader( string $p_filename, string $p_stored_filename)

  • Access: public

Parameters:

string   $p_filename   — 
string   $p_stored_filename   — 

[ Top ]

_writeHeaderBlock   [line 1478]

bool _writeHeaderBlock( string $p_filename, int $p_size, [int $p_mtime = 0], [int $p_perms = 0], [string $p_type = ''], [int $p_uid = 0], [int $p_gid = 0])

  • Access: public

Parameters:

string   $p_filename   — 
int   $p_size   — 
int   $p_mtime   — 
int   $p_perms   — 
string   $p_type   — 
int   $p_uid   — 
int   $p_gid   — 

[ Top ]

_writeLongHeader   [line 1587]

bool _writeLongHeader( string $p_filename, [ $is_link = false])

  • Access: public

Parameters:

string   $p_filename   — 
   $is_link   — 

[ Top ]


Documentation generated on Wed, 04 Dec 2019 07:14:06 -0500 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.