3630 "decode rawBytes into a byteArray or string" |
3628 "decode rawBytes into a byteArray or string" |
3631 |
3629 |
3632 |outBytes| |
3630 |outBytes| |
3633 |
3631 |
3634 compressionMethod == COMPRESSION_STORED ifTrue:[ |
3632 compressionMethod == COMPRESSION_STORED ifTrue:[ |
3635 "/ |
3633 "/ |
3636 "/ uncompressed |
3634 "/ uncompressed |
3637 "/ |
3635 "/ |
3638 asString ifTrue:[^ rawBytes asString]. |
3636 asString ifTrue:[^ rawBytes asString]. |
3639 ^ rawBytes |
3637 ^ rawBytes |
3640 ]. |
3638 ]. |
3641 |
3639 |
3642 compressionMethod == COMPRESSION_DEFLATED ifTrue:[ |
3640 compressionMethod == COMPRESSION_DEFLATED ifTrue:[ |
3643 "/ |
3641 "/ |
3644 "/ deflate/inflate algorithm |
3642 "/ deflate/inflate algorithm |
3645 "/ |
3643 "/ |
3646 asString ifTrue:[ |
3644 asString ifTrue:[ |
3647 outBytes := String new:uncompressedSize. |
3645 outBytes := String uninitializedNew:uncompressedSize. |
3648 ] ifFalse:[ |
3646 ] ifFalse:[ |
3649 outBytes := ByteArray new:uncompressedSize. |
3647 outBytes := ByteArray uninitializedNew:uncompressedSize. |
3650 ]. |
3648 ]. |
3651 ^ self inflate:rawBytes to:outBytes |
3649 ^ self inflate:rawBytes to:outBytes |
3652 ]. |
3650 ]. |
3653 |
3651 |
3654 "/ |
3652 "/ |
3655 "/ the other algorithms are not (yet) supported |
3653 "/ the other algorithms are not (yet) supported |
3656 "/ |
3654 "/ |
3657 compressionMethod == COMPRESSION_SHRUNK ifTrue:[ |
3655 compressionMethod == COMPRESSION_SHRUNK ifTrue:[ |
3658 self error:'unsupported compression method: SHRUNK'. |
3656 self error:'unsupported compression method: SHRUNK'. |
3659 ^ nil |
3657 ^ nil |
3660 ]. |
3658 ]. |
3661 compressionMethod == COMPRESSION_REDUCED1 ifTrue:[ |
3659 compressionMethod == COMPRESSION_REDUCED1 ifTrue:[ |
3662 self error:'unsupported compression method: REDUCED1'. |
3660 self error:'unsupported compression method: REDUCED1'. |
3663 ^ nil |
3661 ^ nil |
3664 ]. |
3662 ]. |
3665 compressionMethod == COMPRESSION_REDUCED2 ifTrue:[ |
3663 compressionMethod == COMPRESSION_REDUCED2 ifTrue:[ |
3666 self error:'unsupported compression method: REDUCED2'. |
3664 self error:'unsupported compression method: REDUCED2'. |
3667 ^ nil |
3665 ^ nil |
3668 ]. |
3666 ]. |
3669 compressionMethod == COMPRESSION_REDUCED3 ifTrue:[ |
3667 compressionMethod == COMPRESSION_REDUCED3 ifTrue:[ |
3670 self error:'unsupported compression method: REDUCED3'. |
3668 self error:'unsupported compression method: REDUCED3'. |
3671 ^ nil |
3669 ^ nil |
3672 ]. |
3670 ]. |
3673 compressionMethod == COMPRESSION_REDUCED4 ifTrue:[ |
3671 compressionMethod == COMPRESSION_REDUCED4 ifTrue:[ |
3674 self error:'unsupported compression method: REDUCED4'. |
3672 self error:'unsupported compression method: REDUCED4'. |
3675 ^ nil |
3673 ^ nil |
3676 ]. |
3674 ]. |
3677 compressionMethod == COMPRESSION_IMPLODED ifTrue:[ |
3675 compressionMethod == COMPRESSION_IMPLODED ifTrue:[ |
3678 self error:'unsupported compression method: IMPLODED'. |
3676 self error:'unsupported compression method: IMPLODED'. |
3679 ^ nil |
3677 ^ nil |
3680 ]. |
3678 ]. |
3681 compressionMethod == COMPRESSION_TOKENIZED ifTrue:[ |
3679 compressionMethod == COMPRESSION_TOKENIZED ifTrue:[ |
3682 self error:'unsupported compression method: TOKENIZED'. |
3680 self error:'unsupported compression method: TOKENIZED'. |
3683 ^ nil |
3681 ^ nil |
3684 ]. |
3682 ]. |
3685 |
3683 |
3686 self error:'unsupported compression method'. |
3684 self error:'unsupported compression method'. |
3687 ^ nil |
3685 ^ nil |
3688 |
3686 |
3689 "Created: / 29-03-1998 / 20:14:45 / cg" |
3687 "Created: / 29-03-1998 / 20:14:45 / cg" |
3690 "Modified: / 19-11-2010 / 15:39:49 / cg" |
3688 "Modified: / 19-11-2010 / 15:39:49 / cg" |
|
3689 "Modified: / 24-09-2019 / 16:28:35 / Stefan Vogel" |
3691 ! |
3690 ! |
3692 |
3691 |
3693 inflate:inBytes to:outBytes |
3692 inflate:inBytes to:outBytes |
3694 |inflateReturnCode| |
3693 |inflateReturnCode| |
3695 |
3694 |