My Project
 All Data Structures Namespaces Functions Variables
Public Member Functions | Data Fields
CI_Zip Class Reference

Public Member Functions

 __construct ()
 
 add_dir ($directory)
 
 _get_mod_time ($dir)
 
 _add_dir ($dir, $file_mtime, $file_mdate)
 
 add_data ($filepath, $data=NULL)
 
 _add_data ($filepath, $data, $file_mtime, $file_mdate)
 
 read_file ($path, $preserve_filepath=FALSE)
 
 read_dir ($path, $preserve_filepath=TRUE, $root_path=NULL)
 
 get_zip ()
 
 archive ($filepath)
 
 download ($filename= 'backup.zip')
 
 clear_data ()
 

Data Fields

 $zipdata = ''
 
 $directory = ''
 
 $entries = 0
 
 $file_num = 0
 
 $offset = 0
 
 $now
 

Constructor & Destructor Documentation

__construct ( )

Constructor

Member Function Documentation

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

Add Data to Zip

private

Parameters
stringthe file name/path
stringthe data to be encoded
Returns
void
_add_dir (   $dir,
  $file_mtime,
  $file_mdate 
)

Add Directory

private

Parameters
stringthe directory name
Returns
void
_get_mod_time (   $dir)

Get file/directory modification time

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

Parameters
stringpath to file
Returns
array filemtime/filemdate
add_data (   $filepath,
  $data = NULL 
)

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.

public

Parameters
mixed
string
Returns
void
add_dir (   $directory)

Add Directory

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

public

Parameters
mixedthe directory name. Can be string or array
Returns
void
archive (   $filepath)

Write File to the specified directory

Lets you write a file

public

Parameters
stringthe file name
Returns
bool
clear_data ( )

Initialize Data

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

public

Returns
void
download (   $filename = 'backup.zip')

Download

public

Parameters
stringthe file name
stringthe data to be encoded
Returns
bool
get_zip ( )

Get the Zip file

public

Returns
binary string
read_dir (   $path,
  $preserve_filepath = TRUE,
  $root_path = NULL 
)

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.

public

Parameters
stringpath to source
Returns
bool
read_file (   $path,
  $preserve_filepath = FALSE 
)

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

public

Returns
bool

The documentation for this class was generated from the following file: