PHP Class Contao\ZipWriter

Usage: $zip = new ZipWriter('test.zip'); $zip->addFile('test.txt'); $zip->close();
ファイルを表示 Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$intCount integer File count
$resFile resource File handle
$strCentralDir string Central directory
$strFile resource File name
$strTemp resource Temporary name

Public Methods

Method Description
__construct ( string $strFile ) Create a new zip archive
__destruct ( ) Close the file handle if it has not been done yet
addFile ( string $strFile, string $strName = null ) Add a file to the archive
addString ( string $strData, string $strName, integer $intTime ) Add a file from a string to the archive
close ( ) Write the central directory and close the file handle

Protected Methods

Method Description
unixToHex ( integer $intTime ) : integer Convert a Unix timestamp to a hexadecimal value

Method Details

__construct() public method

Create a new zip archive
public __construct ( string $strFile )
$strFile string The file path

__destruct() public method

Close the file handle if it has not been done yet
public __destruct ( )

addFile() public method

Add a file to the archive
public addFile ( string $strFile, string $strName = null )
$strFile string The file path
$strName string An optional file name

addString() public method

Add a file from a string to the archive
public addString ( string $strData, string $strName, integer $intTime )
$strData string The data to be added
$strName string The file path
$intTime integer An optional modification timestamp

close() public method

Write the central directory and close the file handle
public close ( )

unixToHex() protected method

Convert a Unix timestamp to a hexadecimal value
protected unixToHex ( integer $intTime ) : integer
$intTime integer The Unix timestamp
return integer The hexadecimal value

Property Details

$intCount protected_oe property

File count
protected int $intCount
return integer

$resFile protected_oe property

File handle
protected resource $resFile
return resource

$strCentralDir protected_oe property

Central directory
protected string $strCentralDir
return string

$strFile protected_oe property

File name
protected resource $strFile
return resource

$strTemp protected_oe property

Temporary name
protected resource $strTemp
return resource