8 be provided or otherwise made available to, or used by, any |
10 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
11 other person. No title to or ownership of the software is |
10 hereby transferred. |
12 hereby transferred. |
11 " |
13 " |
12 "{ Package: 'stx:libbasic2' }" |
14 "{ Package: 'stx:libbasic2' }" |
|
15 |
|
16 "{ NameSpace: Smalltalk }" |
13 |
17 |
14 Object subclass:#ZipArchive |
18 Object subclass:#ZipArchive |
15 instanceVariableNames:'file mode archiveName firstEntry lastEntry centralDirectory |
19 instanceVariableNames:'file mode archiveName firstEntry lastEntry centralDirectory |
16 startOfArchive endOfArchive zipMembersByName appendTrailingSlash' |
20 startOfArchive endOfArchive zipMembersByName appendTrailingSlash' |
17 classVariableNames:'Lobby RecentlyUsedZipArchives FlushBlock ZipFileFormatErrorSignal |
21 classVariableNames:'Lobby RecentlyUsedZipArchives FlushBlock ZipFileFormatErrorSignal |
3546 ! ! |
3550 ! ! |
3547 |
3551 |
3548 !ZipArchive methodsFor:'private - decompression'! |
3552 !ZipArchive methodsFor:'private - decompression'! |
3549 |
3553 |
3550 decode:rawBytes method:compressionMethod size:uncompressedSize |
3554 decode:rawBytes method:compressionMethod size:uncompressedSize |
|
3555 "decode rawBytes into a byteArray" |
|
3556 |
|
3557 ^ self |
|
3558 decode:rawBytes |
|
3559 method:compressionMethod |
|
3560 size:uncompressedSize |
|
3561 asString:false |
|
3562 ! |
|
3563 |
|
3564 decode:rawBytes method:compressionMethod size:uncompressedSize asString:asString |
|
3565 "decode rawBytes into a byteArray or string" |
|
3566 |
3551 |outBytes| |
3567 |outBytes| |
3552 |
3568 |
3553 compressionMethod == COMPRESSION_STORED ifTrue:[ |
3569 compressionMethod == COMPRESSION_STORED ifTrue:[ |
3554 "/ |
3570 "/ |
3555 "/ uncompressed |
3571 "/ uncompressed |
3556 "/ |
3572 "/ |
|
3573 asString ifTrue:[^ rawBytes asString]. |
3557 ^ rawBytes |
3574 ^ rawBytes |
3558 ]. |
3575 ]. |
3559 |
3576 |
3560 compressionMethod == COMPRESSION_DEFLATED ifTrue:[ |
3577 compressionMethod == COMPRESSION_DEFLATED ifTrue:[ |
3561 "/ |
3578 "/ |
3562 "/ deflate/inflate algorithm |
3579 "/ deflate/inflate algorithm |
3563 "/ |
3580 "/ |
3564 outBytes := ByteArray new:uncompressedSize. |
3581 asString ifTrue:[ |
|
3582 outBytes := String new:uncompressedSize. |
|
3583 ] ifFalse:[ |
|
3584 outBytes := ByteArray new:uncompressedSize. |
|
3585 ]. |
3565 ^ self inflate:rawBytes to:outBytes |
3586 ^ self inflate:rawBytes to:outBytes |
3566 ]. |
3587 ]. |
3567 |
3588 |
3568 "/ |
3589 "/ |
3569 "/ the other algorithms are not (yet) supported |
3590 "/ the other algorithms are not (yet) supported |
3606 |
3627 |
3607 inflate:inBytes to:outBytes |
3628 inflate:inBytes to:outBytes |
3608 |inflateReturnCode| |
3629 |inflateReturnCode| |
3609 |
3630 |
3610 %{ /* STACK:32768 */ |
3631 %{ /* STACK:32768 */ |
3611 if (__isByteArray(inBytes) |
3632 char *in, *out; |
3612 && __isByteArray(outBytes)) { |
3633 |
3613 char *in, *out; |
3634 if (__isByteArray(inBytes)) { |
|
3635 in = __ByteArrayInstPtr(inBytes)->ba_element; |
|
3636 } else if (__isString(inBytes)) { |
|
3637 in = __stringVal(inBytes); |
|
3638 } else { |
|
3639 inflateReturnCode = __MKSMALLINT(-999); |
|
3640 goto badArgument; |
|
3641 } |
|
3642 |
|
3643 if (__isByteArray(outBytes)) { |
|
3644 out = __ByteArrayInstPtr(outBytes)->ba_element; |
|
3645 } else if (__isString(outBytes)) { |
|
3646 out = __stringVal(outBytes); |
|
3647 } else { |
|
3648 inflateReturnCode = __MKSMALLINT(-999); |
|
3649 goto badArgument; |
|
3650 } |
|
3651 |
|
3652 { |
3614 int rc; |
3653 int rc; |
3615 |
|
3616 in = __ByteArrayInstPtr(inBytes)->ba_element; |
|
3617 out = __ByteArrayInstPtr(outBytes)->ba_element; |
|
3618 |
3654 |
3619 if ((rc = stx_inflate(in, out)) == 0) { |
3655 if ((rc = stx_inflate(in, out)) == 0) { |
3620 RETURN (outBytes); |
3656 RETURN (outBytes); |
3621 } |
3657 } |
3622 inflateReturnCode = __MKSMALLINT(rc); |
3658 inflateReturnCode = __MKSMALLINT(rc); |
3623 } |
3659 } |
|
3660 badArgument: ; |
3624 %}. |
3661 %}. |
3625 inflateReturnCode notNil ifTrue:[ |
3662 inflateReturnCode notNil ifTrue:[ |
|
3663 inflateReturnCode == -999 ifTrue:[ |
|
3664 self primitiveFailed:'bad argument' |
|
3665 ]. |
|
3666 |
3626 "/ bad blockType 2 |
3667 "/ bad blockType 2 |
3627 self error:'inflate error: ' , inflateReturnCode printString |
3668 self error:'inflate error: ' , inflateReturnCode printString |
3628 ]. |
3669 ]. |
3629 ^ nil. |
3670 ^ nil. |
3630 |
3671 |
5191 ! ! |
5240 ! ! |
5192 |
5241 |
5193 !ZipArchive class methodsFor:'documentation'! |
5242 !ZipArchive class methodsFor:'documentation'! |
5194 |
5243 |
5195 version |
5244 version |
5196 ^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.113 2014-04-29 13:27:27 cg Exp $' |
5245 ^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.114 2015-03-09 17:55:09 cg Exp $' |
5197 ! |
5246 ! |
5198 |
5247 |
5199 version_CVS |
5248 version_CVS |
5200 ^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.113 2014-04-29 13:27:27 cg Exp $' |
5249 ^ '$Header: /cvs/stx/stx/libbasic2/ZipArchive.st,v 1.114 2015-03-09 17:55:09 cg Exp $' |
5201 ! ! |
5250 ! ! |
5202 |
5251 |
5203 |
5252 |
5204 ZipArchive initialize! |
5253 ZipArchive initialize! |