Mercurial > repos > SharpZipLib
annotate BZip2/BZip2OutputStream.cs @ 1:94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
Initial commit of clean SharpZipLib 0860 source. Only change is build paths.
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 30 Oct 2010 14:03:17 +0000 |
parents | |
children |
rev | line source |
---|---|
1
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // BZip2OutputStream.cs |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // Copyright (C) 2001 Mike Krueger |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 // |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 // This program is free software; you can redistribute it and/or |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 // modify it under the terms of the GNU General Public License |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 // as published by the Free Software Foundation; either version 2 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 // of the License, or (at your option) any later version. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 // |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 // This program is distributed in the hope that it will be useful, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 // GNU General Public License for more details. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 // |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 // You should have received a copy of the GNU General Public License |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 // along with this program; if not, write to the Free Software |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 // |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 // Linking this library statically or dynamically with other modules is |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 // making a combined work based on this library. Thus, the terms and |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 // conditions of the GNU General Public License cover the whole |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 // combination. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 // |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 // As a special exception, the copyright holders of this library give you |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 // permission to link this library with independent modules to produce an |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 // executable, regardless of the license terms of these independent |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 // modules, and to copy and distribute the resulting executable under |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 // terms of your choice, provided that you also meet, for each linked |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 // independent module, the terms and conditions of the license of that |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 // module. An independent module is a module which is not derived from |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 // or based on this library. If you modify this library, you may extend |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 // this exception to your version of the library, but you are not |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 // obligated to do so. If you do not wish to do so, delete this |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 // exception statement from your version. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 using System; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 using System.IO; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 using ICSharpCode.SharpZipLib.Checksums; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 namespace ICSharpCode.SharpZipLib.BZip2 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 // TODO: Update to BZip2 1.0.1, 1.0.2 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 /// An output stream that compresses into the BZip2 format |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 /// including file header chars into another stream. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 public class BZip2OutputStream : Stream |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 #region Constants |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 const int SETMASK = (1 << 21); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 const int CLEARMASK = (~SETMASK); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 const int GREATER_ICOST = 15; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 const int LESSER_ICOST = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 const int SMALL_THRESH = 20; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 const int DEPTH_THRESH = 10; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 If you are ever unlucky/improbable enough |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 to get a stack overflow whilst sorting, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 increase the following constant and try |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 again. In practice I have never seen the |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 stack go above 27 elems, so the following |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 limit seems very generous. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 const int QSORT_STACK_SIZE = 1000; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 Knuth's increments seem to work better |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 than Incerpi-Sedgewick here. Possibly |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 because the number of elems to sort is |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 usually small, typically <= 20. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 readonly int[] increments = new int[] { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 1, 4, 13, 40, 121, 364, 1093, 3280, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 9841, 29524, 88573, 265720, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 797161, 2391484 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 }; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 #endregion |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 #region Constructors |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 /// Construct a default output stream with maximum block size |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 /// <param name="stream">The stream to write BZip data onto.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 public BZip2OutputStream(Stream stream) : this(stream, 9) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 /// Initialise a new instance of the <see cref="BZip2OutputStream"></see> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 /// for the specified stream, using the given blocksize. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
96 /// <param name="stream">The stream to write compressed data to.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 /// <param name="blockSize">The block size to use.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
98 /// <remarks> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
99 /// Valid block sizes are in the range 1..9, with 1 giving |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
100 /// the lowest compression and 9 the highest. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 /// </remarks> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 public BZip2OutputStream(Stream stream, int blockSize) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 BsSetStream(stream); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
105 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
106 workFactor = 50; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
107 if (blockSize > 9) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
108 blockSize = 9; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
109 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
110 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
111 if (blockSize < 1) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
112 blockSize = 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
113 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
114 blockSize100k = blockSize; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
115 AllocateCompressStructures(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
116 Initialize(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
117 InitBlock(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
118 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
119 #endregion |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
120 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
121 #region Destructor |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
122 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
123 /// Ensures that resources are freed and other cleanup operations |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
124 /// are performed when the garbage collector reclaims the BZip2OutputStream. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
125 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
126 ~BZip2OutputStream() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
127 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
128 Dispose(false); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
129 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
130 #endregion |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
132 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
133 /// Get/set flag indicating ownership of underlying stream. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 /// When the flag is true <see cref="Close"></see> will close the underlying stream also. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
136 public bool IsStreamOwner |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
137 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
138 get { return isStreamOwner; } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
139 set { isStreamOwner = value; } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
141 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
142 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
143 #region Stream overrides |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
145 /// Gets a value indicating whether the current stream supports reading |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
146 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
147 public override bool CanRead |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
148 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
149 get { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
150 return false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
151 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
152 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
153 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
154 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
155 /// Gets a value indicating whether the current stream supports seeking |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
156 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
157 public override bool CanSeek { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
158 get { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
159 return false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
160 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
161 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
162 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
163 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 /// Gets a value indicating whether the current stream supports writing |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 public override bool CanWrite { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 get { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
168 return baseStream.CanWrite; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
170 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
171 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
173 /// Gets the length in bytes of the stream |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
174 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 public override long Length { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
176 get { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 return baseStream.Length; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
181 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
182 /// Gets or sets the current position of this stream. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
183 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
184 public override long Position { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
185 get { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
186 return baseStream.Position; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
187 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
188 set { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
189 throw new NotSupportedException("BZip2OutputStream position cannot be set"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
190 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
191 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
192 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
193 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
194 /// Sets the current position of this stream to the given value. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
195 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
196 /// <param name="offset">The point relative to the offset from which to being seeking.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
197 /// <param name="origin">The reference point from which to begin seeking.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
198 /// <returns>The new position in the stream.</returns> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
199 public override long Seek(long offset, SeekOrigin origin) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
200 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 throw new NotSupportedException("BZip2OutputStream Seek not supported"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
202 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
203 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
204 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
205 /// Sets the length of this stream to the given value. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
206 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
207 /// <param name="value">The new stream length.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
208 public override void SetLength(long value) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
209 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
210 throw new NotSupportedException("BZip2OutputStream SetLength not supported"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
211 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
212 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
213 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
214 /// Read a byte from the stream advancing the position. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
215 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 /// <returns>The byte read cast to an int; -1 if end of stream.</returns> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
217 public override int ReadByte() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
218 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
219 throw new NotSupportedException("BZip2OutputStream ReadByte not supported"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
220 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
221 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
222 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
223 /// Read a block of bytes |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
224 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
225 /// <param name="buffer">The buffer to read into.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
226 /// <param name="offset">The offset in the buffer to start storing data at.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
227 /// <param name="count">The maximum number of bytes to read.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
228 /// <returns>The total number of bytes read. This might be less than the number of bytes |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
229 /// requested if that number of bytes are not currently available, or zero |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
230 /// if the end of the stream is reached.</returns> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
231 public override int Read(byte[] buffer, int offset, int count) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
232 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
233 throw new NotSupportedException("BZip2OutputStream Read not supported"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
234 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
235 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
236 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
237 /// Write a block of bytes to the stream |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
238 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
239 /// <param name="buffer">The buffer containing data to write.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
240 /// <param name="offset">The offset of the first byte to write.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
241 /// <param name="count">The number of bytes to write.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
242 public override void Write(byte[] buffer, int offset, int count) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
243 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
244 if ( buffer == null ) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
245 throw new ArgumentNullException("buffer"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
246 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
247 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
248 if ( offset < 0 ) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
249 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
250 throw new ArgumentOutOfRangeException("offset"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
251 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
252 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
253 if ( count < 0 ) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
254 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
255 throw new ArgumentOutOfRangeException("count"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
256 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
257 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
258 if ( buffer.Length - offset < count ) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
259 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
260 throw new ArgumentException("Offset/count out of range"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
261 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
262 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
263 for (int i = 0; i < count; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
264 WriteByte(buffer[offset + i]); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
265 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
266 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
267 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
268 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
269 /// Write a byte to the stream. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
270 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
271 /// <param name="value">The byte to write to the stream.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
272 public override void WriteByte(byte value) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
273 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
274 int b = (256 + value) % 256; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
275 if (currentChar != -1) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
276 if (currentChar == b) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
277 runLength++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
278 if (runLength > 254) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
279 WriteRun(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
280 currentChar = -1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
281 runLength = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
282 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
283 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
284 WriteRun(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
285 runLength = 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
286 currentChar = b; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
287 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
288 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
289 currentChar = b; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
290 runLength++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
291 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
292 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
293 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
294 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
295 /// End the current block and end compression. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
296 /// Close the stream and free any resources |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
297 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
298 public override void Close() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
299 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
300 Dispose(true); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
301 GC.SuppressFinalize(this); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
302 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
303 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
304 #endregion |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
305 void MakeMaps() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
306 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
307 nInUse = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
308 for (int i = 0; i < 256; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
309 if (inUse[i]) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
310 seqToUnseq[nInUse] = (char)i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
311 unseqToSeq[i] = (char)nInUse; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
312 nInUse++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
313 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
314 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
315 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
316 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
317 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
318 /// Get the number of bytes written to output. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
319 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
320 void WriteRun() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
321 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
322 if (last < allowableBlockSize) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
323 inUse[currentChar] = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
324 for (int i = 0; i < runLength; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
325 mCrc.Update(currentChar); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
326 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
327 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
328 switch (runLength) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
329 case 1: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
330 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
331 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
332 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
333 case 2: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
334 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
335 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
336 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
337 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
338 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
339 case 3: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
340 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
341 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
342 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
343 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
344 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
345 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
346 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
347 default: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
348 inUse[runLength - 4] = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
349 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
350 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
351 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
352 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
353 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
354 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
355 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
356 block[last + 1] = (byte)currentChar; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
357 last++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
358 block[last + 1] = (byte)(runLength - 4); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
359 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
360 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
361 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
362 EndBlock(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
363 InitBlock(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
364 WriteRun(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
365 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
366 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
367 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
368 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
369 /// Get the number of bytes written to the output. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
370 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
371 public int BytesWritten |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
372 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
373 get { return bytesOut; } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
374 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
375 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
376 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
377 /// Releases the unmanaged resources used by the <see cref="BZip2OutputStream"/> and optionally releases the managed resources. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
378 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
379 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
380 #if NET_1_0 || NET_1_1 || NETCF_1_0 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
381 protected virtual void Dispose(bool disposing) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
382 #else |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
383 override protected void Dispose(bool disposing) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
384 #endif |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
385 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
386 try { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
387 #if !NET_1_0 && !NET_1_1 && !NETCF_1_0 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
388 base.Dispose(disposing); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
389 #endif |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
390 if( !disposed_ ) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
391 disposed_=true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
392 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
393 if( runLength>0 ) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
394 WriteRun(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
395 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
396 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
397 currentChar=-1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
398 EndBlock(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
399 EndCompression(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
400 Flush(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
401 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
402 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
403 finally { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
404 if ( disposing ) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
405 if ( IsStreamOwner ) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
406 baseStream.Close(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
407 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
408 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
409 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
410 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
411 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
412 /// <summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
413 /// Flush output buffers |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
414 /// </summary> |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
415 public override void Flush() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
416 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
417 baseStream.Flush(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
418 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
419 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
420 void Initialize() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
421 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
422 bytesOut = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
423 nBlocksRandomised = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
424 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
425 /*--- Write header `magic' bytes indicating file-format == huffmanised, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
426 followed by a digit indicating blockSize100k. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
427 ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
428 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
429 BsPutUChar('B'); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
430 BsPutUChar('Z'); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
431 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
432 BsPutUChar('h'); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
433 BsPutUChar('0' + blockSize100k); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
434 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
435 combinedCRC = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
436 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
437 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
438 void InitBlock() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
439 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
440 mCrc.Reset(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
441 last = -1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
442 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
443 for (int i = 0; i < 256; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
444 inUse[i] = false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
445 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
446 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
447 /*--- 20 is just a paranoia constant ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
448 allowableBlockSize = BZip2Constants.BaseBlockSize * blockSize100k - 20; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
449 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
450 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
451 void EndBlock() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
452 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
453 if (last < 0) { // dont do anything for empty files, (makes empty files compatible with original Bzip) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
454 return; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
455 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
456 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
457 blockCRC = unchecked((uint)mCrc.Value); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
458 combinedCRC = (combinedCRC << 1) | (combinedCRC >> 31); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
459 combinedCRC ^= blockCRC; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
460 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
461 /*-- sort the block and establish position of original string --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
462 DoReversibleTransformation(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
463 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
464 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
465 A 6-byte block header, the value chosen arbitrarily |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
466 as 0x314159265359 :-). A 32 bit value does not really |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
467 give a strong enough guarantee that the value will not |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
468 appear by chance in the compressed datastream. Worst-case |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
469 probability of this event, for a 900k block, is about |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
470 2.0e-3 for 32 bits, 1.0e-5 for 40 bits and 4.0e-8 for 48 bits. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
471 For a compressed file of size 100Gb -- about 100000 blocks -- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
472 only a 48-bit marker will do. NB: normal compression/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
473 decompression do *not* rely on these statistical properties. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
474 They are only important when trying to recover blocks from |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
475 damaged files. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
476 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
477 BsPutUChar(0x31); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
478 BsPutUChar(0x41); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
479 BsPutUChar(0x59); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
480 BsPutUChar(0x26); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
481 BsPutUChar(0x53); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
482 BsPutUChar(0x59); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
483 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
484 /*-- Now the block's CRC, so it is in a known place. --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
485 unchecked { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
486 BsPutint((int)blockCRC); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
487 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
488 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
489 /*-- Now a single bit indicating randomisation. --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
490 if (blockRandomised) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
491 BsW(1,1); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
492 nBlocksRandomised++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
493 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
494 BsW(1,0); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
495 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
496 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
497 /*-- Finally, block's contents proper. --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
498 MoveToFrontCodeAndSend(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
499 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
500 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
501 void EndCompression() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
502 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
503 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
504 Now another magic 48-bit number, 0x177245385090, to |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
505 indicate the end of the last block. (sqrt(pi), if |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
506 you want to know. I did want to use e, but it contains |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
507 too much repetition -- 27 18 28 18 28 46 -- for me |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
508 to feel statistically comfortable. Call me paranoid.) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
509 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
510 BsPutUChar(0x17); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
511 BsPutUChar(0x72); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
512 BsPutUChar(0x45); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
513 BsPutUChar(0x38); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
514 BsPutUChar(0x50); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
515 BsPutUChar(0x90); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
516 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
517 unchecked { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
518 BsPutint((int)combinedCRC); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
519 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
520 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
521 BsFinishedWithStream(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
522 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
523 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
524 void BsSetStream(Stream stream) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
525 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
526 baseStream = stream; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
527 bsLive = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
528 bsBuff = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
529 bytesOut = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
530 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
531 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
532 void BsFinishedWithStream() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
533 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
534 while (bsLive > 0) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
535 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
536 int ch = (bsBuff >> 24); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
537 baseStream.WriteByte((byte)ch); // write 8-bit |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
538 bsBuff <<= 8; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
539 bsLive -= 8; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
540 bytesOut++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
541 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
542 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
543 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
544 void BsW(int n, int v) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
545 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
546 while (bsLive >= 8) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
547 int ch = (bsBuff >> 24); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
548 unchecked{baseStream.WriteByte((byte)ch);} // write 8-bit |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
549 bsBuff <<= 8; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
550 bsLive -= 8; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
551 ++bytesOut; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
552 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
553 bsBuff |= (v << (32 - bsLive - n)); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
554 bsLive += n; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
555 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
556 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
557 void BsPutUChar(int c) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
558 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
559 BsW(8, c); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
560 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
561 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
562 void BsPutint(int u) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
563 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
564 BsW(8, (u >> 24) & 0xFF); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
565 BsW(8, (u >> 16) & 0xFF); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
566 BsW(8, (u >> 8) & 0xFF); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
567 BsW(8, u & 0xFF); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
568 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
569 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
570 void BsPutIntVS(int numBits, int c) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
571 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
572 BsW(numBits, c); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
573 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
574 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
575 void SendMTFValues() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
576 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
577 char[][] len = new char[BZip2Constants.GroupCount][]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
578 for (int i = 0; i < BZip2Constants.GroupCount; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
579 len[i] = new char[BZip2Constants.MaximumAlphaSize]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
580 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
581 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
582 int gs, ge, totc, bt, bc, iter; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
583 int nSelectors = 0, alphaSize, minLen, maxLen, selCtr; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
584 int nGroups; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
585 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
586 alphaSize = nInUse + 2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
587 for (int t = 0; t < BZip2Constants.GroupCount; t++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
588 for (int v = 0; v < alphaSize; v++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
589 len[t][v] = (char)GREATER_ICOST; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
590 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
591 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
592 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
593 /*--- Decide how many coding tables to use ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
594 if (nMTF <= 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
595 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
596 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
597 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
598 if (nMTF < 200) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
599 nGroups = 2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
600 } else if (nMTF < 600) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
601 nGroups = 3; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
602 } else if (nMTF < 1200) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
603 nGroups = 4; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
604 } else if (nMTF < 2400) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
605 nGroups = 5; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
606 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
607 nGroups = 6; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
608 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
609 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
610 /*--- Generate an initial set of coding tables ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
611 int nPart = nGroups; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
612 int remF = nMTF; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
613 gs = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
614 while (nPart > 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
615 int tFreq = remF / nPart; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
616 int aFreq = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
617 ge = gs - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
618 while (aFreq < tFreq && ge < alphaSize - 1) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
619 ge++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
620 aFreq += mtfFreq[ge]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
621 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
622 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
623 if (ge > gs && nPart != nGroups && nPart != 1 && ((nGroups - nPart) % 2 == 1)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
624 aFreq -= mtfFreq[ge]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
625 ge--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
626 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
627 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
628 for (int v = 0; v < alphaSize; v++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
629 if (v >= gs && v <= ge) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
630 len[nPart - 1][v] = (char)LESSER_ICOST; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
631 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
632 len[nPart - 1][v] = (char)GREATER_ICOST; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
633 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
634 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
635 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
636 nPart--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
637 gs = ge + 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
638 remF -= aFreq; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
639 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
640 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
641 int[][] rfreq = new int[BZip2Constants.GroupCount][]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
642 for (int i = 0; i < BZip2Constants.GroupCount; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
643 rfreq[i] = new int[BZip2Constants.MaximumAlphaSize]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
644 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
645 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
646 int[] fave = new int[BZip2Constants.GroupCount]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
647 short[] cost = new short[BZip2Constants.GroupCount]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
648 /*--- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
649 Iterate up to N_ITERS times to improve the tables. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
650 ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
651 for (iter = 0; iter < BZip2Constants.NumberOfIterations; ++iter) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
652 for (int t = 0; t < nGroups; ++t) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
653 fave[t] = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
654 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
655 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
656 for (int t = 0; t < nGroups; ++t) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
657 for (int v = 0; v < alphaSize; ++v) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
658 rfreq[t][v] = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
659 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
660 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
661 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
662 nSelectors = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
663 totc = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
664 gs = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
665 while (true) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
666 /*--- Set group start & end marks. --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
667 if (gs >= nMTF) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
668 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
669 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
670 ge = gs + BZip2Constants.GroupSize - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
671 if (ge >= nMTF) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
672 ge = nMTF - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
673 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
674 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
675 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
676 Calculate the cost of this group as coded |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
677 by each of the coding tables. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
678 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
679 for (int t = 0; t < nGroups; t++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
680 cost[t] = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
681 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
682 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
683 if (nGroups == 6) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
684 short cost0, cost1, cost2, cost3, cost4, cost5; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
685 cost0 = cost1 = cost2 = cost3 = cost4 = cost5 = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
686 for (int i = gs; i <= ge; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
687 short icv = szptr[i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
688 cost0 += (short)len[0][icv]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
689 cost1 += (short)len[1][icv]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
690 cost2 += (short)len[2][icv]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
691 cost3 += (short)len[3][icv]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
692 cost4 += (short)len[4][icv]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
693 cost5 += (short)len[5][icv]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
694 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
695 cost[0] = cost0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
696 cost[1] = cost1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
697 cost[2] = cost2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
698 cost[3] = cost3; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
699 cost[4] = cost4; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
700 cost[5] = cost5; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
701 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
702 for (int i = gs; i <= ge; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
703 short icv = szptr[i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
704 for (int t = 0; t < nGroups; t++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
705 cost[t] += (short)len[t][icv]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
706 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
707 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
708 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
709 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
710 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
711 Find the coding table which is best for this group, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
712 and record its identity in the selector table. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
713 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
714 bc = 999999999; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
715 bt = -1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
716 for (int t = 0; t < nGroups; ++t) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
717 if (cost[t] < bc) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
718 bc = cost[t]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
719 bt = t; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
720 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
721 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
722 totc += bc; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
723 fave[bt]++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
724 selector[nSelectors] = (char)bt; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
725 nSelectors++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
726 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
727 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
728 Increment the symbol frequencies for the selected table. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
729 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
730 for (int i = gs; i <= ge; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
731 ++rfreq[bt][szptr[i]]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
732 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
733 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
734 gs = ge+1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
735 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
736 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
737 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
738 Recompute the tables based on the accumulated frequencies. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
739 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
740 for (int t = 0; t < nGroups; ++t) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
741 HbMakeCodeLengths(len[t], rfreq[t], alphaSize, 20); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
742 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
743 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
744 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
745 rfreq = null; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
746 fave = null; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
747 cost = null; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
748 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
749 if (!(nGroups < 8)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
750 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
751 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
752 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
753 if (!(nSelectors < 32768 && nSelectors <= (2 + (900000 / BZip2Constants.GroupSize)))) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
754 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
755 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
756 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
757 /*--- Compute MTF values for the selectors. ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
758 char[] pos = new char[BZip2Constants.GroupCount]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
759 char ll_i, tmp2, tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
760 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
761 for (int i = 0; i < nGroups; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
762 pos[i] = (char)i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
763 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
764 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
765 for (int i = 0; i < nSelectors; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
766 ll_i = selector[i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
767 int j = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
768 tmp = pos[j]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
769 while (ll_i != tmp) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
770 j++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
771 tmp2 = tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
772 tmp = pos[j]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
773 pos[j] = tmp2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
774 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
775 pos[0] = tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
776 selectorMtf[i] = (char)j; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
777 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
778 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
779 int[][] code = new int[BZip2Constants.GroupCount][]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
780 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
781 for (int i = 0; i < BZip2Constants.GroupCount; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
782 code[i] = new int[BZip2Constants.MaximumAlphaSize]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
783 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
784 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
785 /*--- Assign actual codes for the tables. --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
786 for (int t = 0; t < nGroups; t++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
787 minLen = 32; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
788 maxLen = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
789 for (int i = 0; i < alphaSize; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
790 if (len[t][i] > maxLen) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
791 maxLen = len[t][i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
792 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
793 if (len[t][i] < minLen) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
794 minLen = len[t][i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
795 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
796 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
797 if (maxLen > 20) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
798 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
799 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
800 if (minLen < 1) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
801 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
802 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
803 HbAssignCodes(code[t], len[t], minLen, maxLen, alphaSize); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
804 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
805 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
806 /*--- Transmit the mapping table. ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
807 bool[] inUse16 = new bool[16]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
808 for (int i = 0; i < 16; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
809 inUse16[i] = false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
810 for (int j = 0; j < 16; ++j) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
811 if (inUse[i * 16 + j]) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
812 inUse16[i] = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
813 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
814 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
815 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
816 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
817 for (int i = 0; i < 16; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
818 if (inUse16[i]) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
819 BsW(1,1); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
820 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
821 BsW(1,0); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
822 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
823 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
824 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
825 for (int i = 0; i < 16; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
826 if (inUse16[i]) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
827 for (int j = 0; j < 16; ++j) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
828 if (inUse[i * 16 + j]) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
829 BsW(1,1); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
830 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
831 BsW(1,0); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
832 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
833 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
834 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
835 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
836 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
837 /*--- Now the selectors. ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
838 BsW(3, nGroups); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
839 BsW(15, nSelectors); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
840 for (int i = 0; i < nSelectors; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
841 for (int j = 0; j < selectorMtf[i]; ++j) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
842 BsW(1,1); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
843 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
844 BsW(1,0); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
845 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
846 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
847 /*--- Now the coding tables. ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
848 for (int t = 0; t < nGroups; ++t) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
849 int curr = len[t][0]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
850 BsW(5, curr); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
851 for (int i = 0; i < alphaSize; ++i) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
852 while (curr < len[t][i]) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
853 BsW(2, 2); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
854 curr++; /* 10 */ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
855 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
856 while (curr > len[t][i]) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
857 BsW(2, 3); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
858 curr--; /* 11 */ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
859 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
860 BsW (1, 0); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
861 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
862 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
863 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
864 /*--- And finally, the block data proper ---*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
865 selCtr = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
866 gs = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
867 while (true) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
868 if (gs >= nMTF) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
869 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
870 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
871 ge = gs + BZip2Constants.GroupSize - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
872 if (ge >= nMTF) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
873 ge = nMTF - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
874 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
875 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
876 for (int i = gs; i <= ge; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
877 BsW(len[selector[selCtr]][szptr[i]], code[selector[selCtr]][szptr[i]]); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
878 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
879 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
880 gs = ge + 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
881 ++selCtr; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
882 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
883 if (!(selCtr == nSelectors)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
884 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
885 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
886 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
887 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
888 void MoveToFrontCodeAndSend () |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
889 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
890 BsPutIntVS(24, origPtr); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
891 GenerateMTFValues(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
892 SendMTFValues(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
893 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
894 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
895 void SimpleSort(int lo, int hi, int d) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
896 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
897 int i, j, h, bigN, hp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
898 int v; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
899 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
900 bigN = hi - lo + 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
901 if (bigN < 2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
902 return; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
903 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
904 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
905 hp = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
906 while (increments[hp] < bigN) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
907 hp++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
908 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
909 hp--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
910 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
911 for (; hp >= 0; hp--) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
912 h = increments[hp]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
913 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
914 i = lo + h; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
915 while (true) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
916 /*-- copy 1 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
917 if (i > hi) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
918 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
919 v = zptr[i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
920 j = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
921 while (FullGtU(zptr[j-h]+d, v+d)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
922 zptr[j] = zptr[j-h]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
923 j = j - h; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
924 if (j <= (lo + h - 1)) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
925 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
926 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
927 zptr[j] = v; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
928 i++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
929 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
930 /*-- copy 2 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
931 if (i > hi) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
932 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
933 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
934 v = zptr[i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
935 j = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
936 while (FullGtU ( zptr[j-h]+d, v+d )) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
937 zptr[j] = zptr[j-h]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
938 j = j - h; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
939 if (j <= (lo + h - 1)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
940 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
941 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
942 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
943 zptr[j] = v; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
944 i++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
945 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
946 /*-- copy 3 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
947 if (i > hi) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
948 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
949 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
950 v = zptr[i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
951 j = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
952 while (FullGtU ( zptr[j-h]+d, v+d)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
953 zptr[j] = zptr[j-h]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
954 j = j - h; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
955 if (j <= (lo + h - 1)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
956 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
957 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
958 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
959 zptr[j] = v; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
960 i++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
961 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
962 if (workDone > workLimit && firstAttempt) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
963 return; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
964 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
965 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
966 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
967 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
968 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
969 void Vswap(int p1, int p2, int n ) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
970 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
971 int temp = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
972 while (n > 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
973 temp = zptr[p1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
974 zptr[p1] = zptr[p2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
975 zptr[p2] = temp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
976 p1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
977 p2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
978 n--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
979 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
980 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
981 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
982 void QSort3(int loSt, int hiSt, int dSt) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
983 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
984 int unLo, unHi, ltLo, gtHi, med, n, m; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
985 int lo, hi, d; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
986 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
987 StackElement[] stack = new StackElement[QSORT_STACK_SIZE]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
988 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
989 int sp = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
990 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
991 stack[sp].ll = loSt; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
992 stack[sp].hh = hiSt; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
993 stack[sp].dd = dSt; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
994 sp++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
995 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
996 while (sp > 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
997 if (sp >= QSORT_STACK_SIZE) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
998 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
999 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1000 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1001 sp--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1002 lo = stack[sp].ll; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1003 hi = stack[sp].hh; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1004 d = stack[sp].dd; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1005 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1006 if (hi - lo < SMALL_THRESH || d > DEPTH_THRESH) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1007 SimpleSort(lo, hi, d); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1008 if (workDone > workLimit && firstAttempt) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1009 return; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1010 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1011 continue; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1012 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1013 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1014 med = Med3(block[zptr[lo] + d + 1], |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1015 block[zptr[hi ] + d + 1], |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1016 block[zptr[(lo + hi) >> 1] + d + 1]); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1017 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1018 unLo = ltLo = lo; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1019 unHi = gtHi = hi; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1020 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1021 while (true) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1022 while (true) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1023 if (unLo > unHi) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1024 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1025 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1026 n = ((int)block[zptr[unLo]+d + 1]) - med; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1027 if (n == 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1028 int temp = zptr[unLo]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1029 zptr[unLo] = zptr[ltLo]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1030 zptr[ltLo] = temp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1031 ltLo++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1032 unLo++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1033 continue; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1034 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1035 if (n > 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1036 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1037 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1038 unLo++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1039 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1040 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1041 while (true) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1042 if (unLo > unHi) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1043 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1044 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1045 n = ((int)block[zptr[unHi]+d + 1]) - med; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1046 if (n == 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1047 int temp = zptr[unHi]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1048 zptr[unHi] = zptr[gtHi]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1049 zptr[gtHi] = temp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1050 gtHi--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1051 unHi--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1052 continue; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1053 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1054 if (n < 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1055 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1056 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1057 unHi--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1058 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1059 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1060 if (unLo > unHi) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1061 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1062 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1063 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1064 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1065 int temp = zptr[unLo]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1066 zptr[unLo] = zptr[unHi]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1067 zptr[unHi] = temp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1068 unLo++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1069 unHi--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1070 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1071 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1072 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1073 if (gtHi < ltLo) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1074 stack[sp].ll = lo; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1075 stack[sp].hh = hi; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1076 stack[sp].dd = d+1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1077 sp++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1078 continue; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1079 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1080 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1081 n = ((ltLo-lo) < (unLo-ltLo)) ? (ltLo-lo) : (unLo-ltLo); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1082 Vswap(lo, unLo-n, n); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1083 m = ((hi-gtHi) < (gtHi-unHi)) ? (hi-gtHi) : (gtHi-unHi); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1084 Vswap(unLo, hi-m+1, m); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1085 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1086 n = lo + unLo - ltLo - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1087 m = hi - (gtHi - unHi) + 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1088 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1089 stack[sp].ll = lo; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1090 stack[sp].hh = n; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1091 stack[sp].dd = d; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1092 sp++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1093 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1094 stack[sp].ll = n + 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1095 stack[sp].hh = m - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1096 stack[sp].dd = d+1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1097 sp++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1098 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1099 stack[sp].ll = m; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1100 stack[sp].hh = hi; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1101 stack[sp].dd = d; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1102 sp++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1103 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1104 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1105 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1106 void MainSort() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1107 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1108 int i, j, ss, sb; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1109 int[] runningOrder = new int[256]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1110 int[] copy = new int[256]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1111 bool[] bigDone = new bool[256]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1112 int c1, c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1113 int numQSorted; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1114 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1115 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1116 In the various block-sized structures, live data runs |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1117 from 0 to last+NUM_OVERSHOOT_BYTES inclusive. First, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1118 set up the overshoot area for block. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1119 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1120 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1121 // if (verbosity >= 4) fprintf ( stderr, " sort initialise ...\n" ); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1122 for (i = 0; i < BZip2Constants.OvershootBytes; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1123 block[last + i + 2] = block[(i % (last + 1)) + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1124 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1125 for (i = 0; i <= last + BZip2Constants.OvershootBytes; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1126 quadrant[i] = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1127 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1128 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1129 block[0] = (byte)(block[last + 1]); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1130 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1131 if (last < 4000) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1132 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1133 Use simpleSort(), since the full sorting mechanism |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1134 has quite a large constant overhead. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1135 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1136 for (i = 0; i <= last; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1137 zptr[i] = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1138 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1139 firstAttempt = false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1140 workDone = workLimit = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1141 SimpleSort(0, last, 0); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1142 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1143 numQSorted = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1144 for (i = 0; i <= 255; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1145 bigDone[i] = false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1146 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1147 for (i = 0; i <= 65536; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1148 ftab[i] = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1149 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1150 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1151 c1 = block[0]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1152 for (i = 0; i <= last; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1153 c2 = block[i + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1154 ftab[(c1 << 8) + c2]++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1155 c1 = c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1156 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1157 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1158 for (i = 1; i <= 65536; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1159 ftab[i] += ftab[i - 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1160 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1161 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1162 c1 = block[1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1163 for (i = 0; i < last; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1164 c2 = block[i + 2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1165 j = (c1 << 8) + c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1166 c1 = c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1167 ftab[j]--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1168 zptr[ftab[j]] = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1169 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1170 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1171 j = ((block[last + 1]) << 8) + (block[1]); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1172 ftab[j]--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1173 zptr[ftab[j]] = last; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1174 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1175 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1176 Now ftab contains the first loc of every small bucket. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1177 Calculate the running order, from smallest to largest |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1178 big bucket. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1179 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1180 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1181 for (i = 0; i <= 255; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1182 runningOrder[i] = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1183 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1184 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1185 int vv; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1186 int h = 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1187 do { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1188 h = 3 * h + 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1189 } while (h <= 256); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1190 do { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1191 h = h / 3; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1192 for (i = h; i <= 255; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1193 vv = runningOrder[i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1194 j = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1195 while ((ftab[((runningOrder[j-h])+1) << 8] - ftab[(runningOrder[j-h]) << 8]) > (ftab[((vv)+1) << 8] - ftab[(vv) << 8])) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1196 runningOrder[j] = runningOrder[j-h]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1197 j = j - h; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1198 if (j <= (h - 1)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1199 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1200 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1201 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1202 runningOrder[j] = vv; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1203 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1204 } while (h != 1); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1205 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1206 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1207 The main sorting loop. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1208 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1209 for (i = 0; i <= 255; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1210 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1211 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1212 Process big buckets, starting with the least full. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1213 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1214 ss = runningOrder[i]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1215 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1216 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1217 Complete the big bucket [ss] by quicksorting |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1218 any unsorted small buckets [ss, j]. Hopefully |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1219 previous pointer-scanning phases have already |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1220 completed many of the small buckets [ss, j], so |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1221 we don't have to sort them at all. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1222 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1223 for (j = 0; j <= 255; j++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1224 sb = (ss << 8) + j; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1225 if(!((ftab[sb] & SETMASK) == SETMASK)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1226 int lo = ftab[sb] & CLEARMASK; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1227 int hi = (ftab[sb+1] & CLEARMASK) - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1228 if (hi > lo) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1229 QSort3(lo, hi, 2); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1230 numQSorted += (hi - lo + 1); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1231 if (workDone > workLimit && firstAttempt) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1232 return; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1233 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1234 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1235 ftab[sb] |= SETMASK; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1236 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1237 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1238 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1239 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1240 The ss big bucket is now done. Record this fact, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1241 and update the quadrant descriptors. Remember to |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1242 update quadrants in the overshoot area too, if |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1243 necessary. The "if (i < 255)" test merely skips |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1244 this updating for the last bucket processed, since |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1245 updating for the last bucket is pointless. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1246 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1247 bigDone[ss] = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1248 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1249 if (i < 255) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1250 int bbStart = ftab[ss << 8] & CLEARMASK; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1251 int bbSize = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1252 int shifts = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1253 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1254 while ((bbSize >> shifts) > 65534) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1255 shifts++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1256 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1257 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1258 for (j = 0; j < bbSize; j++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1259 int a2update = zptr[bbStart + j]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1260 int qVal = (j >> shifts); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1261 quadrant[a2update] = qVal; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1262 if (a2update < BZip2Constants.OvershootBytes) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1263 quadrant[a2update + last + 1] = qVal; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1264 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1265 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1266 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1267 if (!(((bbSize-1) >> shifts) <= 65535)) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1268 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1269 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1270 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1271 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1272 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1273 Now scan this big bucket so as to synthesise the |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1274 sorted order for small buckets [t, ss] for all t != ss. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1275 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1276 for (j = 0; j <= 255; j++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1277 copy[j] = ftab[(j << 8) + ss] & CLEARMASK; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1278 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1279 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1280 for (j = ftab[ss << 8] & CLEARMASK; j < (ftab[(ss+1) << 8] & CLEARMASK); j++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1281 c1 = block[zptr[j]]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1282 if (!bigDone[c1]) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1283 zptr[copy[c1]] = zptr[j] == 0 ? last : zptr[j] - 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1284 copy[c1] ++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1285 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1286 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1287 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1288 for (j = 0; j <= 255; j++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1289 ftab[(j << 8) + ss] |= SETMASK; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1290 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1291 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1292 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1293 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1294 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1295 void RandomiseBlock() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1296 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1297 int i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1298 int rNToGo = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1299 int rTPos = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1300 for (i = 0; i < 256; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1301 inUse[i] = false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1302 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1303 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1304 for (i = 0; i <= last; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1305 if (rNToGo == 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1306 rNToGo = (int)BZip2Constants.RandomNumbers[rTPos]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1307 rTPos++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1308 if (rTPos == 512) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1309 rTPos = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1310 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1311 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1312 rNToGo--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1313 block[i + 1] ^= (byte)((rNToGo == 1) ? 1 : 0); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1314 // handle 16 bit signed numbers |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1315 block[i + 1] &= 0xFF; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1316 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1317 inUse[block[i + 1]] = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1318 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1319 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1320 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1321 void DoReversibleTransformation() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1322 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1323 workLimit = workFactor * last; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1324 workDone = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1325 blockRandomised = false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1326 firstAttempt = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1327 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1328 MainSort(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1329 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1330 if (workDone > workLimit && firstAttempt) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1331 RandomiseBlock(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1332 workLimit = workDone = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1333 blockRandomised = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1334 firstAttempt = false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1335 MainSort(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1336 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1337 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1338 origPtr = -1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1339 for (int i = 0; i <= last; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1340 if (zptr[i] == 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1341 origPtr = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1342 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1343 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1344 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1345 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1346 if (origPtr == -1) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1347 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1348 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1349 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1350 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1351 bool FullGtU(int i1, int i2) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1352 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1353 int k; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1354 byte c1, c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1355 int s1, s2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1356 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1357 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1358 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1359 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1360 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1361 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1362 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1363 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1364 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1365 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1366 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1367 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1368 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1369 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1370 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1371 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1372 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1373 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1374 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1375 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1376 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1377 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1378 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1379 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1380 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1381 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1382 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1383 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1384 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1385 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1386 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1387 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1388 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1389 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1390 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1391 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1392 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1393 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1394 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1395 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1396 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1397 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1398 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1399 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1400 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1401 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1402 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1403 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1404 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1405 k = last + 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1406 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1407 do { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1408 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1409 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1410 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1411 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1412 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1413 s1 = quadrant[i1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1414 s2 = quadrant[i2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1415 if (s1 != s2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1416 return s1 > s2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1417 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1418 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1419 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1420 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1421 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1422 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1423 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1424 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1425 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1426 s1 = quadrant[i1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1427 s2 = quadrant[i2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1428 if (s1 != s2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1429 return s1 > s2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1430 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1431 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1432 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1433 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1434 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1435 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1436 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1437 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1438 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1439 s1 = quadrant[i1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1440 s2 = quadrant[i2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1441 if (s1 != s2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1442 return s1 > s2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1443 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1444 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1445 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1446 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1447 c1 = block[i1 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1448 c2 = block[i2 + 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1449 if (c1 != c2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1450 return c1 > c2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1451 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1452 s1 = quadrant[i1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1453 s2 = quadrant[i2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1454 if (s1 != s2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1455 return s1 > s2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1456 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1457 i1++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1458 i2++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1459 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1460 if (i1 > last) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1461 i1 -= last; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1462 i1--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1463 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1464 if (i2 > last) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1465 i2 -= last; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1466 i2--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1467 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1468 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1469 k -= 4; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1470 ++workDone; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1471 } while (k >= 0); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1472 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1473 return false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1474 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1475 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1476 void AllocateCompressStructures() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1477 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1478 int n = BZip2Constants.BaseBlockSize * blockSize100k; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1479 block = new byte[(n + 1 + BZip2Constants.OvershootBytes)]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1480 quadrant = new int[(n + BZip2Constants.OvershootBytes)]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1481 zptr = new int[n]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1482 ftab = new int[65537]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1483 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1484 if (block == null || quadrant == null || zptr == null || ftab == null) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1485 // int totalDraw = (n + 1 + NUM_OVERSHOOT_BYTES) + (n + NUM_OVERSHOOT_BYTES) + n + 65537; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1486 // compressOutOfMemory ( totalDraw, n ); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1487 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1488 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1489 /* |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1490 The back end needs a place to store the MTF values |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1491 whilst it calculates the coding tables. We could |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1492 put them in the zptr array. However, these values |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1493 will fit in a short, so we overlay szptr at the |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1494 start of zptr, in the hope of reducing the number |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1495 of cache misses induced by the multiple traversals |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1496 of the MTF values when calculating coding tables. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1497 Seems to improve compression speed by about 1%. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1498 */ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1499 // szptr = zptr; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1500 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1501 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1502 szptr = new short[2 * n]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1503 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1504 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1505 void GenerateMTFValues() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1506 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1507 char[] yy = new char[256]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1508 int i, j; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1509 char tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1510 char tmp2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1511 int zPend; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1512 int wr; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1513 int EOB; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1514 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1515 MakeMaps(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1516 EOB = nInUse+1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1517 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1518 for (i = 0; i <= EOB; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1519 mtfFreq[i] = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1520 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1521 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1522 wr = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1523 zPend = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1524 for (i = 0; i < nInUse; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1525 yy[i] = (char) i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1526 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1527 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1528 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1529 for (i = 0; i <= last; i++) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1530 char ll_i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1531 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1532 ll_i = unseqToSeq[block[zptr[i]]]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1533 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1534 j = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1535 tmp = yy[j]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1536 while (ll_i != tmp) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1537 j++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1538 tmp2 = tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1539 tmp = yy[j]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1540 yy[j] = tmp2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1541 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1542 yy[0] = tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1543 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1544 if (j == 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1545 zPend++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1546 } else { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1547 if (zPend > 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1548 zPend--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1549 while (true) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1550 switch (zPend % 2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1551 case 0: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1552 szptr[wr] = (short)BZip2Constants.RunA; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1553 wr++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1554 mtfFreq[BZip2Constants.RunA]++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1555 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1556 case 1: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1557 szptr[wr] = (short)BZip2Constants.RunB; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1558 wr++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1559 mtfFreq[BZip2Constants.RunB]++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1560 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1561 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1562 if (zPend < 2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1563 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1564 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1565 zPend = (zPend - 2) / 2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1566 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1567 zPend = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1568 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1569 szptr[wr] = (short)(j + 1); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1570 wr++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1571 mtfFreq[j + 1]++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1572 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1573 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1574 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1575 if (zPend > 0) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1576 zPend--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1577 while (true) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1578 switch (zPend % 2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1579 case 0: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1580 szptr[wr] = (short)BZip2Constants.RunA; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1581 wr++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1582 mtfFreq[BZip2Constants.RunA]++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1583 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1584 case 1: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1585 szptr[wr] = (short)BZip2Constants.RunB; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1586 wr++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1587 mtfFreq[BZip2Constants.RunB]++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1588 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1589 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1590 if (zPend < 2) { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1591 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1592 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1593 zPend = (zPend - 2) / 2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1594 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1595 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1596 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1597 szptr[wr] = (short)EOB; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1598 wr++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1599 mtfFreq[EOB]++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1600 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1601 nMTF = wr; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1602 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1603 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1604 static void Panic() |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1605 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1606 throw new BZip2Exception("BZip2 output stream panic"); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1607 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1608 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1609 static void HbMakeCodeLengths(char[] len, int[] freq, int alphaSize, int maxLen) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1610 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1611 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1612 Nodes and heap entries run from 1. Entry 0 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1613 for both the heap and nodes is a sentinel. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1614 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1615 int nNodes, nHeap, n1, n2, j, k; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1616 bool tooLong; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1617 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1618 int[] heap = new int[BZip2Constants.MaximumAlphaSize + 2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1619 int[] weight = new int[BZip2Constants.MaximumAlphaSize * 2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1620 int[] parent = new int[BZip2Constants.MaximumAlphaSize * 2]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1621 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1622 for (int i = 0; i < alphaSize; ++i) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1623 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1624 weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1625 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1626 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1627 while (true) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1628 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1629 nNodes = alphaSize; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1630 nHeap = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1631 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1632 heap[0] = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1633 weight[0] = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1634 parent[0] = -2; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1635 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1636 for (int i = 1; i <= alphaSize; ++i) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1637 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1638 parent[i] = -1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1639 nHeap++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1640 heap[nHeap] = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1641 int zz = nHeap; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1642 int tmp = heap[zz]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1643 while (weight[tmp] < weight[heap[zz >> 1]]) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1644 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1645 heap[zz] = heap[zz >> 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1646 zz >>= 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1647 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1648 heap[zz] = tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1649 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1650 if (!(nHeap < (BZip2Constants.MaximumAlphaSize+2))) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1651 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1652 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1653 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1654 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1655 while (nHeap > 1) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1656 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1657 n1 = heap[1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1658 heap[1] = heap[nHeap]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1659 nHeap--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1660 int zz = 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1661 int yy = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1662 int tmp = heap[zz]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1663 while (true) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1664 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1665 yy = zz << 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1666 if (yy > nHeap) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1667 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1668 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1669 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1670 if (yy < nHeap && weight[heap[yy+1]] < weight[heap[yy]]) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1671 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1672 yy++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1673 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1674 if (weight[tmp] < weight[heap[yy]]) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1675 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1676 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1677 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1678 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1679 heap[zz] = heap[yy]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1680 zz = yy; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1681 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1682 heap[zz] = tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1683 n2 = heap[1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1684 heap[1] = heap[nHeap]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1685 nHeap--; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1686 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1687 zz = 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1688 yy = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1689 tmp = heap[zz]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1690 while (true) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1691 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1692 yy = zz << 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1693 if (yy > nHeap) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1694 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1695 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1696 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1697 if (yy < nHeap && weight[heap[yy+1]] < weight[heap[yy]]) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1698 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1699 yy++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1700 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1701 if (weight[tmp] < weight[heap[yy]]) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1702 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1703 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1704 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1705 heap[zz] = heap[yy]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1706 zz = yy; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1707 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1708 heap[zz] = tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1709 nNodes++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1710 parent[n1] = parent[n2] = nNodes; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1711 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1712 weight[nNodes] = (int)((weight[n1] & 0xffffff00) + (weight[n2] & 0xffffff00)) | |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1713 (int)(1 + (((weight[n1] & 0x000000ff) > (weight[n2] & 0x000000ff)) ? (weight[n1] & 0x000000ff) : (weight[n2] & 0x000000ff))); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1714 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1715 parent[nNodes] = -1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1716 nHeap++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1717 heap[nHeap] = nNodes; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1718 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1719 zz = nHeap; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1720 tmp = heap[zz]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1721 while (weight[tmp] < weight[heap[zz >> 1]]) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1722 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1723 heap[zz] = heap[zz >> 1]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1724 zz >>= 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1725 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1726 heap[zz] = tmp; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1727 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1728 if (!(nNodes < (BZip2Constants.MaximumAlphaSize * 2))) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1729 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1730 Panic(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1731 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1732 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1733 tooLong = false; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1734 for (int i = 1; i <= alphaSize; ++i) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1735 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1736 j = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1737 k = i; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1738 while (parent[k] >= 0) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1739 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1740 k = parent[k]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1741 j++; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1742 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1743 len[i - 1] = (char)j; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1744 if (j > maxLen) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1745 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1746 tooLong = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1747 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1748 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1749 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1750 if (!tooLong) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1751 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1752 break; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1753 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1754 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1755 for (int i = 1; i < alphaSize; ++i) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1756 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1757 j = weight[i] >> 8; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1758 j = 1 + (j / 2); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1759 weight[i] = j << 8; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1760 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1761 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1762 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1763 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1764 static void HbAssignCodes (int[] code, char[] length, int minLen, int maxLen, int alphaSize) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1765 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1766 int vec = 0; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1767 for (int n = minLen; n <= maxLen; ++n) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1768 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1769 for (int i = 0; i < alphaSize; ++i) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1770 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1771 if (length[i] == n) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1772 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1773 code[i] = vec; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1774 ++vec; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1775 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1776 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1777 vec <<= 1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1778 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1779 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1780 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1781 static byte Med3(byte a, byte b, byte c ) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1782 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1783 byte t; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1784 if (a > b) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1785 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1786 t = a; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1787 a = b; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1788 b = t; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1789 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1790 if (b > c) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1791 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1792 t = b; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1793 b = c; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1794 c = t; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1795 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1796 if (a > b) |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1797 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1798 b = a; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1799 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1800 return b; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1801 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1802 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1803 struct StackElement |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1804 { |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1805 public int ll; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1806 public int hh; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1807 public int dd; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1808 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1809 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1810 #region Instance Fields |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1811 bool isStreamOwner = true; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1812 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1813 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1814 index of the last char in the block, so |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1815 the block size == last + 1. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1816 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1817 int last; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1818 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1819 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1820 index in zptr[] of original string after sorting. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1821 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1822 int origPtr; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1823 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1824 /*-- |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1825 always: in the range 0 .. 9. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1826 The current block size is 100000 * this number. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1827 --*/ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1828 int blockSize100k; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1829 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1830 bool blockRandomised; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1831 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1832 int bytesOut; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1833 int bsBuff; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1834 int bsLive; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1835 IChecksum mCrc = new StrangeCRC(); |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1836 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1837 bool[] inUse = new bool[256]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1838 int nInUse; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1839 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1840 char[] seqToUnseq = new char[256]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1841 char[] unseqToSeq = new char[256]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1842 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1843 char[] selector = new char[BZip2Constants.MaximumSelectors]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1844 char[] selectorMtf = new char[BZip2Constants.MaximumSelectors]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1845 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1846 byte[] block; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1847 int[] quadrant; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1848 int[] zptr; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1849 short[] szptr; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1850 int[] ftab; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1851 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1852 int nMTF; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1853 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1854 int[] mtfFreq = new int[BZip2Constants.MaximumAlphaSize]; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1855 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1856 /* |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1857 * Used when sorting. If too many long comparisons |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1858 * happen, we stop sorting, randomise the block |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1859 * slightly, and try again. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1860 */ |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1861 int workFactor; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1862 int workDone; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1863 int workLimit; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1864 bool firstAttempt; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1865 int nBlocksRandomised; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1866 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1867 int currentChar = -1; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1868 int runLength; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1869 uint blockCRC, combinedCRC; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1870 int allowableBlockSize; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1871 Stream baseStream; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1872 bool disposed_; |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1873 #endregion |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1874 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1875 } |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1876 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1877 /* This file was derived from a file containing this license: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1878 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1879 * This file is a part of bzip2 and/or libbzip2, a program and |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1880 * library for lossless, block-sorting data compression. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1881 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1882 * Copyright (C) 1996-1998 Julian R Seward. All rights reserved. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1883 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1884 * Redistribution and use in source and binary forms, with or without |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1885 * modification, are permitted provided that the following conditions |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1886 * are met: |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1887 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1888 * 1. Redistributions of source code must retain the above copyright |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1889 * notice, this list of conditions and the following disclaimer. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1890 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1891 * 2. The origin of this software must not be misrepresented; you must |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1892 * not claim that you wrote the original software. If you use this |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1893 * software in a product, an acknowledgment in the product |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1894 * documentation would be appreciated but is not required. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1895 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1896 * 3. Altered source versions must be plainly marked as such, and must |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1897 * not be misrepresented as being the original software. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1898 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1899 * 4. The name of the author may not be used to endorse or promote |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1900 * products derived from this software without specific prior written |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1901 * permission. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1902 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1903 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1904 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1905 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1906 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1907 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1908 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1909 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1910 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1911 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1912 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1913 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1914 * |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1915 * Java version ported by Keiron Liddle, Aftex Software <keiron@aftexsw.com> 1999-2001 |
94e25b786321
Re #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1916 */ |