Skip to main content Help Control Panel

Aubagne HipHop

Tout le Hip Hop d'Aubagne et des alentours

Home «   Server software «  

Documentation: included/tar.php

ContentClick to slide

included/tar.php

This script is a reference file of this system.

Licence: http://www.php.net/license/3_0.txt

Auteurs:

class Archive_Tar - Creates a (compressed) Tar archive

@version $Revision: 1.29 $ @package Archive

Auteurs:

  • Vincent Blavet

included/tar.php - @var string Name of the Tar

included/tar.php - @var boolean if true, the Tar file will be gzipped

included/tar.php - @var string Type of compression : 'none', 'gz' or 'bz2'

included/tar.php - @var string Explode separator

included/tar.php - @var file descriptor

included/tar.php - @var string Local Tar name of a remote Tar (http:// or ftp://)

Archive_Tar() - Archive_Tar Class constructor. This flavour of the constructor only

function Archive_Tar($p_tarname, $p_compress = null)

  • $p_tarname - string $p_tarname The name of the tar archive to create
  • $p_compress = null - string $p_compress can be null, 'gz' or 'bz2'. This

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.

parameter indicates if gzip or bz2 compression is required. For compatibility reason the boolean value 'true' means 'gz'. @access public

_Archive_Tar()

function _Archive_Tar()

create() - This method creates the archive file and add the files / directories

function create($p_filelist)

  • $p_filelist - array $p_filelist An array of filenames and directory names, or a
  • returns true on success, false on error.

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.

single string with names separated by a single blank space. @access public

Voir aussi:

add() - This method add the files / directories that are listed in $p_filelist in

function add($p_filelist)

  • $p_filelist - array $p_filelist An array of filenames and directory names, or a
  • returns true on success, false on error.

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.

single string with names separated by a single blank space. @access public

Voir aussi:

extract()

function extract($p_path='')

  • $p_path='' -

listContent()

function listContent()

createModify() - This method creates the archive file and add the files / directories

function createModify($p_filelist, $p_add_dir, $p_remove_dir='')

  • $p_filelist - array $p_filelist An array of filenames and directory names,
  • $p_add_dir - string $p_add_dir A string which contains a path to be added
  • $p_remove_dir='' - string $p_remove_dir A string which contains a path to be
  • returns boolean true on success, false on error.

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.

or a single string with names separated by a single blank space. to the memorized path of each element in the list. removed from the memorized path of each element in the list, when relevant. @access public

Voir aussi:

addModify() - This method add the files / directories listed in $p_filelist at the

function addModify($p_filelist, $p_add_dir, $p_remove_dir='')

  • $p_filelist - array $p_filelist An array of filenames and directory
  • $p_add_dir - string $p_add_dir A string which contains a path to be
  • $p_remove_dir='' - string $p_remove_dir A string which contains a path to be
  • returns true on success, false on error.

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.

names, or a single string with names separated by a single blank space. added to the memorized path of each element in the list. removed from the memorized path of each element in the list, when relevant. @access public

addString() - This method add a single string as a file at the

function addString($p_filename, $p_string)

  • $p_filename - string $p_filename A string which contains the full
  • $p_string - string $p_string The content of the file added in
  • returns true on success, false on error.

end of the existing archive. If the archive does not yet exists it is created.

filename path that will be associated with the string. the archive. @access public

extractModify() - This method extract all the content of the archive in the directory

function extractModify($p_path, $p_remove_path)

  • $p_path - string $p_path The path of the directory where the
  • $p_remove_path - string $p_remove_path Part of the memorized path that can be
  • returns boolean true on success, false on error.

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.

files/dir need to by extracted. removed if present at the beginning of the file/dir path. @access public

Voir aussi:

extractInString() - This method extract from the archive one file identified by $p_filename.

function extractInString($p_filename)

  • $p_filename - string $p_filename The path of the file to extract in a string.
  • returns a string with the file content or NULL.

The return value is a string with the file content, or NULL on error. @access public

extractList() - This method extract from the archive only the files indicated in the

function extractList($p_filelist, $p_path='', $p_remove_path='')

  • $p_filelist - array $p_filelist An array of filenames and directory names,
  • $p_path='' - string $p_path The path of the directory where the
  • $p_remove_path='' - string $p_remove_path Part of the memorized path that can be
  • returns true on success, false on error.

$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. or a single string with names separated by a single blank space. files/dir need to by extracted. removed if present at the beginning of the file/dir path. @access public

Voir aussi:

setAttribute() - This method set specific attributes of the archive. It uses a variable

function setAttribute()

  • returns true on success, false on error.

list of parameters, in the format attribute code + attribute values : $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ','); @access public

_error()

function _error($p_message)

  • $p_message -

_warning()

function _warning($p_message)

  • $p_message -

_isArchive()

function _isArchive($p_filename=NULL)

  • $p_filename=NULL -

_openWrite()

function _openWrite()

_openRead()

function _openRead()

_openReadWrite()

function _openReadWrite()

_close()

function _close()

_cleanFile()

function _cleanFile()

_writeBlock()

function _writeBlock($p_binary_data, $p_len=null)

  • $p_binary_data -
  • $p_len=null -

_readBlock()

function _readBlock()

_jumpBlock()

function _jumpBlock($p_len=null)

  • $p_len=null -

_writeFooter()

function _writeFooter()

_addList()

function _addList($p_list, $p_add_dir, $p_remove_dir)

  • $p_list -
  • $p_add_dir -
  • $p_remove_dir -

_addFile()

function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir)

  • $p_filename -
  • &$p_header -
  • $p_add_dir -
  • $p_remove_dir -

_addString()

function _addString($p_filename, $p_string)

  • $p_filename -
  • $p_string -

_writeHeader()

function _writeHeader($p_filename, $p_stored_filename)

  • $p_filename -
  • $p_stored_filename -

_writeLongHeader()

function _writeLongHeader($p_filename)

  • $p_filename -

_readHeader()

function _readHeader($v_binary_data, &$v_header)

  • $v_binary_data -
  • &$v_header -

_readLongHeader()

function _readLongHeader(&$v_header)

  • &$v_header -

_extractInString() - This method extract from the archive one file identified by $p_filename.

function _extractInString($p_filename)

  • $p_filename - string $p_filename The path of the file to extract in a string.
  • returns a string with the file content or NULL.

The return value is a string with the file content, or NULL on error. @access private

_openAppend()

function _openAppend()

_append()

function _append($p_filelist, $p_add_dir='', $p_remove_dir='')

  • $p_filelist -
  • $p_add_dir='' -
  • $p_remove_dir='' -

_dirCheck() - Check if a directory exists and create it (including parent

function _dirCheck($p_dir)

  • $p_dir - string $p_dir directory to check
  • returns bool TRUE if the directory exists or was created

dirs) if not.

_pathReduction() - Compress path by changing for example "/dir/foo/../bar" to "/dir/bar",

function _pathReduction($p_dir)

  • $p_dir - string $p_dir path to reduce
  • returns string reduced path

rand emove double slashes.

@access private

_translateWinPath()

function _translateWinPath($p_path, $p_remove_disk_letter=true)

  • $p_path -
  • $p_remove_disk_letter=true -

Tools
Browse the source of this script
Server software