Contents - Index - Previous - Next


ZipFromStream method

 

Applies to

TVCLZip component

 

Declaration

function ZipFromStream(theStream: TkpStream; FName: string): Integer; overload;

function ZipFromStream(theStream: TkpStream; FName: string; FreeStreamWhenDone: Boolean): Integer; overload;

// D4,D5,BCB4,BCB5 only...

function ZipFromStream(theStream: TStream; FName: string; FreeStreamWhenDone: Boolean): Integer; overload;

 

 

Description

The ZipFromStream method will take theStream, and zip it to the zip file specified by the ZipName Property or to the ArchiveStream.  This allows you to, for instance, take a currently open TMemoryStream and save it directly to a zip file without having to first save it to a disk file.  All of the VCLZip's current properties will affect the processing of the file.  FName specifies the filename that will be given to the saved file.  If the StorePaths Property is set to True, then path information will be saved if FName includes path information.

 

The FreeStreamWhenDone parameter tells VCLZip to free the stream when it has finished zipping the stream into the archive. If it is false, or if you use the overloaded ZipFromStream that does not include this parameter, then it is left up to your application to free the stream.  It is most useful to set this to True if you are using the OnGetNextStream event to have VCLZip zip multiple streams into the archive in one operation. 

 

If you have defined an OnGetNextStream event, it will be called to get more streams to zip into the same archive.

 

The overloaded version of this method that is for D4, D5, BCB4, and BCB5 only is to allow these versions of Delphi/BCB to zip from a normal TStream rather than a TkpStream.  Note that in D6, D7, and BCB6, TkpStream = TStream as these versions of Delphi/BCB have Int64 capabilities in TStream.

 

Return Value  

The return value will be 1 if the stream was zipped and 0 if it was not successfully zipped.  If OnGetNextStream is defined then the return value will be the total number of streams zipped.