Archive: ezcArchiveZip
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcArchiveZip
|
The ezcArchiveZip class implements the Zip archive format. [
source]
Implemented Interfaces
- Iterator (internal interface)
ezcArchiveZip is a subclass from
ezcArchive that provides the common interface. Zip algorithm specific methods are implemented in this class.
ezcArchiveZip tries on creation to read the entire archive. Every
ezcArchiveEntry will be appended to the
ezcArchive::$entries array. (ezcArchiveTarV7 archive format reads only anentry when needed the first time.)
All the archive entries are read, because we need to find the ezcArchiveCentralDirectoryHeader that contains extra file information. Some other Zip implementations search back from the end of the archive, but:
- Not all of them take the comment section at the end of the archive into account.
- The file pointer can only forward, so they seek over the entire archive anyway.
The current implementation can handle Non-Zip64 archives. The following extra Zip information can be read:
- The Unix Extra field.
- The Unix Extra field 2.
- The Universal Timestamp field.
Parents
ezcArchive
|
--ezcArchiveZip
Inherited Constants
From
ezcArchive:
Member Variables
|
protected array(int) |
$centralHeaderPositions
Stores the byte number where the central directory header starts (fileNumber is the index of the array). |
|
protected array(ezcArchiveCentralDirectoryHeader) |
$centralHeaders
Stores the ezcArchiveCentralDirectoryHeader for each entry. |
|
protected ezcArchiveCentralDirectoryEndHeader |
$endRecord
Stores the ezcArchiveCentralDirectoryEndHeader. |
|
protected array(int) |
$localHeaderPositions
Stores the byte number where the local file header starts for each entry. |
|
protected array(ezcArchiveLocalFileHeader) |
$localHeaders
Stores the ezcArchiveLocalFileHeader for each entry. |
Inherited Member Variables
From
ezcArchive:
Method Summary
|
public ezcArchiveZip |
__construct(
$file )
Initializes the Zip archive and reads the entire archive. |
|
public void |
algorithmCanWrite(
)
|
|
public void |
appendToCurrent(
$files, $prefix )
|
|
public void |
getAlgorithm(
)
|
|
public string |
getFileData(
$fileNumber )
Returns the file data of the given fileNumber. |
|
protected void |
readEntireArchive(
)
Reads the entire archive and creates all the entries. |
|
protected void |
setEndRecord(
)
Creates and sets a new ezcArchiveCentralDirectoryEndHeader. |
|
public void |
truncate(
[$fileNumber = 0] )
|
|
protected void |
writeCurrentDataToFile(
$targetPath )
|
|
public void |
writeFile(
$fileNumber, $writeTo )
Reads the file data from the archive and writes it the the $writeTo file. |
Inherited Methods
From
ezcArchive :
Methods
__construct
ezcArchiveZip __construct(
$file )
Initializes the Zip archive and reads the entire archive.
The constructor opens the archive as a ezcArchiveCharacterFile.
algorithmCanWrite
void algorithmCanWrite(
)
Redefinition of
appendToCurrent
void appendToCurrent(
$files,
$prefix )
Parameters
| Name |
Type |
Description |
$files |
|
|
$prefix |
|
|
Redefinition of
getAlgorithm
void getAlgorithm(
)
Redefinition of
getFileData
string getFileData(
int
$fileNumber )
Returns the file data of the given fileNumber.
This method doesn't handle compression and reads the whole file in memory. This method is used to get the symbolic links, since these are stored in files.
For larger or compressed files, use the
writeFile() method.
Parameters
| Name |
Type |
Description |
$fileNumber |
int |
|
readEntireArchive
void readEntireArchive(
)
Reads the entire archive and creates all the entries.
To find the central directory structure we need to read all the headers. Some algorithms search backwards, but these don't expect comments.
The central directory structure gives us extra information about the stored file like: symlinks and permissions.
setEndRecord
void setEndRecord(
)
Creates and sets a new ezcArchiveCentralDirectoryEndHeader.
The new ezcArchiveCentralDirectoryEndHeader is based on the current file position, the centralHeaderPositions, and the number of entries read.
truncate
void truncate(
[
$fileNumber = 0] )
Parameters
| Name |
Type |
Description |
$fileNumber |
|
|
Redefinition of
writeCurrentDataToFile
void writeCurrentDataToFile(
$targetPath )
Parameters
| Name |
Type |
Description |
$targetPath |
|
|
Redefinition of
writeFile
void writeFile(
int
$fileNumber, string
$writeTo )
Reads the file data from the archive and writes it the the $writeTo file.
The data from the entry with $fileNumber is read from the archive. If the data is compressed or deflated it will be, respectively, decompressed or inflated.
Parameters
| Name |
Type |
Description |
$fileNumber |
int |
|
$writeTo |
string |
|
Throws
| Class | Description |
ezcArchiveChecksumException |
if the checksum is invalid from the created file. |
Last updated: Wed, 28 Nov 2007