Documentation

ZipFile
in package

ZipFile

This file contains the ZipFile class

Table of Contents

Properties

$ctrl_dir  : array<string|int, mixed>
Central directory
$datasec  : array<string|int, mixed>
Array to store compressed data
$doWrite  : bool
Whether to echo zip as it's built or return as string from -> file
$eof_ctrl_dir  : string
End of central directory record
$old_offset  : int
Last offset position

Methods

addFile()  : void
Adds "file" to archive
file()  : string
Echo central dir if ->doWrite==true, else build string to return
setDoWrite()  : void
Sets member variable this -> doWrite to true - Should be called immediately after class instantiation - If set to true, then ZIP archive are echo'ed to STDOUT as each file is added via this -> addfile(), and central directories are echoed to STDOUT on final call to this -> file(). Also, this -> file() returns an empty string so it is safe to issue a "echo $zipfile;" command
unix2DosTime()  : int
Converts an Unix timestamp to a four byte DOS date and time format (date in high two bytes, time in low two bytes allowing magnitude comparison).

Properties

$ctrl_dir

Central directory

public array<string|int, mixed> $ctrl_dir = array()

$datasec

Array to store compressed data

public array<string|int, mixed> $datasec = array()

$doWrite

Whether to echo zip as it's built or return as string from -> file

public bool $doWrite = \false

$eof_ctrl_dir

End of central directory record

public string $eof_ctrl_dir = "PK\x05\x06\x00\x00\x00\x00"

$old_offset

Last offset position

public int $old_offset = 0

Methods

addFile()

Adds "file" to archive

public addFile(string $data, string $name[, int $time = 0 ]) : void
Parameters
$data : string

file contents

$name : string

name of the file in the archive (may contains the path)

$time : int = 0

the current timestamp

Tags
access

public

file()

Echo central dir if ->doWrite==true, else build string to return

public file() : string
Tags
access

public

Return values
string

if ->doWrite {empty string} else the ZIP file contents

setDoWrite()

Sets member variable this -> doWrite to true - Should be called immediately after class instantiation - If set to true, then ZIP archive are echo'ed to STDOUT as each file is added via this -> addfile(), and central directories are echoed to STDOUT on final call to this -> file(). Also, this -> file() returns an empty string so it is safe to issue a "echo $zipfile;" command

public setDoWrite() : void
Tags
access

public

unix2DosTime()

Converts an Unix timestamp to a four byte DOS date and time format (date in high two bytes, time in low two bytes allowing magnitude comparison).

public unix2DosTime([int $unixtime = 0 ]) : int
Parameters
$unixtime : int = 0

the current Unix timestamp

Tags
access

private

Return values
int

the current date in a four byte DOS format


        
On this page

Search results