BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
ZipArchive Class Reference
Collaboration diagram for ZipArchive:

Public Member Functions

 open ($filename, $flags=null)
 
 close ()
 
 getStatusString ()
 
 addEmptyDir ($dirname)
 
 addFromString ($localname, $contents)
 
 addFile ($filename, $localname=null, $start=0, $length=0)
 
 addGlob ($pattern, $flags=0, array $options=array())
 
 addPattern ($pattern, $path= '.', array $options=array())
 
 renameIndex ($index, $newname)
 
 renameName ($name, $newname)
 
 setArchiveComment ($comment)
 
 getArchiveComment ($flags=null)
 
 setCommentIndex ($index, $comment)
 
 setCommentName ($name, $comment)
 
 setCompressionIndex ($index, $comp_method, $comp_flags=0)
 
 setCompressionName ($name, $comp_method, $comp_flags=0)
 
 setPassword ($password)
 
 getCommentIndex ($index, $flags=null)
 
 getCommentName ($name, $flags=null)
 
 deleteIndex ($index)
 
 deleteName ($name)
 
 statName ($name, $flags=null)
 
 statIndex ($index, $flags=null)
 
 locateName ($name, $flags=null)
 
 getNameIndex ($index, $flags=null)
 
 unchangeArchive ()
 
 unchangeAll ()
 
 unchangeIndex ($index)
 
 unchangeName ($name)
 
 extractTo ($destination, $entries=null)
 
 getFromName ($name, $length=0, $flags=null)
 
 getFromIndex ($index, $length=0, $flags=null)
 
 getStream ($name)
 

Public Attributes

const CREATE = 1
 
const EXCL = 2
 
const CHECKCONS = 4
 
const OVERWRITE = 8
 
const FL_NOCASE = 1
 
const FL_NODIR = 2
 
const FL_COMPRESSED = 4
 
const FL_UNCHANGED = 8
 
const CM_DEFAULT = -1
 
const CM_STORE = 0
 
const CM_SHRINK = 1
 
const CM_REDUCE_1 = 2
 
const CM_REDUCE_2 = 3
 
const CM_REDUCE_3 = 4
 
const CM_REDUCE_4 = 5
 
const CM_IMPLODE = 6
 
const CM_DEFLATE = 8
 
const CM_DEFLATE64 = 9
 
const CM_PKWARE_IMPLODE = 10
 
const CM_BZIP2 = 12
 
const CM_LZMA = 14
 
const CM_TERSE = 18
 
const CM_LZ77 = 19
 
const CM_WAVPACK = 97
 
const CM_PPMD = 98
 
const ER_OK = 0
 
const ER_MULTIDISK = 1
 
const ER_RENAME = 2
 
const ER_CLOSE = 3
 
const ER_SEEK = 4
 
const ER_READ = 5
 
const ER_WRITE = 6
 
const ER_CRC = 7
 
const ER_ZIPCLOSED = 8
 
const ER_NOENT = 9
 
const ER_EXISTS = 10
 
const ER_OPEN = 11
 
const ER_TMPOPEN = 12
 
const ER_ZLIB = 13
 
const ER_MEMORY = 14
 
const ER_CHANGED = 15
 
const ER_COMPNOTSUPP = 16
 
const ER_EOF = 17
 
const ER_INVAL = 18
 
const ER_NOZIP = 19
 
const ER_INTERNAL = 20
 
const ER_INCONS = 21
 
const ER_REMOVE = 22
 
const ER_DELETED = 23
 
 $status
 
 $statusSys
 
 $numFiles
 
 $filename
 
 $comment
 

Detailed Description

A file archive, compressed with Zip. http://php.net/manual/en/class.ziparchive.php

Member Function Documentation

ZipArchive::addEmptyDir (   $dirname)

(PHP 5 >= 5.2.0, PECL zip >= 1.8.0)
Add a new directory string $dirname The directory to add.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::addFile (   $filename,
  $localname = null,
  $start = 0,
  $length = 0 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Adds a file to a ZIP archive from the given path string $filename The path to the file to add.

Parameters
string$localname[optional]

If supplied, this is the local name inside the ZIP archive that will override the filename.

Parameters
int$start[optional]

This parameter is not used but is required to extend ZipArchive.

Parameters
int$length[optional]

This parameter is not used but is required to extend ZipArchive.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::addFromString (   $localname,
  $contents 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Add a file to a ZIP archive using its contents string $localname The name of the entry to create.

Parameters
string$contents

The contents to use to create the entry. It is used in a binary safe mode.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::addGlob (   $pattern,
  $flags = 0,
array  $options = array() 
)

(PHP 5 >= 5.3.0, PECL zip >= 1.9.0)
Add files from a directory by glob pattern string $pattern A glob pattern against which files will be matched.

Parameters
int$flags[optional]

A bit mask of glob() flags.

Parameters
array$options[optional]

An associative array of options. Available options are:

"add_path"

Prefix to prepend when translating to the local path of the file within the archive. This is applied after any remove operations defined by the "remove_path" or "remove_all_path" options.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::addPattern (   $pattern,
  $path = '.',
array  $options = array() 
)

(PHP 5 >= 5.3.0, PECL zip >= 1.9.0)
Add files from a directory by PCRE pattern string $pattern A PCRE pattern against which files will be matched.

Parameters
string$path[optional]

The directory that will be scanned. Defaults to the current working directory.

Parameters
array$options[optional]

An associative array of options accepted by ZipArchive::addGlob.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::close ( )

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Close the active archive (opened or newly created) bool TRUE on success or FALSE on failure.

ZipArchive::deleteIndex (   $index)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
delete an entry in the archive using its index int $index Index of the entry to delete.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::deleteName (   $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
delete an entry in the archive using its name string $name Name of the entry to delete.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::extractTo (   $destination,
  $entries = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Extract the archive contents string $destination Location where to extract the files.

Parameters
mixed$entries[optional]

The entries to extract. It accepts either a single entry name or an array of names.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::getArchiveComment (   $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Returns the Zip archive comment int $flags [optional] If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged comment is returned.

Returns
string the Zip archive comment or FALSE on failure.
ZipArchive::getCommentIndex (   $index,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Returns the comment of an entry using the entry index int $index Index of the entry

Parameters
int$flags[optional]

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged comment is returned.

Returns
string the comment on success or FALSE on failure.
ZipArchive::getCommentName (   $name,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Returns the comment of an entry using the entry name string $name Name of the entry

Parameters
int$flags[optional]

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged comment is returned.

Returns
string the comment on success or FALSE on failure.
ZipArchive::getFromIndex (   $index,
  $length = 0,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.3.0)
Returns the entry contents using its index int $index Index of the entry

Parameters
int$length[optional]

The length to be read from the entry. If 0, then the entire entry is read.

Parameters
int$flags[optional]

The flags to use to open the archive. the following values may be ORed to it.

ZipArchive::FL_UNCHANGED

Returns
string the contents of the entry on success or FALSE on failure.
ZipArchive::getFromName (   $name,
  $length = 0,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Returns the entry contents using its name string $name Name of the entry

Parameters
int$length[optional]

The length to be read from the entry. If 0, then the entire entry is read.

Parameters
int$flags[optional]

The flags to use to open the archive. the following values may be ORed to it.

ZipArchive::FL_UNCHANGED

Returns
string the contents of the entry on success or FALSE on failure.
ZipArchive::getNameIndex (   $index,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Returns the name of an entry using its index int $index Index of the entry.

Parameters
int$flags[optional]

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged name is returned.

Returns
string the name on success or FALSE on failure.
ZipArchive::getStatusString ( )

Returns the status error message, system and/or zip messages string a string with the status message on success or FALSE on failure. 5.2.7

ZipArchive::getStream (   $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Get a file handler to the entry defined by its name (read only). string $name The name of the entry to use.

Returns
resource a file pointer (resource) on success or FALSE on failure.
ZipArchive::locateName (   $name,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Returns the index of the entry in the archive string $name The name of the entry to look up

Parameters
int$flags[optional]

The flags are specified by ORing the following values, or 0 for none of them.

ZipArchive::FL_NOCASE

Returns
int the index of the entry on success or FALSE on failure.
ZipArchive::open (   $filename,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Open a ZIP file archive string $filename The file name of the ZIP archive to open.

Parameters
int$flags[optional]

The mode to use to open the archive.

ZipArchive::OVERWRITE

Returns
mixed Error codes

Returns TRUE on success or the error code.

ZipArchive::ER_EXISTS

File already exists.

ZipArchive::ER_INCONS

Zip archive inconsistent.

ZipArchive::ER_INVAL

Invalid argument.

ZipArchive::ER_MEMORY

Malloc failure.

ZipArchive::ER_NOENT

No such file.

ZipArchive::ER_NOZIP

Not a zip archive.

ZipArchive::ER_OPEN

Can't open file.

ZipArchive::ER_READ

Read error.

ZipArchive::ER_SEEK

Seek error.

ZipArchive::renameIndex (   $index,
  $newname 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Renames an entry defined by its index int $index Index of the entry to rename.

Parameters
string$newname

New name.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::renameName (   $name,
  $newname 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Renames an entry defined by its name string $name Name of the entry to rename.

Parameters
string$newname

New name.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::setArchiveComment (   $comment)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of a ZIP archive string $comment The contents of the comment.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::setCommentIndex (   $index,
  $comment 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of an entry defined by its index int $index Index of the entry.

Parameters
string$comment

The contents of the comment.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::setCommentName (   $name,
  $comment 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of an entry defined by its name string $name Name of the entry.

Parameters
string$comment

The contents of the comment.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::setCompressionName (   $name,
  $comp_method,
  $comp_flags = 0 
)

Set the compression method of an entry defined by its name http://php.net/manual/en/ziparchive.setcompressionname.php

Parameters
string$nameName of the entry.
int$comp_methodThe compression method. Either ZipArchive::CM_DEFAULT, ZipArchive::CM_STORE or ZipArchive::CM_DEFLATE.
int$comp_flags[optional] Compression flags. Currently unused.
Returns
bool Returns TRUE on success or FALSE on failure.
Since
7.0
ZipArchive::setPassword (   $password)

(PHP 5 >= 5.6.0, PECL zip >= 1.12.0)

Parameters
$password
Returns
boolean
ZipArchive::statIndex (   $index,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Get the details of an entry defined by its index. int $index Index of the entry

Parameters
int$flags[optional]

ZipArchive::FL_UNCHANGED may be ORed to it to request information about the original file in the archive, ignoring any changes made.

Returns
array an array containing the entry details or FALSE on failure.
ZipArchive::statName (   $name,
  $flags = null 
)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Get the details of an entry defined by its name. string $name Name of the entry

Parameters
int$flags[optional]

The flags argument specifies how the name lookup should be done. Also, ZipArchive::FL_UNCHANGED may be ORed to it to request information about the original file in the archive, ignoring any changes made.

ZipArchive::FL_NOCASE

Returns
array an array containing the entry details or FALSE on failure.
ZipArchive::unchangeAll ( )

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Undo all changes done in the archive bool TRUE on success or FALSE on failure.

ZipArchive::unchangeArchive ( )

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Revert all global changes done in the archive. bool TRUE on success or FALSE on failure.

ZipArchive::unchangeIndex (   $index)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Revert all changes done to an entry at the given index int $index Index of the entry.

Returns
bool TRUE on success or FALSE on failure.
ZipArchive::unchangeName (   $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Revert all changes done to an entry with the given name. string $name Name of the entry.

Returns
bool TRUE on success or FALSE on failure.

Member Data Documentation

ZipArchive::$comment

Comment for the archive

ZipArchive::$filename

File name in the file system

ZipArchive::$numFiles

Number of files in archive

ZipArchive::$status

Status of the Zip Archive

ZipArchive::$statusSys

System status of the Zip Archive

const ZipArchive::CHECKCONS = 4

Perform additional consistency checks on the archive, and error if they fail. http://php.net/manual/en/zip.constants.php

const ZipArchive::CM_BZIP2 = 12
const ZipArchive::CM_DEFAULT = -1

better of deflate or store. http://php.net/manual/en/zip.constants.php

const ZipArchive::CM_DEFLATE = 8
const ZipArchive::CM_DEFLATE64 = 9
const ZipArchive::CM_IMPLODE = 6
const ZipArchive::CM_PKWARE_IMPLODE = 10
const ZipArchive::CM_REDUCE_1 = 2
const ZipArchive::CM_REDUCE_2 = 3
const ZipArchive::CM_REDUCE_3 = 4
const ZipArchive::CM_REDUCE_4 = 5
const ZipArchive::CM_SHRINK = 1
const ZipArchive::CM_STORE = 0
const ZipArchive::CREATE = 1

Create the archive if it does not exist. http://php.net/manual/en/zip.constants.php

const ZipArchive::ER_CHANGED = 15
const ZipArchive::ER_CLOSE = 3

Closing zip archive failed http://php.net/manual/en/zip.constants.php

const ZipArchive::ER_COMPNOTSUPP = 16

Compression method not supported. http://php.net/manual/en/zip.constants.php

const ZipArchive::ER_CRC = 7
const ZipArchive::ER_DELETED = 23
const ZipArchive::ER_EOF = 17
const ZipArchive::ER_EXISTS = 10
const ZipArchive::ER_INCONS = 21
const ZipArchive::ER_INTERNAL = 20
const ZipArchive::ER_INVAL = 18
const ZipArchive::ER_MEMORY = 14

Memory allocation failure http://php.net/manual/en/zip.constants.php

const ZipArchive::ER_MULTIDISK = 1

Multi-disk zip archives not supported. http://php.net/manual/en/zip.constants.php

const ZipArchive::ER_NOENT = 9
const ZipArchive::ER_NOZIP = 19
const ZipArchive::ER_OK = 0
const ZipArchive::ER_OPEN = 11
const ZipArchive::ER_READ = 5
const ZipArchive::ER_REMOVE = 22
const ZipArchive::ER_RENAME = 2

Renaming temporary file failed. http://php.net/manual/en/zip.constants.php

const ZipArchive::ER_SEEK = 4
const ZipArchive::ER_TMPOPEN = 12
const ZipArchive::ER_WRITE = 6
const ZipArchive::ER_ZIPCLOSED = 8

Containing zip archive was closed http://php.net/manual/en/zip.constants.php

const ZipArchive::ER_ZLIB = 13
const ZipArchive::EXCL = 2
const ZipArchive::FL_COMPRESSED = 4
const ZipArchive::FL_NOCASE = 1

Ignore case on name lookup http://php.net/manual/en/zip.constants.php

const ZipArchive::FL_NODIR = 2

Ignore directory component http://php.net/manual/en/zip.constants.php

const ZipArchive::FL_UNCHANGED = 8

Use original data, ignoring changes. http://php.net/manual/en/zip.constants.php

const ZipArchive::OVERWRITE = 8

Always start a new archive, this mode will overwrite the file if it already exists. http://php.net/manual/en/zip.constants.php


The documentation for this class was generated from the following file: