Overview Package | SS_ZIP class |
FRAMES NO FRAMES | |
SUMMARY: FIELD METHOD | DETAIL: FIELD METHOD |
SS_ZIP.ss_zip
class ss_zip
SS_ZIP class is designed to work with ZIP archives
Field Summary |
---|
public var | $zipfile contains whole zipfile |
public var | $complevel compression level |
public var | $cnt entry counter |
public var | $offset current offset in zipdata segment |
public var | $idx index of current entry |
public var | $zipdata ZipData segment, each element of this array contains local file header plus zipped data |
public var | $cdir central directory array |
Method Summary |
---|
public void | ss_zip constructor |
public void | clear Resets the objec, clears all the structures |
public void | open opens zip file. |
public void | save saves to the disc or sends zipfile to the browser. |
public void | add_data adds data to zip file |
public void | add_file adds a file to the archive |
public str | archive compile the arcive. |
public int | seek_idx changes pointer to current entry. |
public array | read Reads an entry from the arcive which is pointed by inner index pointer. |
public bool | remove Removes entry from the archive. |
public array | extract_data extracts data from the archive and return it as a string. |
public void | extract_file extracts the entry and creates it in the file system. |
private void | _check_idx |
private void | _write |
Field Detail |
---|
public var $zipfile = ""
contains whole zipfile
public var $complevel = 6
compression level
public var $cnt
entry counter
public var $offset
current offset in zipdata segment
public var $idx
index of current entry
public var $zipdata = array()
ZipData segment, each element of this array contains local file header plus zipped data
public var $cdir = array()
central directory array
Method Detail |
---|
public void ss_zip(string zipfile = "", int complevel = 6)
constructor
zipfile
- if not empty must contain path to valid zip file, ss_zip will try to open and parse it. If this parameter is empty, the new empty zip archive is created. This parameter has no meaning in LIGHT verion, please upgrade to PROfessional version. complevel
- compression level, 1-minimal compression, 9-maximal, default is 6 public void clear()
Resets the objec, clears all the structures
public void open(str zipfile, bool append = false)
opens zip file.
zipfile
- path to the file append
- if true the newlly opened archive will be appended to existing object structure public void save(str zipfile, char where = 'f')
saves to the disc or sends zipfile to the browser.
zipfile
- path under which to store the file on the server or file name under which the browser will receive it. If you are saving to the server, you are responsible to obtain appropriate write permissions for this operation. where
- indicates where should the file be sent public void add_data(str filename, str data = null)
adds data to zip file
filename
- path under which the content of data parameter will be stored into the zip archive data
- content to be stored under name given by path parameter public void add_file(str filename, str storedasname = "")
adds a file to the archive
filename
- contains valid path to file to be stored in the arcive. storedasname
- the path under which the file will be stored to the archive. If empty, the file will be stored under path given by filename parameter public str archive()
compile the arcive.
This function produces ZIP archive and returns it.
public int seek_idx(int idx)
changes pointer to current entry.
Most likely you will always use it to 'rewind' the archive and then using read() Checks for bopundaries, so will not allow index to be set to values < 0 ro > last element
idx
- the new index to which you want to rewind the archive curent pointer public array read()
Reads an entry from the arcive which is pointed by inner index pointer.
public bool remove(int idx)
Removes entry from the archive.
please be very carefull with this function, there is no undo after you save the archive
idx
public array extract_data(int idx)
extracts data from the archive and return it as a string.
idx
- index of the entry public void extract_file(int idx, string path = ".")
extracts the entry and creates it in the file system.
idx
- Index of the entry path
- the first part of the path where the entry will be stored. So if this is '/my/server/path' and entry is arhived/file/path/file.txt then the function will attempt to store it under /my/server/path/arhived/file/path/file.txt You are responsible to ensure that you have write permissions for this operation under your operation system. private void _check_idx(var $idx)
$idx
private void _write(var $name, var $data)
$name
$data
Overview Package | SS_ZIP class |
FRAMES NO FRAMES | |
SUMMARY: FIELD METHOD | DETAIL: FIELD METHOD |