Core_Tar
in package
Creates a tar archive
Tags
Table of Contents
Properties
- $_compress : bool
- $_compress_type : string
- $_excludeDir : array<string|int, mixed>
- Exclude dir
- $_file : file
- $_separator : string
- $_tarname : string
- $_temp_tarname : string
Methods
- __construct() : mixed
- 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.
- add() : 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() : 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() : 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() : true
- This method creates the archive file and add the files / directories that are listed in $p_filelist.
- createModify() : bool
- This method creates the archive file and add the files / directories that are listed in $p_filelist.
- excludeDir() : mixed
- Add Excluding Dir
- extract() : mixed
- Extract
- extractInString() : a
- This method extract FROM the archive one file identified by $p_filename.
- extractList() : 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() : bool
- 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.
- gzopen() : mixed
- Fix bug gzopen -> gzopen64 http://www.hostcms.ru/forums/2/10759/
- _addFile() : bool
- Add file
- _addList() : bool
- Add list
- _addString() : bool
- Add string
- _append() : unknown
- Append
- _cleanFile() : bool
- Clean file
- _close() : bool
- Close
- _dirCheck() : bool
- Check if a directory exists and create it (including parent dirs) if not.
- _error() : mixed
- Show error message
- _extractInString() : a
- This method extract FROM the archive one file identified by $p_filename.
- _extractList() : mixed
- Extract list
- _isArchive() : bool
- Check if file is archive
- _jumpBlock() : bool
- Skip block
- _openAppend() : mixed
- Open for append
- _openRead() : bool
- Open for read
- _openReadWrite() : bool
- Open for read and write
- _openWrite() : bool
- Open for write
- _pathReduction() : string
- Compress path by changing for example "/dir/foo/../bar" to "/dir/bar", rand emove double slashes.
- _readBlock() : string
- Read block
- _readHeader() : bool
- Read header
- _readLongHeader() : bool
- Read long header
- _translateWinPath() : string
- {{{ _translateWinPath()
- _warning() : mixed
- Show warning message
- _writeBlock() : bool
- Write block
- _writeFooter() : bool
- Write footer
- _writeHeader() : bool
- Write header
- _writeHeaderBlock() : bool
- Write header block
- _writeLongHeader() : bool
- Write long header
Properties
$_compress
protected
bool
$_compress
= \NULL
if true, the Tar file will be gzipped
$_compress_type
protected
string
$_compress_type
= 'none'
Type of compression : 'none', 'gz' or 'bz2'
$_excludeDir
Exclude dir
protected
array<string|int, mixed>
$_excludeDir
= array()
$_file
protected
file
$_file
= 0
descriptor
$_separator
protected
string
$_separator
= ' '
Explode separator
$_tarname
protected
string
$_tarname
= ''
Name of the Tar
$_temp_tarname
protected
string
$_temp_tarname
= ''
Local Tar name of a remote Tar (http:// or ftp://)
Methods
__construct()
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.
public
__construct(string $p_tarname[, string $p_compress = NULL ]) : mixed
If the compress argument is set the tar will be read or created as a gzip or bz2 compressed TAR file.
Parameters
- $p_tarname : string
-
The name of the tar archive to create
- $p_compress : string = NULL
-
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'.
Tags
add()
This method add the files / directories that are listed in $p_filelist in the archive. If the archive does not exist it is created.
public
add(array<string|int, mixed> $p_filelist) : true
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
- $p_filelist : array<string|int, mixed>
-
An array of filenames and directory names, or a single string with names separated by a single blank space.
Tags
Return values
true —on success, false on error.
addModify()
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.
public
addModify(array<string|int, mixed> $p_filelist, string $p_add_dir[, string $p_remove_dir = '' ]) : true
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.
Parameters
- $p_filelist : array<string|int, mixed>
-
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.
Tags
Return values
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
Parameters
- $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.
Tags
Return values
true —on success, false on error.
create()
This method creates the archive file and add the files / directories that are listed in $p_filelist.
public
create(array<string|int, mixed> $p_filelist) : true
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
- $p_filelist : array<string|int, mixed>
-
An array of filenames and directory names, or a single string with names separated by a single blank space.
Tags
Return values
true —on success, false on error.
createModify()
This method creates the archive file and add the files / directories that are listed in $p_filelist.
public
createModify(array<string|int, mixed> $p_filelist, string $p_add_dir[, mixed $p_remove_dir = '' ]) : bool
If the file уже существует 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
- $p_filelist : array<string|int, mixed>
-
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 : mixed = ''
Tags
Return values
bool —true on success, false on error.
excludeDir()
Add Excluding Dir
public
excludeDir(mixed $dirPath) : mixed
Parameters
- $dirPath : mixed
extract()
Extract
public
extract([string $p_path = '' ]) : mixed
Parameters
- $p_path : string = ''
-
path
extractInString()
This method extract FROM the archive one file identified by $p_filename.
public
extractInString(string $p_filename) : a
The return value is a string with the file content, or NULL on error.
Parameters
- $p_filename : string
-
The path of the file to extract in a string.
Tags
Return values
a —string with the file content or NULL.
extractList()
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.
public
extractList(array<string|int, mixed> $p_filelist[, string $p_path = '' ][, string $p_remove_path = '' ]) : true
If indicated the $p_remove_path can be used in the same way as it is used in extractModify() method.
Parameters
- $p_filelist : array<string|int, mixed>
-
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.
Tags
Return values
true —on success, false on error.
extractModify()
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.
public
extractModify(string $p_path, string $p_remove_path) : bool
While extracting a file, if the directory path does not exists it is created. While extracting a file, if the file уже существует it is replaced without looking for last modification date. While extracting a file, if the file уже существует 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
- $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.
Tags
Return values
bool —true on success, false on error.
gzopen()
Fix bug gzopen -> gzopen64 http://www.hostcms.ru/forums/2/10759/
public
gzopen(mixed $filename, mixed $mode[, mixed $use_include_path = 0 ]) : mixed
Parameters
- $filename : mixed
- $mode : mixed
- $use_include_path : mixed = 0
_addFile()
Add file
protected
_addFile(string $p_filename, pointer &$p_header, string $p_add_dir, string $p_remove_dir) : bool
Parameters
- $p_filename : string
- $p_header : pointer
- $p_add_dir : string
- $p_remove_dir : string
Return values
bool_addList()
Add list
protected
_addList(array<string|int, mixed> $p_list, string $p_add_dir, string $p_remove_dir) : bool
Parameters
- $p_list : array<string|int, mixed>
- $p_add_dir : string
- $p_remove_dir : string
Return values
bool_addString()
Add string
protected
_addString( $p_filename, $p_string) : bool
Parameters
Return values
bool_append()
Append
protected
_append(unknown_type $p_filelist[, unknown_type $p_add_dir = '' ][, unknown_type $p_remove_dir = '' ]) : unknown
Parameters
- $p_filelist : unknown_type
- $p_add_dir : unknown_type = ''
- $p_remove_dir : unknown_type = ''
Tags
Return values
unknown_cleanFile()
Clean file
protected
_cleanFile() : bool
Return values
bool_close()
Close
protected
_close() : bool
Return values
bool_dirCheck()
Check if a directory exists and create it (including parent dirs) if not.
protected
_dirCheck(string $p_dir[, string $chmod = CHMOD ]) : bool
Parameters
- $p_dir : string
-
directory to check
- $chmod : string = CHMOD
-
CHMOD
Return values
bool —TRUE if the directory exists or was created
_error()
Show error message
protected
_error(string $p_message) : mixed
Parameters
- $p_message : string
-
message text
_extractInString()
This method extract FROM the archive one file identified by $p_filename.
protected
_extractInString(string $p_filename) : a
The return value is a string with the file content, or NULL on error.
Parameters
- $p_filename : string
-
The path of the file to extract in a string.
Tags
Return values
a —string with the file content or NULL.
_extractList()
Extract list
protected
_extractList(string $p_path, pointer &$p_list_detail, string $p_mode, array<string|int, mixed> $p_file_list, string $p_remove_path) : mixed
Parameters
- $p_path : string
-
path
- $p_list_detail : pointer
- $p_mode : string
- $p_file_list : array<string|int, mixed>
- $p_remove_path : string
_isArchive()
Check if file is archive
protected
_isArchive([string $p_filename = NULL ]) : bool
Parameters
- $p_filename : string = NULL
-
file name
Return values
bool_jumpBlock()
Skip block
protected
_jumpBlock([int $p_len = null ]) : bool
Parameters
- $p_len : int = null
-
block length
Return values
bool_openAppend()
Open for append
protected
_openAppend() : mixed
_openRead()
Open for read
protected
_openRead() : bool
Return values
bool_openReadWrite()
Open for read and write
protected
_openReadWrite() : bool
Return values
bool_openWrite()
Open for write
protected
_openWrite() : bool
Return values
bool_pathReduction()
Compress path by changing for example "/dir/foo/../bar" to "/dir/bar", rand emove double slashes.
protected
_pathReduction(string $p_dir) : string
Parameters
- $p_dir : string
-
path to reduce
Tags
Return values
string —reduced path
_readBlock()
Read block
protected
_readBlock() : string
Return values
string_readHeader()
Read header
protected
_readHeader(string $v_binary_data, pointer &$v_header) : bool
Parameters
- $v_binary_data : string
- $v_header : pointer
Return values
bool_readLongHeader()
Read long header
protected
_readLongHeader(pointer &$v_header) : bool
Parameters
- $v_header : pointer
Return values
bool_translateWinPath()
{{{ _translateWinPath()
protected
_translateWinPath(string $p_path[, bool $p_remove_disk_letter = true ]) : string
Parameters
- $p_path : string
-
path
- $p_remove_disk_letter : bool = true
-
remove disk letter
Return values
string_warning()
Show warning message
protected
_warning(string $p_message) : mixed
Parameters
- $p_message : string
-
message text
_writeBlock()
Write block
protected
_writeBlock(string $p_binary_data[, int $p_len = null ]) : bool
Parameters
- $p_binary_data : string
- $p_len : int = null
-
data length
Return values
bool_writeFooter()
Write footer
protected
_writeFooter() : bool
Return values
bool_writeHeader()
Write header
protected
_writeHeader(string $p_filename, string $p_stored_filename) : bool
Parameters
- $p_filename : string
- $p_stored_filename : string
Return values
bool_writeHeaderBlock()
Write header block
protected
_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 ]) : bool
Parameters
- $p_filename : string
-
file name
- $p_size : int
-
size
- $p_mtime : int = 0
- $p_perms : int = 0
- $p_type : string = ''
- $p_uid : int = 0
- $p_gid : int = 0
Return values
bool_writeLongHeader()
Write long header
protected
_writeLongHeader(string $p_filename) : bool
Parameters
- $p_filename : string