equal
deleted
inserted
replaced
3125 |
3125 |
3126 "Created: / 29.3.1998 / 17:46:09 / cg" |
3126 "Created: / 29.3.1998 / 17:46:09 / cg" |
3127 "Modified: / 20.10.1998 / 00:30:02 / cg" |
3127 "Modified: / 20.10.1998 / 00:30:02 / cg" |
3128 ! ! |
3128 ! ! |
3129 |
3129 |
|
3130 !ZipArchive class methodsFor:'utilities'! |
|
3131 |
|
3132 dateToZipFileDate:aDate |
|
3133 "/ data in msdos format |
|
3134 ^ (((aDate day) |
|
3135 bitOr: (aDate month bitShift: 5)) |
|
3136 bitOr: (((aDate year) - 1980) bitShift: 9)) |
|
3137 ! |
|
3138 |
|
3139 timeToZipFileTime:aTime |
|
3140 "/ time in msdos format |
|
3141 ^ (((aTime seconds // 2) |
|
3142 bitOr: (aTime minutes bitShift: 5)) |
|
3143 bitOr: (aTime hours bitShift: 11)) |
|
3144 ! ! |
|
3145 |
3130 !ZipArchive methodsFor:'Compatibility-Squeak'! |
3146 !ZipArchive methodsFor:'Compatibility-Squeak'! |
3131 |
3147 |
3132 binaryContentsOf: fileName |
3148 binaryContentsOf: fileName |
3133 |
3149 |
3134 ^(self extract: fileName) |
3150 ^(self extract: fileName) |
4184 ! |
4200 ! |
4185 |
4201 |
4186 addFile:aFileName fromStream:aStream compressMethod:theCompressMethodArg asDirectory:isDirectory |
4202 addFile:aFileName fromStream:aStream compressMethod:theCompressMethodArg asDirectory:isDirectory |
4187 "do not create directories (isDirectory = true) - they are not compatible between operating systems" |
4203 "do not create directories (isDirectory = true) - they are not compatible between operating systems" |
4188 |
4204 |
4189 |zipEntry curTime curDate theZipFileName theCompressMethod streamBufferSize buffer |
4205 |zipEntry theZipFileName theCompressMethod streamBufferSize buffer |
4190 crc32 unCompressedDataSize startDataPosition nextBlockSize myZipStream| |
4206 crc32 unCompressedDataSize startDataPosition nextBlockSize myZipStream| |
4191 |
4207 |
4192 (file isNil or: [mode ~~ #write]) ifTrue: [ |
4208 (file isNil or: [mode ~~ #write]) ifTrue: [ |
4193 ^ self error: 'ZipArchive not open for writing ...'. |
4209 ^ self error: 'ZipArchive not open for writing ...'. |
4194 ]. |
4210 ]. |
4216 zipEntry compressionMethod: theCompressMethod. |
4232 zipEntry compressionMethod: theCompressMethod. |
4217 zipEntry internalFileAttributes: 1. |
4233 zipEntry internalFileAttributes: 1. |
4218 zipEntry externalFileAttributes: EXTERNALFILEATTRIBUTES_ISFILE. |
4234 zipEntry externalFileAttributes: EXTERNALFILEATTRIBUTES_ISFILE. |
4219 ]. |
4235 ]. |
4220 |
4236 |
4221 curTime := Time now. |
|
4222 curDate := Date today. |
|
4223 "/ data and time in msdos format |
4237 "/ data and time in msdos format |
4224 zipEntry lastModFileTime: (((curTime seconds // 2) bitOr: (curTime minutes rightShift: -5)) bitOr: (curTime hours rightShift: -11)). |
4238 zipEntry setModificationTimeAndDateToNow. |
4225 zipEntry lastModFileDate: (((curDate day) bitOr: (curDate month rightShift: -5)) bitOr: (((curDate year) - 1980) rightShift: -9)). |
|
4226 |
4239 |
4227 "/ ensure that the file position is at the end |
4240 "/ ensure that the file position is at the end |
4228 file setToEnd. |
4241 file setToEnd. |
4229 |
4242 |
4230 zipEntry writeTo:file. |
4243 zipEntry writeTo:file. |
4307 ! |
4320 ! |
4308 |
4321 |
4309 basicAddFile:aFileName withContents:data compressMethod:theCompressMethodArg asDirectory:isDirectory |
4322 basicAddFile:aFileName withContents:data compressMethod:theCompressMethodArg asDirectory:isDirectory |
4310 "do not create directories (isDirectory = true) - they are not compatible between operating systems" |
4323 "do not create directories (isDirectory = true) - they are not compatible between operating systems" |
4311 |
4324 |
4312 | zipEntry theCompressedData curTime curDate theZipFileName theCompressMethod | |
4325 | zipEntry theCompressedData theZipFileName theCompressMethod | |
4313 |
4326 |
4314 (file isNil or:[ mode ~~ #write ]) ifTrue:[ |
4327 (file isNil or:[ mode ~~ #write ]) ifTrue:[ |
4315 ^ self error:'ZipArchive not open for writing ...'. |
4328 ^ self error:'ZipArchive not open for writing ...'. |
4316 ]. |
4329 ]. |
4317 theCompressMethod := theCompressMethodArg. |
4330 theCompressMethod := theCompressMethodArg. |
4343 ] ifFalse:[ |
4356 ] ifFalse:[ |
4344 zipEntry compressionMethod:theCompressMethod. |
4357 zipEntry compressionMethod:theCompressMethod. |
4345 zipEntry internalFileAttributes: 1. |
4358 zipEntry internalFileAttributes: 1. |
4346 zipEntry externalFileAttributes: EXTERNALFILEATTRIBUTES_ISFILE. |
4359 zipEntry externalFileAttributes: EXTERNALFILEATTRIBUTES_ISFILE. |
4347 ]. |
4360 ]. |
4348 curTime := Time now. |
|
4349 curDate := Date today. |
|
4350 |
4361 |
4351 "/ data and time in msdos format |
4362 "/ data and time in msdos format |
4352 |
4363 zipEntry setModificationTimeAndDateToNow. |
4353 zipEntry |
4364 |
4354 lastModFileTime:(((curTime seconds // 2) |
|
4355 bitOr:(curTime minutes rightShift:-5)) |
|
4356 bitOr:(curTime hours rightShift:-11)). |
|
4357 zipEntry |
|
4358 lastModFileDate:(((curDate day) bitOr:(curDate month rightShift:-5)) |
|
4359 bitOr:(((curDate year) - 1980) rightShift:-9)). |
|
4360 data notEmptyOrNil ifTrue:[ |
4365 data notEmptyOrNil ifTrue:[ |
4361 "/ crc32 is allways reqired (not as written in docu to be zero in case of uncompressed mode) |
4366 "/ crc32 is allways reqired (not as written in docu to be zero in case of uncompressed mode) |
4362 zipEntry crc32:(ZipStream crc32BytesIn:data). |
4367 zipEntry crc32:(ZipStream crc32BytesIn:data). |
4363 ]. |
4368 ]. |
4364 (isDirectory not and:[ theCompressMethod == COMPRESSION_DEFLATED ]) ifTrue:[ |
4369 (isDirectory not and:[ theCompressMethod == COMPRESSION_DEFLATED ]) ifTrue:[ |
4403 ! |
4408 ! |
4404 |
4409 |
4405 writeStreamFor:nameOfFileInArchive compressMethod:theCompressMethodArg |
4410 writeStreamFor:nameOfFileInArchive compressMethod:theCompressMethodArg |
4406 "create new entry in central directory" |
4411 "create new entry in central directory" |
4407 |
4412 |
4408 |zipEntry curTime curDate theZipFileName theCompressMethod| |
4413 |zipEntry theZipFileName theCompressMethod| |
4409 |
4414 |
4410 (file isNil or:[mode ~~ #write]) ifTrue: [ |
4415 (file isNil or:[mode ~~ #write]) ifTrue: [ |
4411 ^ self error: 'ZipArchive not open for writing ...'. |
4416 ^ self error: 'ZipArchive not open for writing ...'. |
4412 ]. |
4417 ]. |
4413 |
4418 |
4429 |
4434 |
4430 zipEntry compressionMethod: theCompressMethod. |
4435 zipEntry compressionMethod: theCompressMethod. |
4431 zipEntry internalFileAttributes: 1. |
4436 zipEntry internalFileAttributes: 1. |
4432 zipEntry externalFileAttributes: EXTERNALFILEATTRIBUTES_ISFILE. |
4437 zipEntry externalFileAttributes: EXTERNALFILEATTRIBUTES_ISFILE. |
4433 |
4438 |
4434 curTime := Time now. |
|
4435 curDate := Date today. |
|
4436 "/ data and time in msdos format |
4439 "/ data and time in msdos format |
4437 zipEntry lastModFileTime: (((curTime seconds // 2) bitOr: (curTime minutes rightShift: -5)) bitOr: (curTime hours rightShift: -11)). |
4440 zipEntry setModificationTimeAndDateToNow. |
4438 zipEntry lastModFileDate: (((curDate day) bitOr: (curDate month rightShift: -5)) bitOr: (((curDate year) - 1980) rightShift: -9)). |
|
4439 |
4441 |
4440 "/ ensure that the file position is at the end |
4442 "/ ensure that the file position is at the end |
4441 file setToEnd. |
4443 file setToEnd. |
4442 |
4444 |
4443 zipEntry writeTo:file. |
4445 zipEntry writeTo:file. |
4444 self addMember:zipEntry. |
4446 self addMember:zipEntry. |
4445 |
4447 |
4446 ^ (ZipWriteStream zipFileStream:file zipEntry:zipEntry) |
4448 ^ (ZipWriteStream zipFileStream:file zipEntry:zipEntry) zipArchive:self. |
4447 zipArchive:self. |
|
4448 |
4449 |
4449 "Modified: / 19-11-2010 / 15:38:54 / cg" |
4450 "Modified: / 19-11-2010 / 15:38:54 / cg" |
4450 ! ! |
4451 ! ! |
4451 |
4452 |
4452 !ZipArchive::AbstractZipStream class methodsFor:'instance creation'! |
4453 !ZipArchive::AbstractZipStream class methodsFor:'instance creation'! |
4814 ^ relativeLocalHeaderOffset |
4815 ^ relativeLocalHeaderOffset |
4815 ! |
4816 ! |
4816 |
4817 |
4817 relativeLocalHeaderOffset:something |
4818 relativeLocalHeaderOffset:something |
4818 relativeLocalHeaderOffset := something. |
4819 relativeLocalHeaderOffset := something. |
|
4820 ! |
|
4821 |
|
4822 setModificationTimeAndDateToNow |
|
4823 |curTime curDate| |
|
4824 |
|
4825 curTime := Time now. |
|
4826 curDate := Date today. |
|
4827 "/ data and time in msdos format |
|
4828 self lastModFileTime: (ZipArchive timeToZipFileTime:curTime). |
|
4829 self lastModFileDate: (ZipArchive dateToZipFileDate:curDate). |
4819 ! |
4830 ! |
4820 |
4831 |
4821 uncompressedSize |
4832 uncompressedSize |
4822 ^ uncompressedSize |
4833 ^ uncompressedSize |
4823 ! |
4834 ! |
5178 ! ! |
5189 ! ! |
5179 |
5190 |
5180 !ZipArchive class methodsFor:'documentation'! |
5191 !ZipArchive class methodsFor:'documentation'! |
5181 |
5192 |
5182 version |
5193 version |
5183 ^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.111 2013-08-18 10:57:01 cg Exp $' |
5194 ^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.112 2014-02-18 13:53:32 cg Exp $' |
5184 ! |
5195 ! |
5185 |
5196 |
5186 version_CVS |
5197 version_CVS |
5187 ^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.111 2013-08-18 10:57:01 cg Exp $' |
5198 ^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.112 2014-02-18 13:53:32 cg Exp $' |
5188 ! ! |
5199 ! ! |
5189 |
5200 |
5190 |
5201 |
5191 ZipArchive initialize! |
5202 ZipArchive initialize! |