'From Squeak3.3alpha of 30 January 2002 [latest update: #4689] on 30 January 2002 at 10:34:07 am'! "Change Set: ZipsInFileListFix-nk Date: 30 January 2002 Author: Ned Konz The FileList changes in 4684RegFileList-hgglsd included registration of ZipArchive. Unfortunately, it was registered for .gz and .gzip files, even though ZipArchive has nothing to do with either file format. This change set fixes that, and moves the responsibility for viewing zips (and making and viewing new ones) to ArchiveViewer, where it belongs. There still is an issue in the FileList registration having to do with registering a tool for any file type (like 'add to zip'). In my opinion, there should be a callback for type '*'. Published in 3.3a as 4726ZipsInFileListFix-nk.cs "! !ArchiveViewer class methodsFor: 'instance creation' stamp: 'nk 1/30/2002 10:18'! addFileToNewZip: fullName "Add the currently selected file to a new zip" | zip | zip := (ZipArchive new) addFile: fullName as: (FileDirectory localNameFor: fullName); yourself. (self open) archive: zip ! ! !ArchiveViewer class methodsFor: 'class initialization' stamp: 'nk 1/30/2002 10:26'! fileReaderServicesForSuffix: suffix ^ (suffix = 'zip') | (suffix = 'ZIP') | (suffix = '*') ifTrue: [ {SimpleServiceEntry provider: self label: 'open in zip viewer' selector: #openOn: }] ifFalse: [suffix = '*' ifTrue: [ {SimpleServiceEntry provider: self label: 'add file to new zip' selector: #addFileToNewZip: }] ifFalse: [#()]]! ! !ArchiveViewer class methodsFor: 'class initialization' stamp: 'nk 1/30/2002 10:13'! initialize "ArchiveViewer initialize" FileList registerFileReader: self! ! !ArchiveViewer class methodsFor: 'class initialization' stamp: 'nk 1/30/2002 10:13'! unload FileList unregisterFileReader: self ! ! !FileList methodsFor: 'file list menu' stamp: 'nk 1/30/2002 10:21'! itemsForAnyFile "what's happen if the Zip stuff is not in the image?" | services | self flag: #possibleBug. services := OrderedCollection new: 5. services add: (SimpleServiceEntry provider: self label: 'copy name to clipboard' selector: #copyName). services add: (SimpleServiceEntry provider: self label: 'rename' selector: #renameFile). services add: (SimpleServiceEntry provider: self label: 'delete' selector: #deleteFile). services add: (SimpleServiceEntry provider: self label: 'compress' selector: #compressFile). (self class isReaderNamedRegistered: #ArchiveViewer) ifTrue: [ services add: (SimpleServiceEntry provider: (Smalltalk at: #ArchiveViewer) label: 'add file to new zip' selector: #addFileToNewZip:)] . "this code shows that it would might be better to register the services than the classes" ^ services! ! !ZipArchive class methodsFor: 'class variables' stamp: 'nk 1/30/2002 10:22'! initialize "ZipArchive initialize" [self initializeZipFileConstants] on: Warning do: [:ex | ex resume: true]. ! ! ZipArchive class removeSelector: #addFileToZip:! ZipArchive class removeSelector: #fileReaderServicesForSuffix:! ZipArchive initialize! ZipArchive class removeSelector: #unload! FileList removeSelector: #openArchiveViewer! ArchiveViewer initialize! !ArchiveViewer class reorganize! ('instance creation' addFileToNewZip: open openOn:) ('parts bin' descriptionForPartsBin) ('class initialization' fileReaderServicesForSuffix: initialize unload) ! "Postscript: ZipArchive should not be registered. Unregister it. Then register the ArchiveViewer instead." FileList unregisterFileReader: ZipArchive. ArchiveViewer initialize.!