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

Side by Side Diff: src/pkg/archive/tar/reader.go

Issue 5777064: code review 5777064: archive/tar: catch short writes. (Closed)
Patch Set: diff -r c7af497373ff https://go.googlecode.com/hg/ Created 13 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:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/archive/tar/writer.go » ('j') | src/pkg/archive/tar/writer.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/archive/tar/writer.go » ('j') | src/pkg/archive/tar/writer.go » ('J')

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