Zip file archive class.
More...
|
| __construct () |
| Create new zip_archive instance.
|
|
| add_directory ($localname) |
| Add empty directory into archive.
|
|
| add_file_from_pathname ($localname, $pathname) |
| Add file into archive.
|
|
| add_file_from_string ($localname, $contents) |
| Add content of string into archive.
|
|
| close () |
| Close archive, write changes to disk.
|
|
| count () |
| Returns number of files in archive.
|
|
| current () |
| Returns current file info.
|
|
| estimated_count () |
| Returns approximate number of files in archive.
|
|
| extract_to ($destination, $index) |
| Extract the archive contents to the given location.
|
|
| get_info ($index) |
| Returns file information.
|
|
| get_stream ($index) |
| Returns file stream for reading of content.
|
|
| is_system_file ($fileinfo) |
|
| key () |
| Returns the index of current file.
|
|
| list_files () |
| Returns array of info about all files in archive.
|
|
| next () |
| Moves forward to next file.
|
|
| open ($archivepathname, $mode=file_archive::CREATE, $encoding=null) |
| Open or create archive (depending on $mode).
|
|
| rewind () |
| Rewinds back to the first file.
|
|
| valid () |
| Did we reach the end?
|
|
|
static | zip_get_central_end ($fp, $filesize) |
| Read end of central signature of ZIP file.
|
|
static | zip_parse_file_header ($data, $centralend, &$pos) |
| Parse file header.
|
|
|
const | CREATE = 2 |
| Open archive if exists, create if does not.
|
|
const | OPEN = 1 |
| Open archive if exists, fail if does not exist.
|
|
const | OVERWRITE = 4 |
| Always create new archive.
|
|
|
| fix_utf8_flags () |
| Add unicode flag to all files in archive.
|
|
| init_namelookup () |
| Create a map of file names used in zip archive.
|
|
| mangle_pathname ($localname) |
| Normalize $localname, always keep in utf-8 encoding.
|
|
| unmangle_pathname ($localname) |
| Tries to convert $localname into utf-8 please note that it may fail really badly.
|
|
|
string | $archivepathname = null |
| Pathname of archive.
|
|
bool | $emptyziphack = false |
| ugly hack for broken empty zip handling in < PHP 5.3.10
|
|
string | $encoding = 'utf-8' |
| Encoding of file names - windows usually expects DOS single-byte charset.
|
|
int | $mode = null |
| archive open mode
|
|
bool | $modified = false |
| was this archive modified?
|
|
array | $namelookup = null |
| unicode decoding array, created by decoding zip file
|
|
int | $pos = 0 |
| Iteration position.
|
|
int | $usedmem = 0 |
| Used memory tracking.
|
|
ZipArchive | $za |
| instance
|
|
|
static string | $emptyzipcontent = 'UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA==' |
| base64 encoded contents of empty zip file
|
|
Zip file archive class.
- Copyright
- 2008 Petr Skoda (http://skodak.org)
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ add_directory()
zip_archive::add_directory |
( |
| $localname | ) |
|
Add empty directory into archive.
- Parameters
-
string | $localname | name of file in archive |
- Return values
-
Reimplemented from file_archive.
◆ add_file_from_pathname()
zip_archive::add_file_from_pathname |
( |
| $localname, |
|
|
| $pathname ) |
Add file into archive.
- Parameters
-
string | $localname | name of file in archive |
string | $pathname | location of file |
- Return values
-
Reimplemented from file_archive.
◆ add_file_from_string()
zip_archive::add_file_from_string |
( |
| $localname, |
|
|
| $contents ) |
Add content of string into archive.
- Parameters
-
string | $localname | name of file in archive |
string | $contents | contents |
- Return values
-
Reimplemented from file_archive.
◆ close()
Close archive, write changes to disk.
- Return values
-
Reimplemented from file_archive.
◆ count()
Returns number of files in archive.
- Return values
-
Reimplemented from file_archive.
◆ current()
Returns current file info.
- Return values
-
◆ estimated_count()
zip_archive::estimated_count |
( |
| ) |
|
Returns approximate number of files in archive.
This may be a slight overestimate.
- Return values
-
int|bool | Estimated number of files, or false if not opened |
◆ extract_to()
zip_archive::extract_to |
( |
| $destination, |
|
|
| $index ) |
Extract the archive contents to the given location.
- Parameters
-
string | $destination | Path to the location where to extract the files. |
int | $index | Index of the archive entry. |
- Return values
-
bool | true on success or false on failure |
◆ fix_utf8_flags()
zip_archive::fix_utf8_flags |
( |
| ) |
|
|
protected |
Add unicode flag to all files in archive.
NOTE: single disk archives only, no ZIP64 support.
- Return values
-
bool | success, modifies the file contents |
◆ get_info()
zip_archive::get_info |
( |
| $index | ) |
|
Returns file information.
- Parameters
-
- Return values
-
stdClass|bool | info object or false if error |
Reimplemented from file_archive.
◆ get_stream()
zip_archive::get_stream |
( |
| $index | ) |
|
Returns file stream for reading of content.
- Parameters
-
- Return values
-
resource|bool | file handle or false if error |
Reimplemented from file_archive.
◆ init_namelookup()
zip_archive::init_namelookup |
( |
| ) |
|
|
protected |
Create a map of file names used in zip archive.
- Return values
-
◆ key()
Returns the index of current file.
- Return values
-
◆ list_files()
zip_archive::list_files |
( |
| ) |
|
Returns array of info about all files in archive.
- Return values
-
Reimplemented from file_archive.
◆ mangle_pathname()
zip_archive::mangle_pathname |
( |
| $localname | ) |
|
|
protected |
Normalize $localname, always keep in utf-8 encoding.
- Parameters
-
string | $localname | name of file in utf-8 encoding |
- Return values
-
string | normalised compressed file or directory name |
Reimplemented from file_archive.
◆ open()
Open or create archive (depending on $mode).
- Todo
- MDL-31048 return error message
- Parameters
-
string | $archivepathname | |
int | $mode | OPEN, CREATE or OVERWRITE constant |
string | $encoding | archive local paths encoding, empty means autodetect |
- Return values
-
Reimplemented from file_archive.
◆ unmangle_pathname()
zip_archive::unmangle_pathname |
( |
| $localname | ) |
|
|
protected |
Tries to convert $localname into utf-8 please note that it may fail really badly.
The resulting file name is cleaned.
- Parameters
-
string | $localname | name (encoding is read from zip file or guessed) |
- Return values
-
Reimplemented from file_archive.
◆ valid()
Did we reach the end?
- Return values
-
The documentation for this class was generated from the following file:
- lib/filestorage/zip_archive.php