SystemOrganization addCategory: #'FS-Zip'! !FSFilesystem classSide methodsFor: '*fs-zip' stamp: 'cwp 2/19/2011 14:44'! inZip: aReference ^ self store: (FSZipStore reference: aReference)! ! FSMemoryStore subclass: #FSZipStore instanceVariableNames: 'reference' classVariableNames: '' poolDictionaries: '' category: 'FS-Zip'! !FSZipStore classSide methodsFor: 'as yet unclassified' stamp: 'cwp 2/18/2011 23:46'! reference: aReference ^ self basicNew initializeWithReference: aReference yourself! ! !FSZipStore methodsFor: 'public' stamp: 'cwp 2/19/2011 14:42'! close | archive fs stream | archive := ZipArchive new. fs := FSFilesystem store: self. fs root allChildren do: [ :each | each isFile ifTrue: [ each readStreamDo: [ :output | archive addString: output contents as: each path printString ] ] ]. archive writeTo: (stream := WriteStream on: ByteArray new); close. self reference writeStreamDo: [ :output | output nextPutAll: stream contents ]! ! !FSZipStore methodsFor: 'as yet unclassified' stamp: 'cwp 2/18/2011 23:49'! initializeWithReference: aReference self initialize. reference := aReference! ! !FSZipStore methodsFor: 'public' stamp: 'cwp 2/19/2011 01:41'! open | archive output | self reference exists ifFalse: [ ^ self ]. archive := ZipArchive new. self reference readStreamDo: [ :input | archive readFrom: input contents readStream. archive members do: [ :member | | path | path := self pathFromMember: member. member isDirectory ifTrue: [ self ensureDirectory: path ] ifFalse: [ self ensureDirectory: path parent. self createFile: path. self replaceFile: path in: [ :bytes | output := bytes writeStream. member rewindData. member copyRawDataTo: output. output contents ] ] ] ]. ^ self! ! !FSZipStore methodsFor: 'private' stamp: 'cwp 2/19/2011 01:37'! pathFromMember: anArchiveMember | path | path := FSPath root resolve: anArchiveMember fileName. ^ path basename isEmpty ifTrue: [ path parent ] ifFalse: [ path ]! ! !FSZipStore methodsFor: 'as yet unclassified' stamp: 'cwp 2/18/2011 23:49'! reference ^ reference! !