\CI_Zip

Zip Compression Class

This class is based on a library I found at Zend: http://www.zend.com/codex.php?id=696&single=1

The original library is a little rough around the edges so I refactored it and added several additional methods -- Rick Ellis

Summary

Methods
Properties
Constants
__construct()
add_dir()
_get_mod_time()
_add_dir()
add_data()
_add_data()
read_file()
read_dir()
get_zip()
archive()
download()
clear_data()
$zipdata
$directory
$entries
$file_num
$offset
$now
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$zipdata

$zipdata : 

Type

$directory

$directory : 

Type

$entries

$entries : 

Type

$file_num

$file_num : 

Type

$offset

$offset : 

Type

$now

$now : 

Type

Methods

__construct()

__construct() 

Constructor

add_dir()

add_dir(  $directory) : void

Add Directory

Lets you add a virtual directory into which you can place files.

Parameters

$directory

_get_mod_time()

_get_mod_time(  $dir) : array

Get file/directory modification time

If this is a newly created file/dir, we will set the time to 'now'

Parameters

$dir

Returns

array —

filemtime/filemdate

_add_dir()

_add_dir(  $dir,   $file_mtime,   $file_mdate) : void

Add Directory

Parameters

$dir
$file_mtime
$file_mdate

add_data()

add_data(  $filepath,   $data = NULL) : void

Add Data to Zip

Lets you add files to the archive. If the path is included in the filename it will be placed within a directory. Make sure you use add_dir() first to create the folder.

Parameters

$filepath
$data

_add_data()

_add_data(  $filepath,   $data,   $file_mtime,   $file_mdate) : void

Add Data to Zip

Parameters

$filepath
$data
$file_mtime
$file_mdate

read_file()

read_file(  $path,   $preserve_filepath = FALSE) : boolean

Read the contents of a file and add it to the zip

Parameters

$path
$preserve_filepath

Returns

boolean

read_dir()

read_dir(  $path,   $preserve_filepath = TRUE,   $root_path = NULL) : boolean

Read a directory and add it to the zip.

This function recursively reads a folder and everything it contains (including sub-folders) and creates a zip based on it. Whatever directory structure is in the original file path will be recreated in the zip file.

Parameters

$path
$preserve_filepath
$root_path

Returns

boolean

get_zip()

get_zip() : \binary

Get the Zip file

Returns

\binary —

string

archive()

archive(  $filepath) : boolean

Write File to the specified directory

Lets you write a file

Parameters

$filepath

Returns

boolean

download()

download(  $filename = 'backup.zip') : boolean

Download

Parameters

$filename

Returns

boolean

clear_data()

clear_data() : void

Initialize Data

Lets you clear current zip data. Useful if you need to create multiple zips with different data.