Mercurial > repos > SharpZipLib
annotate GZip/GzipOutputStream.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 // GZipOutputStream.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 file was translated from java, it was part of the GNU Classpath |
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 // Copyright (C) 2001 Free Software Foundation, Inc. |
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 // |
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 // 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
|
9 // 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
|
10 // 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
|
11 // 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
|
12 // |
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 // 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
|
14 // 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
|
15 // 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
|
16 // 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
|
17 // |
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 // 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
|
19 // 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
|
20 // 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
|
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
|
22 // 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
|
23 // 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
|
24 // 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
|
25 // 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
|
26 // |
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 // 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
|
28 // 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
|
29 // 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
|
30 // 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
|
31 // 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
|
32 // 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
|
33 // 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
|
34 // 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
|
35 // 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
|
36 // 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
|
37 // 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
|
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 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
|
40 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
|
41 |
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 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
|
43 using ICSharpCode.SharpZipLib.Zip.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
|
44 using ICSharpCode.SharpZipLib.Zip.Compression.Streams; |
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 namespace ICSharpCode.SharpZipLib.GZip |
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 { |
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 |
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 /// This filter stream is used to compress a stream into a "GZIP" 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 /// The "GZIP" format is described in RFC 1952. |
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 /// |
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 /// author of the original java version : John Leuner |
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 /// </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
|
55 /// <example> This sample shows how to gzip a file |
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 /// <code> |
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 /// 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
|
58 /// 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
|
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 /// using ICSharpCode.SharpZipLib.GZip; |
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 /// using ICSharpCode.SharpZipLib.Core; |
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 /// |
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 /// class MainClass |
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 /// { |
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 /// public static void Main(string[] args) |
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 /// { |
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 /// using (Stream s = new GZipOutputStream(File.Create(args[0] + ".gz"))) |
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 /// using (FileStream fs = File.OpenRead(args[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
|
69 /// byte[] writeData = new byte[4096]; |
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 /// Streamutils.Copy(s, fs, writeData); |
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 /// } |
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 /// } |
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 /// } |
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 /// } |
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 /// </code> |
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 /// </example> |
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 public class GZipOutputStream : DeflaterOutputStream |
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 { |
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 enum OutputState |
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 Header, |
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 Footer, |
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 Finished, |
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 Closed, |
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 }; |
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 |
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 #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
|
88 /// <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
|
89 /// CRC-32 value for uncompressed data |
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 /// </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
|
91 protected Crc32 crc = new Crc32(); |
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 OutputState state_ = OutputState.Header; |
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 #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
|
94 |
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 #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
|
96 /// <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
|
97 /// Creates a GzipOutputStream with the default buffer 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
|
98 /// </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
|
99 /// <param name="baseOutputStream"> |
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 stream to read data (to be compressed) 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
|
101 /// </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
|
102 public GZipOutputStream(Stream baseOutputStream) |
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 : this(baseOutputStream, 4096) |
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 { |
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 |
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 /// <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
|
108 /// Creates a GZipOutputStream with the specified buffer 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
|
109 /// </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
|
110 /// <param name="baseOutputStream"> |
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 /// The stream to read data (to be compressed) 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
|
112 /// </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
|
113 /// <param name="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
|
114 /// Size of the buffer 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
|
115 /// </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
|
116 public GZipOutputStream(Stream baseOutputStream, int size) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true), 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
|
117 { |
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 Public API |
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 /// Sets the active compression level (1-9). The new level will be activated |
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 /// immediately. |
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 /// <param name="level">The compression level to set.</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
|
127 /// <exception cref="ArgumentOutOfRangeException"> |
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 /// Level specified is 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
|
129 /// </exception> |
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 /// <see cref="Deflater"/> |
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 public void SetLevel(int level) |
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 { |
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 if (level < Deflater.BEST_SPEED) { |
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 throw new ArgumentOutOfRangeException("level"); |
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 } |
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 deflater_.SetLevel(level); |
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 |
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 /// <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
|
140 /// Get the current compression level. |
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 /// </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
|
142 /// <returns>The current compression level.</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
|
143 public int GetLevel() |
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 { |
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 return deflater_.GetLevel(); |
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 } |
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 #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
|
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 #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
|
150 /// <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
|
151 /// Write given buffer to output updating crc |
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 /// </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
|
153 /// <param name="buffer">Buffer 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
|
154 /// <param name="offset">Offset of first byte in buf 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
|
155 /// <param name="count">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
|
156 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
|
157 { |
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 if ( state_ == OutputState.Header ) { |
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 WriteHeader(); |
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 if( state_!=OutputState.Footer ) |
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 { |
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 throw new InvalidOperationException("Write not permitted in current state"); |
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 } |
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 |
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 crc.Update(buffer, 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
|
168 base.Write(buffer, 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
|
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 /// <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
|
172 /// Writes remaining compressed output data to the output 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
|
173 /// and closes it. |
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 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
|
176 { |
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 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
|
178 Finish(); |
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 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
|
181 if ( state_ != OutputState.Closed ) { |
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 state_ = OutputState.Closed; |
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 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
|
184 baseOutputStream_.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
|
185 } |
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 } |
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 } |
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 #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
|
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 #region DeflaterOutputStream 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
|
192 /// <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
|
193 /// Finish compression and write any footer information required to 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
|
194 /// </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
|
195 public override void Finish() |
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 { |
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 // If no data has been written a header should be added. |
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 if ( state_ == OutputState.Header ) { |
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 WriteHeader(); |
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 |
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 if( state_ == OutputState.Footer) |
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 state_=OutputState.Finished; |
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 base.Finish(); |
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 |
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 uint totalin=(uint)(deflater_.TotalIn&0xffffffff); |
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 uint crcval=(uint)(crc.Value&0xffffffff); |
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 byte[] gzipFooter; |
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 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
|
213 { |
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 gzipFooter=new byte[] { |
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 (byte) crcval, (byte) (crcval >> 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
|
216 (byte) (crcval >> 16), (byte) (crcval >> 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
|
217 |
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 (byte) totalin, (byte) (totalin >> 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
|
219 (byte) (totalin >> 16), (byte) (totalin >> 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
|
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 |
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 baseOutputStream_.Write(gzipFooter, 0, gzipFooter.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
|
224 } |
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 } |
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 #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
|
227 |
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 #region Support Routines |
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 void WriteHeader() |
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 { |
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 if ( state_ == OutputState.Header ) |
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 state_=OutputState.Footer; |
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 int mod_time = (int)((DateTime.Now.Ticks - new DateTime(1970, 1, 1).Ticks) / 10000000L); // Ticks give back 100ns intervals |
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 byte[] gzipHeader = { |
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 // The two magic 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
|
238 (byte) (GZipConstants.GZIP_MAGIC >> 8), (byte) (GZipConstants.GZIP_MAGIC & 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
|
239 |
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 // The compression type |
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 (byte) Deflater.DEFLATED, |
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 |
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 // The flags (not 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
|
244 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
|
245 |
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 // The modification time |
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 (byte) mod_time, (byte) (mod_time >> 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
|
248 (byte) (mod_time >> 16), (byte) (mod_time >> 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
|
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 // The extra flags |
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 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
|
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 // The OS type (unknown) |
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 (byte) 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
|
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
|
256 baseOutputStream_.Write(gzipHeader, 0, gzipHeader.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
|
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 } |
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 #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
|
260 } |
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 } |