Zip

This class intends to help people use the CBZip in an easy way.  CBZip brings the power of zip archives to asp.

Requirements

  • CrazyBeavers Zip exe (CBZip.exe)

About

Summary
Zip
This class intends to help people use the CBZip in an easy way.
This should be the URI to CBZip.exe including http:// etc.
The zip filename with extension.
This is the container of all Zip_File objects.
go
Parses the zip file and create the Zip_File objects.
Extract the files in the standard way.
Extract the files without caring about their relative path inside the zip.
Retrive a view from inside the zip.
Each entry of Zip.Files contains an object of this class.
Relative path plus the filename with it extension.
Compression method.
The size of the file when it’s compressed.
The size of the file.
Compression effectiveness.
The CRC32 code which is a 32 bits length hash.
A flag indicating if the entry is a folder or not.
uri
Uri for downloading the file.
Retrieve the file name.
Retrieve the file extension.
Save the file to the hard drive.

Properties

cbZipUri

This should be the URI to CBZip.exe including http:// etc.

Contains

(string) URI

zipName

The zip filename with extension.

Contains

(string) Filename

Files

This is the container of all Zip_File objects.

Contains

(scripting.dictionary) Collection with the Zip_File’s

Functions

go

public sub go()

Parses the zip file and create the Zip_File objects.

extract

public sub extract( sTargetPath )

Extract the files in the standard way.

Parameters

(string)sTargetPath Virtual Path where you intend to save your extracted files.

Example

dim oZip
set oZip = new Zip
oZip.cbZipUri = "http://localhost/cgi-bin/CBZIP.exe"
oZip.zipName = Server.mapPath("docs.zip")
call oZip.go()
oZip.extract("files/") 'Remember that "files/" must exist before calling the extract.
set oZip = nothing

extractWithoutFolders

public sub extractWithoutFolders( sTargetPath )

Extract the files without caring about their relative path inside the zip.

Parameters

(string)sTargetPath Virtual Path where you intend to save your extracted files.

Example

dim oZip
set oZip = new Zip
oZip.cbZipUri = "http://localhost/cgi-bin/CBZIP.exe"
oZip.zipName = Server.mapPath("docs.zip")
call oZip.go()
oZip.extractWithoutFolders("files/") 'Remember that "files/" must exist before calling the extract.
set oZip = nothing

inspect

public function inspect()

Retrive a view from inside the zip.

Returns

(string) HTML table with the zip contents

Example

dim oZip
set oZip = new Zip
oZip.cbZipUri = "http://localhost/cgi-bin/CBZIP.exe"
oZip.zipName = Server.mapPath("docs.zip")
call oZip.go()
Response.write(oZip.inspect())
set oZip = nothing

Zip_File

Each entry of Zip.Files contains an object of this class.  This is the class that the user should use to retrieve information from a file in the zip.

About

Summary
Relative path plus the filename with it extension.
Compression method.
The size of the file when it’s compressed.
The size of the file.
Compression effectiveness.
The CRC32 code which is a 32 bits length hash.
A flag indicating if the entry is a folder or not.
uri
Uri for downloading the file.
Retrieve the file name.
Retrieve the file extension.
Save the file to the hard drive.

Properties

name

Relative path plus the filename with it extension.

Contains

(string) File full path.

compMethod

Compression method.

Contains

(string) Stored, Deflated, etc

compSize

The size of the file when it’s compressed.

Contains

(int) Compressed file size

uncompSize

The size of the file.

Contains

(int) File size

compRatio

Compression effectiveness.

Contains

(int) Compression ratio

crc32

The CRC32 code which is a 32 bits length hash.

Contains

(hex) CRC32

isFolder

A flag indicating if the entry is a folder or not.

Contains

true if it’s a folder
false otherwise

uri

Uri for downloading the file.

Contains

(string) Href to download the file

Functions

fileName

public function fileName()

Retrieve the file name.

Returns

(string) File name

fileExt

public function fileExt()

Retrieve the file extension.

Returns

(string) File extension

saveToFile

public function saveToFile( sPath )

Save the file to the hard drive.

Parameters

(string)sPath Full path

Returns

true if it’s successfully saved
false otherwise
public sub go()
Parses the zip file and create the Zip_File objects.
public sub extract( sTargetPath )
Extract the files in the standard way.
public sub extractWithoutFolders( sTargetPath )
Extract the files without caring about their relative path inside the zip.
public function inspect()
Retrive a view from inside the zip.
public function fileName()
Retrieve the file name.
public function fileExt()
Retrieve the file extension.
public function saveToFile( sPath )
Save the file to the hard drive.