-
Notifications
You must be signed in to change notification settings - Fork 0
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:
public string $zipdata = ''
Zip data in string form
- Visibility: public
public string $directory = ''
Zip data for a directory in string form
- Visibility: public
public integer $entries
Number of files/folder in zip file
- Visibility: public
public integer $file_num
Number of files in zip
- Visibility: public
public integer $offset
relative offset of local header
- Visibility: public
public integer $now
Reference to time at init
- Visibility: public
public integer $compression_level = 2
The level of compression
Ranges from 0 to 9, with 9 being the highest level.
- Visibility: public
void CI_Zip::__construct()
Initialize zip compression class
- Visibility: public
void CI_Zip::add_dir(mixed $directory)
Add Directory
Lets you add a virtual directory into which you can place files.
- Visibility: public
- $directory mixed - <p>the directory name. Can be string or array</p>
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
- $dir string - <p>path to file</p>
void CI_Zip::_add_dir(string $dir, integer $file_mtime, integer $file_mdate)
Add Directory
- Visibility: protected
- $dir string - <p>the directory name</p>
- $file_mtime integer
- $file_mdate integer
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
- $filepath mixed - <p>A single filepath or an array of file => data pairs</p>
- $data string - <p>Single file contents</p>
void CI_Zip::_add_data(string $filepath, string $data, integer $file_mtime, integer $file_mdate)
Add Data to Zip
- Visibility: protected
- $filepath string - <p>the file name/path</p>
- $data string - <p>the data to be encoded</p>
- $file_mtime integer
- $file_mdate integer
boolean CI_Zip::read_file(string $path, boolean $archive_filepath)
Read the contents of a file and add it to the zip
- Visibility: public
- $path string
- $archive_filepath boolean
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
- $path string - <p>path to source directory</p>
- $preserve_filepath boolean
- $root_path string
string CI_Zip::get_zip()
Get the Zip file
- Visibility: public
boolean CI_Zip::archive(string $filepath)
Write File to the specified directory
Lets you write a file
- Visibility: public
- $filepath string - <p>the file name</p>
void CI_Zip::download(string $filename)
Download
- Visibility: public
- $filename string - <p>the file name</p>
\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