1234567891011121314151617181920212223242526272829303132333435 |
- 由于il2cpp在4.6.3下存在如下bug导致sharpzipLib无法使用:
- bug如下:
- byte b = 205;
- Debug.Log( (b & 0xff) << 8)
- 在il2cpp下表达式计算是0
-
- 修改sharpzipLib源码,规避上述bug
- 1.StreamManipulator类PeekBits函数修改如下
- public int PeekBits(int bitCount)
- {
- if (bitsInBuffer_ < bitCount) {
- if (windowStart_ == windowEnd_) {
- return -1; // ok
- }
- int tmp1 = window_[windowStart_++] & 0xff;
- int tmp2 = window_[windowStart_++] & 0xff;
- buffer_ |= (uint)((tmp1 | tmp2 << 8) << bitsInBuffer_);
- bitsInBuffer_ += 16;
- }
- return (int)(buffer_ & ((1 << bitCount) - 1));
- }
-
- 2.DeflaterHuffman类BitReverse函数修改如下:
- public static short BitReverse(int toReverse)
- {
- int t1 = bit4Reverse[toReverse & 0xF];
- int t2 = bit4Reverse[(toReverse >> 4) & 0xF];
- int t3 = bit4Reverse[(toReverse >> 8) & 0xF];
- int t4 = bit4Reverse[(toReverse >> 12) & 0xF];
- int t5 = t1 << 12;
- int t6 = t2 << 8;
- int t7 = t3 << 4;
- int t8 = t4 << 0;
- return (short) (t5 | t6 | t7 | t8);
- }
|