OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package gzip implements reading and writing of gzip format compressed files, | 5 // Package gzip implements reading and writing of gzip format compressed files, |
6 // as specified in RFC 1952. | 6 // as specified in RFC 1952. |
7 package gzip | 7 package gzip |
8 | 8 |
9 import ( | 9 import ( |
10 "bufio" | 10 "bufio" |
(...skipping 18 matching lines...) Expand all Loading... |
29 flagComment = 1 << 4 | 29 flagComment = 1 << 4 |
30 ) | 30 ) |
31 | 31 |
32 func makeReader(r io.Reader) flate.Reader { | 32 func makeReader(r io.Reader) flate.Reader { |
33 if rr, ok := r.(flate.Reader); ok { | 33 if rr, ok := r.(flate.Reader); ok { |
34 return rr | 34 return rr |
35 } | 35 } |
36 return bufio.NewReader(r) | 36 return bufio.NewReader(r) |
37 } | 37 } |
38 | 38 |
39 var HeaderError os.Error = os.ErrorString("invalid gzip header") | 39 var HeaderError = os.NewError("invalid gzip header") |
40 var ChecksumError os.Error = os.ErrorString("gzip checksum error") | 40 var ChecksumError = os.NewError("gzip checksum error") |
41 | 41 |
42 // The gzip file stores a header giving metadata about the compressed file. | 42 // The gzip file stores a header giving metadata about the compressed file. |
43 // That header is exposed as the fields of the Compressor and Decompressor struc
ts. | 43 // That header is exposed as the fields of the Compressor and Decompressor struc
ts. |
44 type Header struct { | 44 type Header struct { |
45 Comment string // comment | 45 Comment string // comment |
46 Extra []byte // "extra data" | 46 Extra []byte // "extra data" |
47 Mtime uint32 // modification time (seconds since January 1, 1970) | 47 Mtime uint32 // modification time (seconds since January 1, 1970) |
48 Name string // file name | 48 Name string // file name |
49 OS byte // operating system type | 49 OS byte // operating system type |
50 } | 50 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 // Yes. Reset and read from it. | 223 // Yes. Reset and read from it. |
224 z.digest.Reset() | 224 z.digest.Reset() |
225 z.size = 0 | 225 z.size = 0 |
226 return z.Read(p) | 226 return z.Read(p) |
227 } | 227 } |
228 | 228 |
229 // Calling Close does not close the wrapped io.Reader originally passed to NewRe
ader. | 229 // Calling Close does not close the wrapped io.Reader originally passed to NewRe
ader. |
230 func (z *Decompressor) Close() os.Error { return z.decompressor.Close() } | 230 func (z *Decompressor) Close() os.Error { return z.decompressor.Close() } |
OLD | NEW |