VASmalltalk – how to create a zip archive …

Today I was in the need to create a zip archive in VASmalltalk and zip-code had been introduced with the new Monticello Importer in version 8.5.2 (application: MZZipUnzipApp)

Documentation is spare and therefore a simple code example how to create a zip archive (and as a reminder for me):

| cfsPath zipArchive |
"where all my files are located"
cfsPath := CfsPath named: 'D:\json-sendelisten'.

"my zip archive to write"
zipArchive := MZZipArchive openWrite: 'd:\test8.zip'.

"i want to add all file from that directory ..."
cfsPath fileEntries do: [ :eachFileEntry |
  | singleFile fileContent |
  singleFile := cfsPath append: eachFileEntry dName.
  
  "method from MSKCfsExtension"
  fileContent := singleFile mskGetBinaryContent.	

  zipArchive 

    "create a current file within the archive"
    createFile: eachFileEntry dName 
    comment: '' 
    method: MZConstants::Z_DEFLATED 
    level: MZConstants::Z_BESTCOMPRESSION;

    "write the binay content of the file to the archive"
    write: fileContent ;

    "close the current file in the archive"
    closeCurrentFile.
].

"close the archive"
zipArchive close.
This entry was posted in Smalltalk and tagged , , . Bookmark the permalink.

One Response to VASmalltalk – how to create a zip archive …

  1. Pingback: Zipping files in VA Smalltalk | Joachims Small World

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s