com.wallstop-studios.unity-helpers 2.0.0-rc79 → 2.0.0-rc79.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/Runtime/Protobuf-Net/System.Collections.Immutable.dll +0 -0
  2. package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  3. package/Runtime/Protobuf-Net/protobuf-net.Core.dll +0 -0
  4. package/Runtime/Protobuf-Net/protobuf-net.dll +0 -0
  5. package/Runtime/Utils/LZMA.cs +53 -0
  6. package/Runtime/Utils/LZMA.cs.meta +3 -0
  7. package/Runtime/Utils/SevenZip/Common/CRC.cs +61 -0
  8. package/Runtime/Utils/SevenZip/Common/CRC.cs.meta +11 -0
  9. package/Runtime/Utils/SevenZip/Common/InBuffer.cs +71 -0
  10. package/Runtime/Utils/SevenZip/Common/InBuffer.cs.meta +11 -0
  11. package/Runtime/Utils/SevenZip/Common/OutBuffer.cs +65 -0
  12. package/Runtime/Utils/SevenZip/Common/OutBuffer.cs.meta +11 -0
  13. package/Runtime/Utils/SevenZip/Common.meta +3 -0
  14. package/Runtime/Utils/SevenZip/Compress/LZ/IMatchFinder.cs +28 -0
  15. package/Runtime/Utils/SevenZip/Compress/LZ/IMatchFinder.cs.meta +11 -0
  16. package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs +404 -0
  17. package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs.meta +11 -0
  18. package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs +153 -0
  19. package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs.meta +11 -0
  20. package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs +110 -0
  21. package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs.meta +11 -0
  22. package/Runtime/{Protobuf-Net/System.Collections.Immutable.xml.meta → Utils/SevenZip/Compress/LZ.meta} +3 -2
  23. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs +101 -0
  24. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs.meta +11 -0
  25. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs +464 -0
  26. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs.meta +11 -0
  27. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs +1669 -0
  28. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs.meta +11 -0
  29. package/Runtime/Utils/SevenZip/Compress/LZMA.meta +8 -0
  30. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs +233 -0
  31. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs.meta +11 -0
  32. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs +137 -0
  33. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs.meta +11 -0
  34. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs +170 -0
  35. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs.meta +11 -0
  36. package/Runtime/Utils/SevenZip/Compress/RangeCoder.meta +8 -0
  37. package/Runtime/{Protobuf-Net/System.Runtime.CompilerServices.Unsafe.xml.meta → Utils/SevenZip/Compress.meta} +3 -2
  38. package/Runtime/Utils/SevenZip/ICoder.cs +177 -0
  39. package/Runtime/Utils/SevenZip/ICoder.cs.meta +11 -0
  40. package/Runtime/Utils/SevenZip.meta +3 -0
  41. package/package.json +2 -1
  42. package/Runtime/Protobuf-Net/System.Buffers.dll +0 -0
  43. package/Runtime/Protobuf-Net/System.Buffers.dll.meta +0 -33
  44. package/Runtime/Protobuf-Net/System.Collections.Immutable.xml +0 -6812
  45. package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll +0 -0
  46. package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll.meta +0 -33
  47. package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.xml +0 -342
@@ -0,0 +1,404 @@
1
+ // LzBinTree.cs
2
+
3
+ using System;
4
+
5
+ namespace SevenZip.Compression.LZ
6
+ {
7
+ public class BinTree : InWindow, IMatchFinder
8
+ {
9
+ UInt32 _cyclicBufferPos;
10
+ UInt32 _cyclicBufferSize = 0;
11
+ UInt32 _matchMaxLen;
12
+
13
+ UInt32[] _son;
14
+ UInt32[] _hash;
15
+
16
+ UInt32 _cutValue = 0xFF;
17
+ UInt32 _hashMask;
18
+ UInt32 _hashSizeSum = 0;
19
+
20
+ bool HASH_ARRAY = true;
21
+
22
+ const UInt32 kHash2Size = 1 << 10;
23
+ const UInt32 kHash3Size = 1 << 16;
24
+ const UInt32 kBT2HashSize = 1 << 16;
25
+ const UInt32 kStartMaxLen = 1;
26
+ const UInt32 kHash3Offset = kHash2Size;
27
+ const UInt32 kEmptyHashValue = 0;
28
+ const UInt32 kMaxValForNormalize = ((UInt32)1 << 31) - 1;
29
+
30
+ UInt32 kNumHashDirectBytes = 0;
31
+ UInt32 kMinMatchCheck = 4;
32
+ UInt32 kFixHashSize = kHash2Size + kHash3Size;
33
+
34
+ public void SetType(int numHashBytes)
35
+ {
36
+ HASH_ARRAY = (numHashBytes > 2);
37
+ if (HASH_ARRAY)
38
+ {
39
+ kNumHashDirectBytes = 0;
40
+ kMinMatchCheck = 4;
41
+ kFixHashSize = kHash2Size + kHash3Size;
42
+ }
43
+ else
44
+ {
45
+ kNumHashDirectBytes = 2;
46
+ kMinMatchCheck = 2 + 1;
47
+ kFixHashSize = 0;
48
+ }
49
+ }
50
+
51
+ public new void SetStream(System.IO.Stream stream)
52
+ {
53
+ base.SetStream(stream);
54
+ }
55
+
56
+ public new void ReleaseStream()
57
+ {
58
+ base.ReleaseStream();
59
+ }
60
+
61
+ public new void Init()
62
+ {
63
+ base.Init();
64
+ for (UInt32 i = 0; i < _hashSizeSum; i++)
65
+ _hash[i] = kEmptyHashValue;
66
+ _cyclicBufferPos = 0;
67
+ ReduceOffsets(-1);
68
+ }
69
+
70
+ public new void MovePos()
71
+ {
72
+ if (++_cyclicBufferPos >= _cyclicBufferSize)
73
+ _cyclicBufferPos = 0;
74
+ base.MovePos();
75
+ if (_pos == kMaxValForNormalize)
76
+ Normalize();
77
+ }
78
+
79
+ public new Byte GetIndexByte(Int32 index)
80
+ {
81
+ return base.GetIndexByte(index);
82
+ }
83
+
84
+ public new UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit)
85
+ {
86
+ return base.GetMatchLen(index, distance, limit);
87
+ }
88
+
89
+ public new UInt32 GetNumAvailableBytes()
90
+ {
91
+ return base.GetNumAvailableBytes();
92
+ }
93
+
94
+ public void Create(
95
+ UInt32 historySize,
96
+ UInt32 keepAddBufferBefore,
97
+ UInt32 matchMaxLen,
98
+ UInt32 keepAddBufferAfter
99
+ )
100
+ {
101
+ if (historySize > kMaxValForNormalize - 256)
102
+ throw new Exception();
103
+ _cutValue = 16 + (matchMaxLen >> 1);
104
+
105
+ UInt32 windowReservSize =
106
+ (historySize + keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + 256;
107
+
108
+ base.Create(
109
+ historySize + keepAddBufferBefore,
110
+ matchMaxLen + keepAddBufferAfter,
111
+ windowReservSize
112
+ );
113
+
114
+ _matchMaxLen = matchMaxLen;
115
+
116
+ UInt32 cyclicBufferSize = historySize + 1;
117
+ if (_cyclicBufferSize != cyclicBufferSize)
118
+ _son = new UInt32[(_cyclicBufferSize = cyclicBufferSize) * 2];
119
+
120
+ UInt32 hs = kBT2HashSize;
121
+
122
+ if (HASH_ARRAY)
123
+ {
124
+ hs = historySize - 1;
125
+ hs |= (hs >> 1);
126
+ hs |= (hs >> 2);
127
+ hs |= (hs >> 4);
128
+ hs |= (hs >> 8);
129
+ hs >>= 1;
130
+ hs |= 0xFFFF;
131
+ if (hs > (1 << 24))
132
+ hs >>= 1;
133
+ _hashMask = hs;
134
+ hs++;
135
+ hs += kFixHashSize;
136
+ }
137
+ if (hs != _hashSizeSum)
138
+ _hash = new UInt32[_hashSizeSum = hs];
139
+ }
140
+
141
+ public UInt32 GetMatches(UInt32[] distances)
142
+ {
143
+ UInt32 lenLimit;
144
+ if (_pos + _matchMaxLen <= _streamPos)
145
+ lenLimit = _matchMaxLen;
146
+ else
147
+ {
148
+ lenLimit = _streamPos - _pos;
149
+ if (lenLimit < kMinMatchCheck)
150
+ {
151
+ MovePos();
152
+ return 0;
153
+ }
154
+ }
155
+
156
+ UInt32 offset = 0;
157
+ UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
158
+ UInt32 cur = _bufferOffset + _pos;
159
+ UInt32 maxLen = kStartMaxLen; // to avoid items for len < hashSize;
160
+ UInt32 hashValue,
161
+ hash2Value = 0,
162
+ hash3Value = 0;
163
+
164
+ if (HASH_ARRAY)
165
+ {
166
+ UInt32 temp = CRC.Table[_bufferBase[cur]] ^ _bufferBase[cur + 1];
167
+ hash2Value = temp & (kHash2Size - 1);
168
+ temp ^= ((UInt32)(_bufferBase[cur + 2]) << 8);
169
+ hash3Value = temp & (kHash3Size - 1);
170
+ hashValue = (temp ^ (CRC.Table[_bufferBase[cur + 3]] << 5)) & _hashMask;
171
+ }
172
+ else
173
+ hashValue = _bufferBase[cur] ^ ((UInt32)(_bufferBase[cur + 1]) << 8);
174
+
175
+ UInt32 curMatch = _hash[kFixHashSize + hashValue];
176
+ if (HASH_ARRAY)
177
+ {
178
+ UInt32 curMatch2 = _hash[hash2Value];
179
+ UInt32 curMatch3 = _hash[kHash3Offset + hash3Value];
180
+ _hash[hash2Value] = _pos;
181
+ _hash[kHash3Offset + hash3Value] = _pos;
182
+ if (curMatch2 > matchMinPos)
183
+ if (_bufferBase[_bufferOffset + curMatch2] == _bufferBase[cur])
184
+ {
185
+ distances[offset++] = maxLen = 2;
186
+ distances[offset++] = _pos - curMatch2 - 1;
187
+ }
188
+ if (curMatch3 > matchMinPos)
189
+ if (_bufferBase[_bufferOffset + curMatch3] == _bufferBase[cur])
190
+ {
191
+ if (curMatch3 == curMatch2)
192
+ offset -= 2;
193
+ distances[offset++] = maxLen = 3;
194
+ distances[offset++] = _pos - curMatch3 - 1;
195
+ curMatch2 = curMatch3;
196
+ }
197
+ if (offset != 0 && curMatch2 == curMatch)
198
+ {
199
+ offset -= 2;
200
+ maxLen = kStartMaxLen;
201
+ }
202
+ }
203
+
204
+ _hash[kFixHashSize + hashValue] = _pos;
205
+
206
+ UInt32 ptr0 = (_cyclicBufferPos << 1) + 1;
207
+ UInt32 ptr1 = (_cyclicBufferPos << 1);
208
+
209
+ UInt32 len0,
210
+ len1;
211
+ len0 = len1 = kNumHashDirectBytes;
212
+
213
+ if (kNumHashDirectBytes != 0)
214
+ {
215
+ if (curMatch > matchMinPos)
216
+ {
217
+ if (
218
+ _bufferBase[_bufferOffset + curMatch + kNumHashDirectBytes]
219
+ != _bufferBase[cur + kNumHashDirectBytes]
220
+ )
221
+ {
222
+ distances[offset++] = maxLen = kNumHashDirectBytes;
223
+ distances[offset++] = _pos - curMatch - 1;
224
+ }
225
+ }
226
+ }
227
+
228
+ UInt32 count = _cutValue;
229
+
230
+ while (true)
231
+ {
232
+ if (curMatch <= matchMinPos || count-- == 0)
233
+ {
234
+ _son[ptr0] = _son[ptr1] = kEmptyHashValue;
235
+ break;
236
+ }
237
+ UInt32 delta = _pos - curMatch;
238
+ UInt32 cyclicPos =
239
+ (
240
+ (delta <= _cyclicBufferPos)
241
+ ? (_cyclicBufferPos - delta)
242
+ : (_cyclicBufferPos - delta + _cyclicBufferSize)
243
+ ) << 1;
244
+
245
+ UInt32 pby1 = _bufferOffset + curMatch;
246
+ UInt32 len = Math.Min(len0, len1);
247
+ if (_bufferBase[pby1 + len] == _bufferBase[cur + len])
248
+ {
249
+ while (++len != lenLimit)
250
+ if (_bufferBase[pby1 + len] != _bufferBase[cur + len])
251
+ break;
252
+ if (maxLen < len)
253
+ {
254
+ distances[offset++] = maxLen = len;
255
+ distances[offset++] = delta - 1;
256
+ if (len == lenLimit)
257
+ {
258
+ _son[ptr1] = _son[cyclicPos];
259
+ _son[ptr0] = _son[cyclicPos + 1];
260
+ break;
261
+ }
262
+ }
263
+ }
264
+ if (_bufferBase[pby1 + len] < _bufferBase[cur + len])
265
+ {
266
+ _son[ptr1] = curMatch;
267
+ ptr1 = cyclicPos + 1;
268
+ curMatch = _son[ptr1];
269
+ len1 = len;
270
+ }
271
+ else
272
+ {
273
+ _son[ptr0] = curMatch;
274
+ ptr0 = cyclicPos;
275
+ curMatch = _son[ptr0];
276
+ len0 = len;
277
+ }
278
+ }
279
+ MovePos();
280
+ return offset;
281
+ }
282
+
283
+ public void Skip(UInt32 num)
284
+ {
285
+ do
286
+ {
287
+ UInt32 lenLimit;
288
+ if (_pos + _matchMaxLen <= _streamPos)
289
+ lenLimit = _matchMaxLen;
290
+ else
291
+ {
292
+ lenLimit = _streamPos - _pos;
293
+ if (lenLimit < kMinMatchCheck)
294
+ {
295
+ MovePos();
296
+ continue;
297
+ }
298
+ }
299
+
300
+ UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
301
+ UInt32 cur = _bufferOffset + _pos;
302
+
303
+ UInt32 hashValue;
304
+
305
+ if (HASH_ARRAY)
306
+ {
307
+ UInt32 temp = CRC.Table[_bufferBase[cur]] ^ _bufferBase[cur + 1];
308
+ UInt32 hash2Value = temp & (kHash2Size - 1);
309
+ _hash[hash2Value] = _pos;
310
+ temp ^= ((UInt32)(_bufferBase[cur + 2]) << 8);
311
+ UInt32 hash3Value = temp & (kHash3Size - 1);
312
+ _hash[kHash3Offset + hash3Value] = _pos;
313
+ hashValue = (temp ^ (CRC.Table[_bufferBase[cur + 3]] << 5)) & _hashMask;
314
+ }
315
+ else
316
+ hashValue = _bufferBase[cur] ^ ((UInt32)(_bufferBase[cur + 1]) << 8);
317
+
318
+ UInt32 curMatch = _hash[kFixHashSize + hashValue];
319
+ _hash[kFixHashSize + hashValue] = _pos;
320
+
321
+ UInt32 ptr0 = (_cyclicBufferPos << 1) + 1;
322
+ UInt32 ptr1 = (_cyclicBufferPos << 1);
323
+
324
+ UInt32 len0,
325
+ len1;
326
+ len0 = len1 = kNumHashDirectBytes;
327
+
328
+ UInt32 count = _cutValue;
329
+ while (true)
330
+ {
331
+ if (curMatch <= matchMinPos || count-- == 0)
332
+ {
333
+ _son[ptr0] = _son[ptr1] = kEmptyHashValue;
334
+ break;
335
+ }
336
+
337
+ UInt32 delta = _pos - curMatch;
338
+ UInt32 cyclicPos =
339
+ (
340
+ (delta <= _cyclicBufferPos)
341
+ ? (_cyclicBufferPos - delta)
342
+ : (_cyclicBufferPos - delta + _cyclicBufferSize)
343
+ ) << 1;
344
+
345
+ UInt32 pby1 = _bufferOffset + curMatch;
346
+ UInt32 len = Math.Min(len0, len1);
347
+ if (_bufferBase[pby1 + len] == _bufferBase[cur + len])
348
+ {
349
+ while (++len != lenLimit)
350
+ if (_bufferBase[pby1 + len] != _bufferBase[cur + len])
351
+ break;
352
+ if (len == lenLimit)
353
+ {
354
+ _son[ptr1] = _son[cyclicPos];
355
+ _son[ptr0] = _son[cyclicPos + 1];
356
+ break;
357
+ }
358
+ }
359
+ if (_bufferBase[pby1 + len] < _bufferBase[cur + len])
360
+ {
361
+ _son[ptr1] = curMatch;
362
+ ptr1 = cyclicPos + 1;
363
+ curMatch = _son[ptr1];
364
+ len1 = len;
365
+ }
366
+ else
367
+ {
368
+ _son[ptr0] = curMatch;
369
+ ptr0 = cyclicPos;
370
+ curMatch = _son[ptr0];
371
+ len0 = len;
372
+ }
373
+ }
374
+ MovePos();
375
+ } while (--num != 0);
376
+ }
377
+
378
+ void NormalizeLinks(UInt32[] items, UInt32 numItems, UInt32 subValue)
379
+ {
380
+ for (UInt32 i = 0; i < numItems; i++)
381
+ {
382
+ UInt32 value = items[i];
383
+ if (value <= subValue)
384
+ value = kEmptyHashValue;
385
+ else
386
+ value -= subValue;
387
+ items[i] = value;
388
+ }
389
+ }
390
+
391
+ void Normalize()
392
+ {
393
+ UInt32 subValue = _pos - _cyclicBufferSize;
394
+ NormalizeLinks(_son, _cyclicBufferSize * 2, subValue);
395
+ NormalizeLinks(_hash, _hashSizeSum, subValue);
396
+ ReduceOffsets((Int32)subValue);
397
+ }
398
+
399
+ public void SetCutValue(UInt32 cutValue)
400
+ {
401
+ _cutValue = cutValue;
402
+ }
403
+ }
404
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 1c7a3e8fbd8100045a97f5f4699e013a
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,153 @@
1
+ // LzInWindow.cs
2
+
3
+ using System;
4
+
5
+ namespace SevenZip.Compression.LZ
6
+ {
7
+ public class InWindow
8
+ {
9
+ public Byte[] _bufferBase = null; // pointer to buffer with data
10
+ System.IO.Stream _stream;
11
+ UInt32 _posLimit; // offset (from _buffer) of first byte when new block reading must be done
12
+ bool _streamEndWasReached; // if (true) then _streamPos shows real end of stream
13
+
14
+ UInt32 _pointerToLastSafePosition;
15
+
16
+ public UInt32 _bufferOffset;
17
+
18
+ public UInt32 _blockSize; // Size of Allocated memory block
19
+ public UInt32 _pos; // offset (from _buffer) of curent byte
20
+ UInt32 _keepSizeBefore; // how many BYTEs must be kept in buffer before _pos
21
+ UInt32 _keepSizeAfter; // how many BYTEs must be kept buffer after _pos
22
+ public UInt32 _streamPos; // offset (from _buffer) of first not read byte from Stream
23
+
24
+ public void MoveBlock()
25
+ {
26
+ UInt32 offset = (UInt32)(_bufferOffset) + _pos - _keepSizeBefore;
27
+ // we need one additional byte, since MovePos moves on 1 byte.
28
+ if (offset > 0)
29
+ offset--;
30
+
31
+ UInt32 numBytes = (UInt32)(_bufferOffset) + _streamPos - offset;
32
+
33
+ // check negative offset ????
34
+ for (UInt32 i = 0; i < numBytes; i++)
35
+ _bufferBase[i] = _bufferBase[offset + i];
36
+ _bufferOffset -= offset;
37
+ }
38
+
39
+ public virtual void ReadBlock()
40
+ {
41
+ if (_streamEndWasReached)
42
+ return;
43
+ while (true)
44
+ {
45
+ int size = (int)((0 - _bufferOffset) + _blockSize - _streamPos);
46
+ if (size == 0)
47
+ return;
48
+ int numReadBytes = _stream.Read(
49
+ _bufferBase,
50
+ (int)(_bufferOffset + _streamPos),
51
+ size
52
+ );
53
+ if (numReadBytes == 0)
54
+ {
55
+ _posLimit = _streamPos;
56
+ UInt32 pointerToPostion = _bufferOffset + _posLimit;
57
+ if (pointerToPostion > _pointerToLastSafePosition)
58
+ _posLimit = (UInt32)(_pointerToLastSafePosition - _bufferOffset);
59
+
60
+ _streamEndWasReached = true;
61
+ return;
62
+ }
63
+ _streamPos += (UInt32)numReadBytes;
64
+ if (_streamPos >= _pos + _keepSizeAfter)
65
+ _posLimit = _streamPos - _keepSizeAfter;
66
+ }
67
+ }
68
+
69
+ void Free()
70
+ {
71
+ _bufferBase = null;
72
+ }
73
+
74
+ public void Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv)
75
+ {
76
+ _keepSizeBefore = keepSizeBefore;
77
+ _keepSizeAfter = keepSizeAfter;
78
+ UInt32 blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;
79
+ if (_bufferBase == null || _blockSize != blockSize)
80
+ {
81
+ Free();
82
+ _blockSize = blockSize;
83
+ _bufferBase = new Byte[_blockSize];
84
+ }
85
+ _pointerToLastSafePosition = _blockSize - keepSizeAfter;
86
+ }
87
+
88
+ public void SetStream(System.IO.Stream stream)
89
+ {
90
+ _stream = stream;
91
+ }
92
+
93
+ public void ReleaseStream()
94
+ {
95
+ _stream = null;
96
+ }
97
+
98
+ public void Init()
99
+ {
100
+ _bufferOffset = 0;
101
+ _pos = 0;
102
+ _streamPos = 0;
103
+ _streamEndWasReached = false;
104
+ ReadBlock();
105
+ }
106
+
107
+ public void MovePos()
108
+ {
109
+ _pos++;
110
+ if (_pos > _posLimit)
111
+ {
112
+ UInt32 pointerToPostion = _bufferOffset + _pos;
113
+ if (pointerToPostion > _pointerToLastSafePosition)
114
+ MoveBlock();
115
+ ReadBlock();
116
+ }
117
+ }
118
+
119
+ public Byte GetIndexByte(Int32 index)
120
+ {
121
+ return _bufferBase[_bufferOffset + _pos + index];
122
+ }
123
+
124
+ // index + limit have not to exceed _keepSizeAfter;
125
+ public UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit)
126
+ {
127
+ if (_streamEndWasReached)
128
+ if ((_pos + index) + limit > _streamPos)
129
+ limit = _streamPos - (UInt32)(_pos + index);
130
+ distance++;
131
+ // Byte *pby = _buffer + (size_t)_pos + index;
132
+ UInt32 pby = _bufferOffset + _pos + (UInt32)index;
133
+
134
+ UInt32 i;
135
+ for (i = 0; i < limit && _bufferBase[pby + i] == _bufferBase[pby + i - distance]; i++)
136
+ ;
137
+ return i;
138
+ }
139
+
140
+ public UInt32 GetNumAvailableBytes()
141
+ {
142
+ return _streamPos - _pos;
143
+ }
144
+
145
+ public void ReduceOffsets(Int32 subValue)
146
+ {
147
+ _bufferOffset += (UInt32)subValue;
148
+ _posLimit -= (UInt32)subValue;
149
+ _pos -= (UInt32)subValue;
150
+ _streamPos -= (UInt32)subValue;
151
+ }
152
+ }
153
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b36e493dd9a99374aaa2a238bc53a389
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,110 @@
1
+ // LzOutWindow.cs
2
+
3
+ namespace SevenZip.Compression.LZ
4
+ {
5
+ public class OutWindow
6
+ {
7
+ byte[] _buffer = null;
8
+ uint _pos;
9
+ uint _windowSize = 0;
10
+ uint _streamPos;
11
+ System.IO.Stream _stream;
12
+
13
+ public uint TrainSize = 0;
14
+
15
+ public void Create(uint windowSize)
16
+ {
17
+ if (_windowSize != windowSize)
18
+ {
19
+ // System.GC.Collect();
20
+ _buffer = new byte[windowSize];
21
+ }
22
+ _windowSize = windowSize;
23
+ _pos = 0;
24
+ _streamPos = 0;
25
+ }
26
+
27
+ public void Init(System.IO.Stream stream, bool solid)
28
+ {
29
+ ReleaseStream();
30
+ _stream = stream;
31
+ if (!solid)
32
+ {
33
+ _streamPos = 0;
34
+ _pos = 0;
35
+ TrainSize = 0;
36
+ }
37
+ }
38
+
39
+ public bool Train(System.IO.Stream stream)
40
+ {
41
+ long len = stream.Length;
42
+ uint size = (len < _windowSize) ? (uint)len : _windowSize;
43
+ TrainSize = size;
44
+ stream.Position = len - size;
45
+ _streamPos = _pos = 0;
46
+ while (size > 0)
47
+ {
48
+ uint curSize = _windowSize - _pos;
49
+ if (size < curSize)
50
+ curSize = size;
51
+ int numReadBytes = stream.Read(_buffer, (int)_pos, (int)curSize);
52
+ if (numReadBytes == 0)
53
+ return false;
54
+ size -= (uint)numReadBytes;
55
+ _pos += (uint)numReadBytes;
56
+ _streamPos += (uint)numReadBytes;
57
+ if (_pos == _windowSize)
58
+ _streamPos = _pos = 0;
59
+ }
60
+ return true;
61
+ }
62
+
63
+ public void ReleaseStream()
64
+ {
65
+ Flush();
66
+ _stream = null;
67
+ }
68
+
69
+ public void Flush()
70
+ {
71
+ uint size = _pos - _streamPos;
72
+ if (size == 0)
73
+ return;
74
+ _stream.Write(_buffer, (int)_streamPos, (int)size);
75
+ if (_pos >= _windowSize)
76
+ _pos = 0;
77
+ _streamPos = _pos;
78
+ }
79
+
80
+ public void CopyBlock(uint distance, uint len)
81
+ {
82
+ uint pos = _pos - distance - 1;
83
+ if (pos >= _windowSize)
84
+ pos += _windowSize;
85
+ for (; len > 0; len--)
86
+ {
87
+ if (pos >= _windowSize)
88
+ pos = 0;
89
+ _buffer[_pos++] = _buffer[pos++];
90
+ if (_pos >= _windowSize)
91
+ Flush();
92
+ }
93
+ }
94
+
95
+ public void PutByte(byte b)
96
+ {
97
+ _buffer[_pos++] = b;
98
+ if (_pos >= _windowSize)
99
+ Flush();
100
+ }
101
+
102
+ public byte GetByte(uint distance)
103
+ {
104
+ uint pos = _pos - distance - 1;
105
+ if (pos >= _windowSize)
106
+ pos += _windowSize;
107
+ return _buffer[pos];
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: f1876183fd68b2142ba99f3bf38815f5
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: