[squeak-dev] The Trunk: Compression-dtl.54.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Sep 28 12:00:46 UTC 2017

David T. Lewis uploaded a new version of Compression to project The Trunk:

==================== Summary ====================

Name: Compression-dtl.54
Author: dtl
Time: 28 September 2017, 8:00:37.70922 am
UUID: 97cfd1cd-0c07-40a7-92e9-4ea35b82fd5e
Ancestors: Compression-nice.53

In an archive file is too short, or more commonly if it is empty, identify its name in the error message. This is helpful in the case of a corrupt file in a package-cache, which may have been created due to some earlier system or network problem.

=============== Diff against Compression-nice.53 ===============

Item was changed:
  ----- Method: ZipArchive class>>findEndOfCentralDirectoryFrom: (in category 'constants') -----
  findEndOfCentralDirectoryFrom: stream
  	"Seek in the given stream to the end, then read backwards until we find the
  	signature of the central directory record. Leave the file positioned right
  	before the signature.
  	Answers the file position of the EOCD, or 0 if not found."
  	| data fileLength seekOffset pos maxOffset |
  	stream setToEnd.
  	fileLength := stream position.
  	"If the file length is less than 18 for the EOCD length plus 4 for the signature, we have a problem"
+ 	fileLength < 22 ifTrue: [^ self error: 'file is too short: ', stream name].
- 	fileLength < 22 ifTrue: [^ self error: 'file is too short'].
  	seekOffset := 0.
  	pos := 0.
  	data := ByteArray new: 4100.
  	maxOffset := 40960 min: fileLength.	"limit search range to 40K"
  		seekOffset := (seekOffset + 4096) min: fileLength.
  		stream position: fileLength - seekOffset.
  		data := stream next: (4100 min: seekOffset) into: data startingAt: 1.
  		pos := self lastIndexOfPKSignature: EndOfCentralDirectorySignature in: data.
  		pos = 0 and: [seekOffset < maxOffset]
  	] whileTrue.
  	^ pos > 0
  		ifTrue: [ | newPos | stream position: (newPos := (stream position + pos - seekOffset - 1)). newPos]
  		ifFalse: [0]!

More information about the Squeak-dev mailing list