Andreas Raab uploaded a new version of Compression to project The Trunk: http://source.squeak.org/trunk/Compression-ar.21.mcz
==================== Summary ====================
Name: Compression-ar.21 Author: ar Time: 1 September 2010, 11:32:08.32 pm UUID: fa1a526b-c5a4-4b43-a077-c53bf02c65da Ancestors: Compression-ar.20
Break the dependency between the Collection and the Compression package.
=============== Diff against Compression-ar.20 ===============
Item was added: + ----- Method: PositionableStream>>asZLibReadStream (in category '*Compression') ----- + asZLibReadStream + ^ZLibReadStream on: collection from: position+1 to: readLimit!
Item was added: + ----- Method: ReadWriteStream>>isZipArchive (in category '*Compression') ----- + isZipArchive + "Determine if this appears to be a valid Zip archive" + | sig | + self binary. + sig := self next: 4. + self position: self position - 4. "rewind" + ^ZipArchive validSignatures includes: sig!
Item was added: + ----- Method: ReadWriteStream>>asUnZippedStream (in category '*Compression') ----- + asUnZippedStream + | isGZip outputStream first strm archive which | + "Decompress this file if needed, and return a stream. No file is written. File extension may be .gz or anything else. Also works on archives (.zip, .gZip)." + + strm := self binary. + strm isZipArchive ifTrue: [ + archive := ZipArchive new readFrom: strm. + which := archive members detect: [:any | any fileName asLowercase endsWith: '.ttf'] + ifNone: [nil]. + which ifNil: [archive close. + ^ self error: 'Can''t find .ttf file in archive']. + strm := which contentStream. + archive close]. + + first := strm next. + isGZip := (strm next * 256 + first) = (GZipConstants gzipMagic). + strm skip: -2. + isGZip + ifTrue: [outputStream := (MultiByteBinaryOrTextStream with: + (GZipReadStream on: strm) upToEnd) reset. + strm close] + ifFalse: [outputStream := strm]. + ^ outputStream!
Item was added: + ----- Method: String>>unzipped (in category '*Compression') ----- + unzipped + | magic1 magic2 | + magic1 := (self at: 1) asInteger. + magic2 := (self at: 2) asInteger. + (magic1 = 16r1F and:[magic2 = 16r8B]) ifFalse:[^self]. + ^(GZipReadStream on: self) upToEnd!
Item was added: + ----- Method: String>>zipped (in category '*Compression') ----- + zipped + | stream gzstream | + + stream := RWBinaryOrTextStream on: String new. + + gzstream := GZipWriteStream on: stream. + gzstream nextPutAll: self. + gzstream close. + stream reset. + + ^ stream contents. + !
squeak-dev@lists.squeakfoundation.org