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 * Class name: CI_Zip * Namespace: Properties ---------- ### $zipdata public string $zipdata = '' Zip data in string form * Visibility: **public** ### $directory public string $directory = '' Zip data for a directory in string form * Visibility: **public** ### $entries public integer $entries Number of files/folder in zip file * Visibility: **public** ### $file_num public integer $file_num Number of files in zip * Visibility: **public** ### $offset public integer $offset relative offset of local header * Visibility: **public** ### $now public integer $now Reference to time at init * Visibility: **public** ### $compression_level public integer $compression_level = 2 The level of compression Ranges from 0 to 9, with 9 being the highest level. * Visibility: **public** Methods ------- ### __construct void CI_Zip::__construct() Initialize zip compression class * Visibility: **public** ### add_dir void CI_Zip::add_dir(mixed $directory) Add Directory Lets you add a virtual directory into which you can place files. * Visibility: **public** #### Arguments * $directory **mixed** - <p>the directory name. Can be string or array</p> ### _get_mod_time array CI_Zip::_get_mod_time(string $dir) Get file/directory modification time If this is a newly created file/dir, we will set the time to 'now' * Visibility: **protected** #### Arguments * $dir **string** - <p>path to file</p> ### _add_dir void CI_Zip::_add_dir(string $dir, integer $file_mtime, integer $file_mdate) Add Directory * Visibility: **protected** #### Arguments * $dir **string** - <p>the directory name</p> * $file_mtime **integer** * $file_mdate **integer** ### add_data void CI_Zip::add_data(mixed $filepath, string $data) 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. * Visibility: **public** #### Arguments * $filepath **mixed** - <p>A single filepath or an array of file => data pairs</p> * $data **string** - <p>Single file contents</p> ### _add_data void CI_Zip::_add_data(string $filepath, string $data, integer $file_mtime, integer $file_mdate) Add Data to Zip * Visibility: **protected** #### Arguments * $filepath **string** - <p>the file name/path</p> * $data **string** - <p>the data to be encoded</p> * $file_mtime **integer** * $file_mdate **integer** ### read_file boolean CI_Zip::read_file(string $path, boolean $archive_filepath) Read the contents of a file and add it to the zip * Visibility: **public** #### Arguments * $path **string** * $archive_filepath **boolean** ### read_dir boolean CI_Zip::read_dir(string $path, boolean $preserve_filepath, string $root_path) 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. * Visibility: **public** #### Arguments * $path **string** - <p>path to source directory</p> * $preserve_filepath **boolean** * $root_path **string** ### get_zip string CI_Zip::get_zip() Get the Zip file * Visibility: **public** ### archive boolean CI_Zip::archive(string $filepath) Write File to the specified directory Lets you write a file * Visibility: **public** #### Arguments * $filepath **string** - <p>the file name</p> ### download void CI_Zip::download(string $filename) Download * Visibility: **public** #### Arguments * $filename **string** - <p>the file name</p> ### clear_data \CI_Zip CI_Zip::clear_data() Initialize Data Lets you clear current zip data. Useful if you need to create multiple zips with different data. * Visibility: **public**