Support Joomla!

Packages

Package: Archive

License

Content on this site is copyright © 2005 - 2008 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.

 Class Archive_Tar

Description

Creates a (compressed) Tar archive

  • copyright: 1997-2006 The PHP Group
  • version: $Revision: 47 $
  • author: Vincent Blavet <vincent@blavet.net>

Located in /pear/archive_tar/Archive_Tar.php (line 35)

Class PEAR   (Package PEAR)

Class Archive_Tar
Variable Summary
Variable boolean $_compress
Variable file $_file
Variable string $_separator
Variable string $_tarname
Method Summary
Constructor Archive_Tar Archive_Tar (string $p_tarname, [string $p_compress = null])
Method true add (array $p_filelist)
Method true addModify (array $p_filelist, string $p_add_dir, [string $p_remove_dir = ''])
Method true addString (string $p_filename, string $p_string)
Method true create (array $p_filelist)
Method boolean createModify (array $p_filelist, string $p_add_dir, [string $p_remove_dir = ''])
Method void extract ([ $p_path = ''])
Method a extractInString (string $p_filename)
Method true extractList (array $p_filelist, [string $p_path = ''], [string $p_remove_path = ''])
Method boolean extractModify (string $p_path, string $p_remove_path)
Method void listContent ()
Method true setAttribute (mixed $argv)
Method void _addFile ( $p_filename,  &$p_header,  $p_add_dir,  $p_remove_dir)
Method void _addList ( $p_list,  $p_add_dir,  $p_remove_dir)
Method void _addString ( $p_filename,  $p_string)
Method void _append ( $p_filelist, [ $p_add_dir = ''], [ $p_remove_dir = ''])
Method void _Archive_Tar ()
Method void _cleanFile ()
Method void _close ()
Method bool _dirCheck (string $p_dir)
Method void _error ( $p_message)
Method void _extractList ( $p_path,  &$p_list_detail,  $p_mode,  $p_file_list,  $p_remove_path)
Method void _jumpBlock ([ $p_len = null])
Method void _openAppend ()
Method void _openRead ()
Method void _openReadWrite ()
Method void _openWrite ()
Method void _readBlock ([ $p_len = null])
Method void _readHeader ( $v_binary_data,  &$v_header)
Method void _readLongHeader ( &$v_header)
Method void _translateWinPath ( $p_path, [ $p_remove_disk_letter = true])
Method void _warning ( $p_message)
Method void _writeBlock ( $p_binary_data, [ $p_len = null])
Method void _writeFooter ()
Method void _writeHeader ( $p_filename,  $p_stored_filename)
Method void _writeHeaderBlock ( $p_filename,  $p_size, [ $p_mtime = 0], [ $p_perms = 0], [ $p_type = ''], [ $p_uid = 0], [ $p_gid = 0])
Method void _writeLongHeader ( $p_filename)
Variables
boolean $_compress = false (line 45)
  • var: if true, the Tar file will be gzipped
string $_compress_type = 'none' (line 50)
  • var: Type of compression : 'none', 'gz' or 'bz2'
file $_file (line 60)
  • var: descriptor
string $_separator = ' ' (line 55)
  • var: Explode separator
string $_tarname = '' (line 40)
  • var: Name of the Tar
string $_temp_tarname = '' (line 65)
  • var: Local Tar name of a remote Tar (http:// or ftp://)
Methods
Constructor Archive_Tar (line 82)

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
Archive_Tar Archive_Tar (string $p_tarname, [string $p_compress = null])
  • string $p_tarname: The name of the tar archive to create
  • string $p_compress: 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'.
add (line 196)

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.

true add (array $p_filelist)
  • array $p_filelist: An array of filenames and directory names, or a single string with names separated by a single blank space.
addModify (line 329)

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
true addModify (array $p_filelist, string $p_add_dir, [string $p_remove_dir = ''])
  • 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.
addString (line 364)

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
true addString (string $p_filename, string $p_string)
  • 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.
create (line 175)

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.

true create (array $p_filelist)
  • array $p_filelist: An array of filenames and directory names, or a single string with names separated by a single blank space.
createModify (line 260)

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.

boolean createModify (array $p_filelist, string $p_add_dir, [string $p_remove_dir = ''])
  • 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.
extract (line 203)
void extract ([ $p_path = ''])
  • $p_path
extractInString (line 444)

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
a extractInString (string $p_filename)
  • string $p_filename: The path of the file to extract in a string.
extractList (line 474)

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.

true extractList (array $p_filelist, [string $p_path = ''], [string $p_remove_path = ''])
  • 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.
extractModify (line 422)

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.

boolean extractModify (string $p_path, string $p_remove_path)
  • 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.
listContent (line 210)
void listContent ()
setAttribute (line 506)

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
true setAttribute (mixed $argv)
  • mixed $argv: variable list of attributes and values
_addFile (line 855)
void _addFile ( $p_filename,  &$p_header,  $p_add_dir,  $p_remove_dir)
  • $p_filename
  • &$p_header
  • $p_add_dir
  • $p_remove_dir
_addList (line 792)
void _addList ( $p_list,  $p_add_dir,  $p_remove_dir)
  • $p_list
  • $p_add_dir
  • $p_remove_dir
_addString (line 917)
void _addString ( $p_filename,  $p_string)
  • $p_filename
  • $p_string
_append (line 1553)
void _append ( $p_filelist, [ $p_add_dir = ''], [ $p_remove_dir = ''])
  • $p_filelist
  • $p_add_dir
  • $p_remove_dir
_Archive_Tar (line 144)
void _Archive_Tar ()
_cleanFile (line 686)
void _cleanFile ()
_close (line 658)
void _close ()
_dirCheck (line 1577)

Check if a directory exists and create it (including parent dirs) if not.

  • return: TRUE if the directory exists or was created
bool _dirCheck (string $p_dir)
  • string $p_dir: directory to check
_error (line 551)
void _error ( $p_message)
  • $p_message
_extractList (line 1290)
void _extractList ( $p_path,  &$p_list_detail,  $p_mode,  $p_file_list,  $p_remove_path)
  • $p_path
  • &$p_list_detail
  • $p_mode
  • $p_file_list
  • $p_remove_path
_jumpBlock (line 757)
void _jumpBlock ([ $p_len = null])
  • $p_len
_openAppend (line 1477)
void _openAppend ()
_openRead (line 588)
void _openRead ()
_openReadWrite (line 637)
void _openReadWrite ()
_openWrite (line 567)
void _openWrite ()
_readBlock (line 735)
void _readBlock ([ $p_len = null])
  • $p_len
_readHeader (line 1148)
void _readHeader ( $v_binary_data,  &$v_header)
  • $v_binary_data
  • &$v_header
_readLongHeader (line 1213)
void _readLongHeader ( &$v_header)
  • &$v_header
_translateWinPath (line 1647)
void _translateWinPath ( $p_path, [ $p_remove_disk_letter = true])
  • $p_path
  • $p_remove_disk_letter
_warning (line 559)
void _warning ( $p_message)
  • $p_message
_writeBlock (line 706)
void _writeBlock ( $p_binary_data, [ $p_len = null])
  • $p_binary_data
  • $p_len
_writeFooter (line 780)
void _writeFooter ()
_writeHeader (line 946)
void _writeHeader ( $p_filename,  $p_stored_filename)
  • $p_filename
  • $p_stored_filename
_writeHeaderBlock (line 1020)
void _writeHeaderBlock ( $p_filename,  $p_size,  $p_mtime,  $p_perms, [ $p_type = ''],  $p_uid,  $p_gid)
  • $p_filename
  • $p_size
  • $p_mtime
  • $p_perms
  • $p_type
  • $p_uid
  • $p_gid
_writeLongHeader (line 1088)
void _writeLongHeader ( $p_filename)
  • $p_filename

Inherited Methods

Inherited From PEAR

 PEAR::PEAR()
 PEAR::delExpect()
 PEAR::expectError()
 PEAR::getStaticProperty()
 PEAR::isError()
 PEAR::loadExtension()
 PEAR::popErrorHandling()
 PEAR::popExpect()
 PEAR::pushErrorHandling()
 PEAR::raiseError()
 PEAR::registerShutdownFunc()
 PEAR::setErrorHandling()
 PEAR::staticPopErrorHandling()
 PEAR::staticPushErrorHandling()
 PEAR::throwError()
 PEAR::_PEAR()

Documentation generated on Mon, 22 Sep 2008 12:07:36 +0100 by phpDocumentor 1.3.1