I use the JCL wrapper to compress the GZIP stream - not sure if it will work simply using TJcl7ziCompresspArchive. To compress the stream, I use the following:
procedure _CompressStreamGZIP( const ASourceStream, ADestinationStream: TStream ); var LArchive : TJclCompressArchive; begin ADestinationStream.Position := 0; ASourceStream.Position := 0; LArchive := TJclGZipCompressArchive.Create( ADestinationStream, 0, False ); try LArchive.AddFile( '..\Stream.0', ASourceStream, false ); LArchive.Compress(); finally if ( Assigned( LArchive ) ) then FreeAndNil( LArchive ); end; end;
To unzip a stream:
procedure _DecompressStreamGZIP( const ASourceStream, ADestinationStream : TStream ); var LArchive : TJclDecompressArchive; begin ADestinationStream.Position := 0; ASourceStream.Position := 0; LArchive := TJclGZipDecompressArchive.Create( ASourceStream, 0, false ); try LArchive.ListFiles(); LArchive.Items[0].Stream := ADestinationStream; LArchive.Items[0].OwnsStream := false; LArchive.Items[0].Selected := True; LArchive.ExtractSelected(); finally if ( Assigned( LArchive ) ) then FreeAndNil( LArchive ); end; end;
berndvf
source share