[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/ -> AkZip.php (summary)

(no description)

Author: Bermi Ferrer
Author: Vincent Blavet
Copyright: Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
License: GNU Lesser General Public License
File Size: 2914 lines (122 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

AkZip:: (43 methods):
  AkZip()
  create()
  add()
  listContent()
  extract()
  delete()
  properties()
  duplicate()
  merge()
  errorCode()
  errorName()
  errorInfo()
  _checkFormat()
  _create()
  _add()
  _openFd()
  _closeFd()
  _addList()
  _addFileList()
  _addFile()
  _writeFileHeader()
  _writeCentralFileHeader()
  _writeCentralHeader()
  _list()
  _convertHeader2FileInfo()
  _extractByRule()
  _extractFile()
  _extractFileAsString()
  _readFileHeader()
  _readCentralFileHeader()
  _readEndCentralDir()
  _deleteByRule()
  _dirCheck()
  _merge()
  _duplicate()
  _check_parameters()
  _errorLog()
  _errorReset()
  _tool_PathReduction()
  _tool_PathInclusion()
  _tool_CopyBlock()
  _tool_Rename()
  _tool_TranslateWinPath()


Class: AkZip  - X-Ref

Class for manipulating zip archive files

A class which provided common methods to manipulate ZIP formatted
archive files.
It provides creation, extraction, deletion and add features.

AkZip($p_zipname)   X-Ref
AkZip Class constructor. This flavour of the constructor only
declare a new AkZip object, identifying it by the name of the
zip file.

param: string  $p_zipname  The name of the zip archive to create

create($p_filelist, $p_params = 0)   X-Ref
This method creates a Zip Archive with the filename set with
the constructor.
The files and directories indicated in $p_filelist
are added in the archive.
When a directory is in the list, the directory and its content is added
in the archive.
The methods takes a variable list of parameters in $p_params.
The supported parameters for this method are :
'add_path' : Add a path to the archived files.
'remove_path' : Remove the specified 'root' path of the archived files.
'remove_all_path' : Remove all the path of the archived files.
'no_compression' : The archived files will not be compressed.

param: mixed  $p_filelist  The list of the files or folders to add.
param: mixed  $p_params  An array of variable parameters and values.
return: mixed An array of file description on success,

add($p_filelist, $p_params = 0)   X-Ref
This method add files or directory in an existing Zip Archive.
If the Zip Archive does not exist it is created.
The files and directories to add are indicated in $p_filelist.
When a directory is in the list, the directory and its content is added
in the archive.
The methods takes a variable list of parameters in $p_params.
The supported parameters for this method are :
'add_path' : Add a path to the archived files.
'remove_path' : Remove the specified 'root' path of the archived files.
'remove_all_path' : Remove all the path of the archived files.
'no_compression' : The archived files will not be compressed.
'callback_pre_add' : A callback function that will be called before
each entry archiving.
'callback_post_add' : A callback function that will be called after
each entry archiving.

param: mixed  $p_filelist  The list of the files or folders to add.
param: mixed  $p_params  An array of variable parameters and values.
return: mixed An array of file description on success,

listContent()   X-Ref
This method gives the names and properties of the files and directories
which are present in the zip archive.
The properties of each entries in the list are :
filename : Name of the file.
For create() or add() it's the filename given by the user.
For an extract() it's the filename of the extracted file.
stored_filename : Name of the file / directory stored in the archive.
size : Size of the stored file.
compressed_size : Size of the file's data compressed in the archive
(without the zip headers overhead)
mtime : Last known modification date of the file (UNIX timestamp)
comment : Comment associated with the file
folder : true | false (indicates if the entry is a folder)
index : index of the file in the archive (-1 when not available)
status : status of the action on the entry (depending of the action) :
Values are :
ok : OK !
filtered : the file/dir was not extracted (filtered by user)
already_a_directory : the file can't be extracted because a
directory with the same name already
exists
write_protected : the file can't be extracted because a file
with the same name already exists and is
write protected
newer_exist : the file was not extracted because a newer
file already exists
path_creation_fail : the file is not extracted because the
folder does not exists and can't be
created
write_error : the file was not extracted because there was a
error while writing the file
read_error : the file was not extracted because there was a
error while reading the file
invalid_header : the file was not extracted because of an
archive format error (bad file header)
Note that each time a method can continue operating when there
is an error on a single file, the error is only logged in the file status.

return: mixed An array of file description on success,

extract($p_params = 0)   X-Ref
This method extract the files and folders which are in the zip archive.
It can extract all the archive or a part of the archive by using filter
feature (extract by name, by index, by ereg, by preg). The extraction
can occur in the current path or an other path.
All the advanced features are activated by the use of variable
parameters.
The return value is an array of entry descriptions which gives
information on extracted files (See listContent()).
The method may return a success value (an array) even if some files
are not correctly extracted (see the file status in listContent()).
The supported variable parameters for this method are :
'add_path' : Path where the files and directories are to be extracted
'remove_path' : First part ('root' part) of the memorized path
(if similar) to remove while extracting.
'remove_all_path' : Remove all the memorized path while extracting.
'extract_as_string' :
'set_chmod' : After the extraction of the file the indicated mode
will be set.
'by_name' : It can be a string with file/dir names separated by ',',
or an array of file/dir names to extract from the archive.
'by_index' : A string with range of indexes separated by ',',
(sample "1,3-5,12").
'by_ereg' : A regular expression (ereg) that must match the extracted
filename.
'by_preg' : A regular expression (preg) that must match the extracted
filename.
'callback_pre_extract' : A callback function that will be called before
each entry extraction.
'callback_post_extract' : A callback function that will be called after
each entry extraction.

param: mixed  $p_params  An array of variable parameters and values.
return: mixed An array of file description on success,

delete($p_params)   X-Ref
This methods delete archive entries in the zip archive.
Notice that at least one filtering rule (set by the variable parameter
list) must be set.
Also notice that if you delete a folder entry, only the folder entry
is deleted, not all the files bellonging to this folder.
The supported variable parameters for this method are :
'by_name' : It can be a string with file/dir names separated by ',',
or an array of file/dir names to delete from the archive.
'by_index' : A string with range of indexes separated by ',',
(sample "1,3-5,12").
'by_ereg' : A regular expression (ereg) that must match the extracted
filename.
'by_preg' : A regular expression (preg) that must match the extracted
filename.

param: mixed  $p_params  An array of variable parameters and values.
return: mixed An array of file description on success,

properties()   X-Ref
This method gives the global properties of the archive.
The properties are :
nb : Number of files in the archive
comment : Comment associated with the archive file
status : not_exist, ok

param: mixed  $p_params  {Description}
return: mixed An array with the global properties or 0 on error.

duplicate($p_archive)   X-Ref
This method creates an archive by copying the content of an other one.
If the archive already exist, it is replaced by the new one without
any warning.

param: mixed  $p_archive  It can be a valid AkZip object or
return: integer 1 on success, 0 on failure.

merge($p_archive_to_add)   X-Ref
This method merge a valid zip archive at the end of the
archive identified by the AkZip object.
If the archive ($this) does not exist, the merge becomes a duplicate.
If the archive to add does not exist, the merge is a success.

param: mixed $p_archive_to_add  It can be a valid AkZip object or
return: integer 1 on success, 0 on failure.

errorCode()   X-Ref
Method that gives the lastest error code.

return: integer The error code value.

errorName($p_with_code = false)   X-Ref
This method gives the latest error code name.

param: boolean $p_with_code  If true, gives the name and the int value.
return: string The error name.

errorInfo($p_full = false)   X-Ref
This method returns the description associated with the latest error.

param: boolean $p_full If set to true gives the description with the
return: string The error description.

_checkFormat($p_level = 0)   X-Ref
AkZip::_checkFormat()

{ Description }

param: integer $p_level

_create($p_list, &$p_result_list, &$p_params)   X-Ref
AkZip::_create()

{ Description }


_add($p_list, &$p_result_list, &$p_params)   X-Ref
AkZip::_add()

{ Description }


_openFd($p_mode)   X-Ref
AkZip::_openFd()

{ Description }


_closeFd()   X-Ref
AkZip::_closeFd()

{ Description }


_addList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)   X-Ref
AkZip::_addList()

{ Description }


_addFileList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)   X-Ref
AkZip::_addFileList()

{ Description }


_addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)   X-Ref
AkZip::_addFile()

{ Description }


_writeFileHeader(&$p_header)   X-Ref
AkZip::_writeFileHeader()

{ Description }


_writeCentralFileHeader(&$p_header)   X-Ref
AkZip::_writeCentralFileHeader()

{ Description }


_writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)   X-Ref
AkZip::_writeCentralHeader()

{ Description }


_list(&$p_list)   X-Ref
AkZip::_list()

{ Description }


_convertHeader2FileInfo($p_header, &$p_info)   X-Ref
AkZip::_convertHeader2FileInfo()

{ Description }


_extractByRule(&$p_file_list, &$p_params)   X-Ref
AkZip::_extractByRule()

{ Description }


_extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params)   X-Ref
AkZip::_extractFile()

{ Description }


_extractFileAsString(&$p_entry, &$p_string)   X-Ref
AkZip::_extractFileAsString()

{ Description }


_readFileHeader(&$p_header)   X-Ref
AkZip::_readFileHeader()

{ Description }


_readCentralFileHeader(&$p_header)   X-Ref
AkZip::_readCentralFileHeader()

{ Description }


_readEndCentralDir(&$p_central_dir)   X-Ref
AkZip::_readEndCentralDir()

{ Description }


_deleteByRule(&$p_result_list, &$p_params)   X-Ref
AkZip::_deleteByRule()

{ Description }


_dirCheck($p_dir, $p_is_dir = false)   X-Ref
AkZip::_dirCheck()

{ Description }

param: [type] $p_is_dir

_merge(&$p_archive_to_add)   X-Ref
AkZip::_merge()

{ Description }


_duplicate($p_archive_filename)   X-Ref
AkZip::_duplicate()

{ Description }


_check_parameters(&$p_params, $p_default)   X-Ref
AkZip::_check_parameters()

{ Description }

param: integer $p_error_code
param: string $p_error_string

_errorLog($p_error_code = 0, $p_error_string = '')   X-Ref
AkZip::_errorLog()

{ Description }

param: integer $p_error_code
param: string $p_error_string

_errorReset()   X-Ref
AkZip::_errorReset()

{ Description }


_tool_PathReduction($p_dir)   X-Ref
_tool_PathReduction()

{ Description }


_tool_PathInclusion($p_dir, $p_path)   X-Ref
_tool_PathInclusion()

{ Description }


_tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode = 0)   X-Ref
_tool_CopyBlock()

{ Description }

param: integer $p_mode

_tool_Rename($p_src, $p_dest)   X-Ref
_tool_Rename()

{ Description }


_tool_TranslateWinPath($p_path, $p_remove_disk_letter = true)   X-Ref
_tool_TranslateWinPath()

{ Description }

param: [type] $p_remove_disk_letter



Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6