How do you compress a directory in Squeak Smalltalk? I found the compressFile method in StandardFileStream, but I cannot figure out how to compress multiple files or a directory. I experimented with System-Compression classes, but didn't have much luck. Thanks in advance!
This is what I have now. I am adding timestamps at the end of the file names, so here I want to put all the files starting with the specified file name in a zip or gzip file.
compressFile: aFileName in: aDirectory | zipped buffer unzipped zipFileName | zipFileName _ aFileName copyUpTo: $. . zipped _ aDirectory newFileNamed: (zipFileName, FileDirectory dot, 'zip'). zipped binary; setFileTypeToObject. zipped _ ZipWriteStream on: zipped. buffer _ ByteArray new: 50000. aDirectory fileNames do: [:f | (f beginsWith: zipFileName) ifTrue: [ unzipped _ aDirectory readOnlyFileNamed: (aDirectory fullNameFor: f). unzipped binary. [unzipped atEnd] whileFalse:[ zipped nextPutAll: (unzipped nextInto: buffer)]. unzipped close]]. zipped close.
source share