Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(459)

Delta Between Two Patch Sets: src/pkg/archive/tar/reader.go

Issue 6700047: code review 6700047: archive/tar: read/write extended pax/gnu tar archives (Closed)
Left Patch Set: diff -r 1399878c6731 https://code.google.com/p/go Created 11 years, 2 months ago
Right Patch Set: diff -r 439cb8bad388 https://code.google.com/p/go Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/archive/tar/common.go ('k') | src/pkg/archive/tar/reader_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 (
(...skipping 10 matching lines...) Expand all
21 var ( 21 var (
22 ErrHeader = errors.New("archive/tar: invalid tar header") 22 ErrHeader = errors.New("archive/tar: invalid tar header")
23 ) 23 )
24 24
25 const maxNanoSecondIntSize = 9 25 const maxNanoSecondIntSize = 9
26 26
27 // A Reader provides sequential access to the contents of a tar archive. 27 // A Reader provides sequential access to the contents of a tar archive.
28 // A tar archive consists of a sequence of files. 28 // A tar archive consists of a sequence of files.
29 // The Next method advances to the next file in the archive (including the first ), 29 // The Next method advances to the next file in the archive (including the first ),
30 // and then it can be treated as an io.Reader to access the file's data. 30 // and then it can be treated as an io.Reader to access the file's data.
31 //
32 // Example:
33 // tr := tar.NewReader(r)
34 // for {
35 // hdr, err := tr.Next()
36 // if err == io.EOF {
37 // // end of tar archive
38 // break
39 // }
40 // if err != nil {
41 // // handle error
42 // }
43 // io.Copy(data, tr)
44 // }
45 type Reader struct { 31 type Reader struct {
46 r io.Reader 32 r io.Reader
47 err error 33 err error
48 nb int64 // number of unread bytes for current file entry 34 nb int64 // number of unread bytes for current file entry
49 pad int64 // amount of padding (ignored) after current file entry 35 pad int64 // amount of padding (ignored) after current file entry
50 } 36 }
51 37
52 // NewReader creates a new Reader reading from r. 38 // NewReader creates a new Reader reading from r.
53 func NewReader(r io.Reader) *Reader { return &Reader{r: r} } 39 func NewReader(r io.Reader) *Reader { return &Reader{r: r} }
54 40
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 385 }
400 n, err = tr.r.Read(b) 386 n, err = tr.r.Read(b)
401 tr.nb -= int64(n) 387 tr.nb -= int64(n)
402 388
403 if err == io.EOF && tr.nb > 0 { 389 if err == io.EOF && tr.nb > 0 {
404 err = io.ErrUnexpectedEOF 390 err = io.ErrUnexpectedEOF
405 } 391 }
406 tr.err = err 392 tr.err = err
407 return 393 return
408 } 394 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b