PHP Класс Archive_Tar, JxLib

Наследование: extends PEAR
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$_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://)

Открытые методы

Метод Описание
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, ',');

Описание методов

Archive_Tar() публичный Метод

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() публичный Метод

{{{ destructor
public _Archive_Tar ( )

_addFile() публичный Метод

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

_addList() публичный Метод

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

_addString() публичный Метод

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

_append() публичный Метод

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

_cleanFile() публичный Метод

{{{ _cleanFile()
public _cleanFile ( )

_close() публичный Метод

{{{ _close()
public _close ( )

_dirCheck() публичный Метод

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
Результат boolean TRUE if the directory exists or was created

_error() публичный Метод

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

_extractInString() публичный Метод

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.
Результат a string with the file content or NULL.

_extractList() публичный Метод

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

_isArchive() публичный Метод

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

_jumpBlock() публичный Метод

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

_maliciousFilename() публичный Метод

Detect and report a malicious file name
public _maliciousFilename ( string $file ) : boolean
$file string
Результат boolean

_openAppend() публичный Метод

{{{ _openAppend()
public _openAppend ( )

_openRead() публичный Метод

{{{ _openRead()
public _openRead ( )

_openReadWrite() публичный Метод

{{{ _openReadWrite()
public _openReadWrite ( )

_openWrite() публичный Метод

{{{ _openWrite()
public _openWrite ( )

_pathReduction() публичный Метод

./bar" to "/dir/bar", rand emove double slashes.
public _pathReduction ( string $p_dir ) : string
$p_dir string path to reduce
Результат string reduced path

_readBlock() публичный Метод

{{{ _readBlock()
public _readBlock ( )

_readHeader() публичный Метод

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

_readLongHeader() публичный Метод

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

_translateWinPath() публичный Метод

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

_warning() публичный Метод

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

_writeBlock() публичный Метод

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

_writeFooter() публичный Метод

{{{ _writeFooter()
public _writeFooter ( )

_writeHeader() публичный Метод

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

_writeHeaderBlock() публичный Метод

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

_writeLongHeader() публичный Метод

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

add() публичный Метод

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.
См. также: 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.
Результат true on success, false on error.

addModify() публичный Метод

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.
Результат true on success, false on error.

addString() публичный Метод

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.
Результат true on success, false on error.

create() публичный Метод

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.
См. также: 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.
Результат true on success, false on error.

createModify() публичный Метод

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.
См. также: 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.
Результат boolean true on success, false on error.

extract() публичный Метод

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

extractInString() публичный Метод

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.
Результат a string with the file content or NULL.

extractList() публичный Метод

If indicated the $p_remove_path can be used in the same way as it is used in extractModify() method.
См. также: 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.
Результат true on success, false on error.

extractModify() публичный Метод

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.
См. также: 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.
Результат boolean true on success, false on error.

listContent() публичный Метод

{{{ listContent()
public listContent ( )

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, ',');
public setAttribute ( ) : true
Результат true on success, false on error.

Описание свойств

$_compress публичное свойство

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

$_compress_type публичное свойство

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

$_file публичное свойство

descriptor
public $_file

$_separator публичное свойство

Explode separator
public $_separator

$_tarname публичное свойство

Name of the Tar
public $_tarname

$_temp_tarname публичное свойство

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