[Cuis-dev] [Fix] ZipArchive>>#addFile: failure

Gerald Klix cuis.01 at klix.ch
Wed Apr 14 08:52:11 PDT 2021


On 2021-04-11 00:46, Juan Vuletich via Cuis-dev wrote:
> On 4/10/2021 8:50 AM, Gerald Klix via Cuis-dev wrote:
>> Hi all, Hi Juan,
>>
>> ZipArchive>>#addFile: and
>> ZipArchive>>#addFile:as: do not work due to
>> a bug in MSDOS date handling.
>>
>> Please find a script to reproduce that failure
>> and q fix to the compression package
>> attached to this message.
>>
>>
>> HTH and Best Regards,
>>
>> Gerald
> 
> Thanks Gerald! Fix now @ GitHub.
> 
> Cheers,
> 
Sigh, sorry, missed a case:
ZipArchive>#addString:as: passes seconds since
the epoch.
See change set for the silly details.


HTH and best Regards,

Gerald
-------------- next part --------------
'From Haver 5.0 [latest update: #4567] on 14 April 2021 at 5:47:11 pm'!

!ZipArchiveMember methodsFor: 'private' stamp: 'KLG 4/14/2021 17:14:13'!
squeakToDosTime: secs
	"Convert to MS-DOS time format
	See: https://docs.microsoft.com/de-de/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime?redirectedfrom=MSDN
	"

	| dosTime dateTime |

	dateTime _ Time dateAndTimeFromSeconds: 
		(secs isInteger
			ifFalse: [ secs secondsSinceSqueakEpoch ]
			ifTrue: [ secs ]).
	dosTime _ (dateTime second second) bitShift: -1.
	dosTime _ dosTime bitOr: ((dateTime second minute) bitShift: 5).
	dosTime _ dosTime bitOr: ((dateTime second hour) bitShift: 11).
	dosTime _ dosTime bitOr: ((dateTime first dayOfMonth) bitShift: `16 + 0`).
	dosTime _ dosTime bitOr: ((dateTime first monthIndex) bitShift: `16 + 5`).
	dosTime _ dosTime bitOr: (((dateTime first yearNumber) - 1980) bitShift: `16 + 9`).
	self assert: dosTime >= 0.
	^ dosTime
! !



More information about the Cuis-dev mailing list