|
Class: ZipStream
Object
|
+--Stream
|
+--CompressionStream
|
+--ZipStream
- Package:
- stx:libbasic2
- Category:
- Streams-Compressed
- Version:
- rev:
1.47
date: 2017/01/18 00:48:38
- user: cg
- file: ZipStream.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
- Author:
- Claus Atzkern
Zip compression and decompression (as used in gzip and zip)
[instance variables:]
[class variables:]
ZipInterface compatibility - compress/uncompress
-
compress: aUncompressedByteArray into: aCompressedByteArray
-
-
flatBytesIn: bytesIn from: start to: stop into: bytesOut doCompress: doCompress
-
compress or uncompress the bytesIn buffer into the bytesOut buffer; returns
the un/compressed size; on error an exception is raised
-
uncompress: aCompressedByteArray into: anUncompressedByteArray
-
ZipInterface compatibility - crc
-
crc32Add: aCharacterOrByte crc: crc
-
Update a running crc with aCharacterOrByte
and return the updated crc
-
crc32BytesIn: bytesIn from: start to: stop crc: crc
-
Update a running crc with the bytes buf[start.. stop]
and return the updated crc
initialization
-
initialize
-
setup class attributes derived from the library
instance creation
-
readOpenAsZipStreamOn: aStream
-
open to read data compressed from stream,
the default readOpenOn: will open ZipStream as gzip stream
-
readOpenAsZipStreamOn: aStream suppressFileHeader: suppressFileHeader suppressZipHeaderAndChecksum: suppressZipHeaderAndChecksum
-
open to read data compressed from stream,
the default readOpenOn: will open ZipStream as gzip stream
-
readOpenAsZipStreamOn: aStream suppressHeaderAndChecksum: aBoolean
-
open to read data compressed from stream,
the default readOpenOn: will open ZipStream as gzip stream
-
writeOpenAsZipStreamOn: aStream
-
open to write data compressed to stream,
the default writeOpenOn: will open ZipStream as gzip stream
-
writeOpenAsZipStreamOn: aStream suppressFileHeader: suppressFileHeader suppressZipHeaderAndChecksum: suppressZipHeaderAndChecksum
-
open to write data compressed to stream,
the default writeOpenOn: will open ZipStream as gzip stream
-
writeOpenAsZipStreamOn: aStream suppressHeaderAndChecksum: aBoolean
-
open to write data compressed to stream,
the default writeOpenOn: will open ZipStream as gzip stream
queries
-
maxDistanceCodes
-
-
maxLiteralCodes
-
low level
-
zclose
-
low level close of the zip stream
-
zdeflate
-
low level - deflate
-
zdeflateInit
-
low level - deflateInit
-
zget_avail_out
-
low level - get the number of available out bytes
-
zget_windowBits
-
answer the bits used for inflateInit2 or deflateInit2...
a negative WindowBits value suppresses the zlib header and the checksum...
-
zinflate
-
low level - inflate
-
zinflateInit
-
low level - inflateInit
-
zopen
-
low level - opens the zip stream
-
zset_avail_in: count
-
set the 'avail_in' and compute the crc
startup & release
-
openWithMode: aMode on: aStream suppressFileHeader: suppressFileHeader suppressZipHeaderAndChecksum: suppressZipHeaderAndChecksum
-
open stream and write or check gzip header
suppressFileHeader:
if true, the gzip header (magic number and a few extra fields) is not written/read
suppressZipHeaderAndChecksum
controls if the gzip checksum and 2 header bytes should be written/checked
-
openWithMode: aMode on: aStream suppressHeaderAndChecksum: aBoolean
-
open stream and write or check gzip header.
Caveat:
Backward compatibility: aBoolean controls if the gzip checksum and 2 header bytes should be written/checked
(i.e. NOT the file header with the zip magic)
-
readHeader
-
Check for the gzip magic id
-
writeHeader
-
write the gzip magic id
|compressedDataStream zipStream compressedData uncompressedData|
compressedDataStream := #[] writeStream.
zipStream := ZipStream writeOpenOn:compressedDataStream.
zipStream nextPutAll:'hallo Welt'.
zipStream close.
compressedData := compressedDataStream contents.
zipStream := ZipStream readOpenOn:(compressedData readStream).
zipStream notNil ifTrue:[
|stream c|
stream := '' writeStream.
[ (c := zipStream nextOrNil) notNil ] whileTrue:[
stream nextPut:c
].
stream close.
uncompressedData := stream contents.
].
^ uncompressedData
|
|fstream zipStream c|
fstream := FileStream newTemporary.
zipStream := ZipStream writeOpenOn:fstream.
zipStream nextPutAll:'hallo Welt(1) - test....'.
zipStream cr.
zipStream nextPutAll:'hallo Welt(2) - test....'.
zipStream cr.
zipStream close.
fstream close.
fstream := fstream fileName readStream.
zipStream := ZipStream readOpenOn:fstream.
Transcript showCR:zipStream contents.
zipStream close.
fstream close.
fstream fileName delete.
|
|