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 tar | 5 package tar |
6 | 6 |
7 // TODO(dsymonds): | 7 // TODO(dsymonds): |
8 // - pax extensions | 8 // - pax extensions |
9 | 9 |
10 import ( | 10 import ( |
11 "bytes" | 11 "bytes" |
12 "errors" | 12 "errors" |
13 "io" | 13 "io" |
14 "io/ioutil" | 14 "io/ioutil" |
15 "os" | 15 "os" |
16 "strconv" | 16 "strconv" |
17 "time" | 17 "time" |
18 ) | 18 ) |
19 | 19 |
20 var ( | 20 var ( |
21 » ErrHeader = errors.New("invalid tar header") | 21 » ErrHeader = errors.New("archive/tar: invalid tar header") |
22 ) | 22 ) |
23 | 23 |
24 // A Reader provides sequential access to the contents of a tar archive. | 24 // A Reader provides sequential access to the contents of a tar archive. |
25 // A tar archive consists of a sequence of files. | 25 // A tar archive consists of a sequence of files. |
26 // The Next method advances to the next file in the archive (including the first
), | 26 // The Next method advances to the next file in the archive (including the first
), |
27 // and then it can be treated as an io.Reader to access the file's data. | 27 // and then it can be treated as an io.Reader to access the file's data. |
28 // | 28 // |
29 // Example: | 29 // Example: |
30 // tr := tar.NewReader(r) | 30 // tr := tar.NewReader(r) |
31 // for { | 31 // for { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 n, err = tr.r.Read(b) | 215 n, err = tr.r.Read(b) |
216 tr.nb -= int64(n) | 216 tr.nb -= int64(n) |
217 | 217 |
218 if err == io.EOF && tr.nb > 0 { | 218 if err == io.EOF && tr.nb > 0 { |
219 err = io.ErrUnexpectedEOF | 219 err = io.ErrUnexpectedEOF |
220 } | 220 } |
221 tr.err = err | 221 tr.err = err |
222 return | 222 return |
223 } | 223 } |
OLD | NEW |