PHP 클래스 Archive_Tar, JxLib

상속: extends PEAR
파일 보기 프로젝트 열기: JxLib/JxLib 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_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