PHP 클래스 CI_Zip, TastyIgniter

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
저자: EllisLab Dev Team
파일 보기 프로젝트 열기: tastyigniter/tastyigniter 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$compression_level integer Ranges from 0 to 9, with 9 being the highest level.
$directory string Zip data for a directory in string form
$entries integer Number of files/folder in zip file
$file_num integer Number of files in zip
$now integer Reference to time at init
$offset integer relative offset of local header
$zipdata string Zip data in string form

공개 메소드들

메소드 설명
__construct ( ) : void Initialize zip compression class
add_data ( mixed $filepath, string $data = NULL ) : void Add Data to Zip
add_dir ( mixed $directory ) : void Add Directory
archive ( string $filepath ) : boolean Write File to the specified directory
clear_data ( ) : CI_Zip Initialize Data
download ( string $filename = 'backup.zip' ) : void Download
get_zip ( ) : string Get the Zip file
read_dir ( string $path, boolean $preserve_filepath = TRUE, string $root_path = NULL ) : boolean Read a directory and add it to the zip.
read_file ( string $path, boolean $archive_filepath = FALSE ) : boolean Read the contents of a file and add it to the zip

보호된 메소드들

메소드 설명
_add_data ( string $filepath, string $data, integer $file_mtime, integer $file_mdate ) : void Add Data to Zip
_add_dir ( string $dir, integer $file_mtime, integer $file_mdate ) : void Add Directory
_get_mod_time ( string $dir ) : array Get file/directory modification time

메소드 상세

__construct() 공개 메소드

Initialize zip compression class
public __construct ( ) : void
리턴 void

_add_data() 보호된 메소드

Add Data to Zip
protected _add_data ( string $filepath, string $data, integer $file_mtime, integer $file_mdate ) : void
$filepath string the file name/path
$data string the data to be encoded
$file_mtime integer
$file_mdate integer
리턴 void

_add_dir() 보호된 메소드

Add Directory
protected _add_dir ( string $dir, integer $file_mtime, integer $file_mdate ) : void
$dir string the directory name
$file_mtime integer
$file_mdate integer
리턴 void

_get_mod_time() 보호된 메소드

If this is a newly created file/dir, we will set the time to 'now'
protected _get_mod_time ( string $dir ) : array
$dir string path to file
리턴 array filemtime/filemdate

add_data() 공개 메소드

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.
public add_data ( mixed $filepath, string $data = NULL ) : void
$filepath mixed A single filepath or an array of file => data pairs
$data string Single file contents
리턴 void

add_dir() 공개 메소드

Lets you add a virtual directory into which you can place files.
public add_dir ( mixed $directory ) : void
$directory mixed the directory name. Can be string or array
리턴 void

archive() 공개 메소드

Lets you write a file
public archive ( string $filepath ) : boolean
$filepath string the file name
리턴 boolean

clear_data() 공개 메소드

Lets you clear current zip data. Useful if you need to create multiple zips with different data.
public clear_data ( ) : CI_Zip
리턴 CI_Zip

download() 공개 메소드

Download
public download ( string $filename = 'backup.zip' ) : void
$filename string the file name
리턴 void

get_zip() 공개 메소드

Get the Zip file
public get_zip ( ) : string
리턴 string (binary encoded)

read_dir() 공개 메소드

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.
public read_dir ( string $path, boolean $preserve_filepath = TRUE, string $root_path = NULL ) : boolean
$path string path to source directory
$preserve_filepath boolean
$root_path string
리턴 boolean

read_file() 공개 메소드

Read the contents of a file and add it to the zip
public read_file ( string $path, boolean $archive_filepath = FALSE ) : boolean
$path string
$archive_filepath boolean
리턴 boolean

프로퍼티 상세

$compression_level 공개적으로 프로퍼티

Ranges from 0 to 9, with 9 being the highest level.
public int $compression_level
리턴 integer

$directory 공개적으로 프로퍼티

Zip data for a directory in string form
public string $directory
리턴 string

$entries 공개적으로 프로퍼티

Number of files/folder in zip file
public int $entries
리턴 integer

$file_num 공개적으로 프로퍼티

Number of files in zip
public int $file_num
리턴 integer

$now 공개적으로 프로퍼티

Reference to time at init
public int $now
리턴 integer

$offset 공개적으로 프로퍼티

relative offset of local header
public int $offset
리턴 integer

$zipdata 공개적으로 프로퍼티

Zip data in string form
public string $zipdata
리턴 string