Skip to content

Commit

Permalink
archive/tar: document how Reader.Read handles header-only files
Browse files Browse the repository at this point in the history
Commit dd5e14a ensured that no data
could be read for header-only files regardless of what the Header.Size
said. We should document this fact in Reader.Read.

Updates golang#13647

Change-Id: I4df9a2892bc66b49e0279693d08454bf696cfa31
Reviewed-on: https://go-review.googlesource.com/17913
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
dsnet authored and rsc committed Dec 17, 2015
1 parent 5c0629b commit 7a2913c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/archive/tar/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,10 @@ func (tr *Reader) numBytes() int64 {
// Read reads from the current entry in the tar archive.
// It returns 0, io.EOF when it reaches the end of that entry,
// until Next is called to advance to the next entry.
//
// Calling Read on special types like TypeLink, TypeSymLink, TypeChar,
// TypeBlock, TypeDir, and TypeFifo returns 0, io.EOF regardless of what
// the Header.Size claims.
func (tr *Reader) Read(b []byte) (n int, err error) {
if tr.err != nil {
return 0, tr.err
Expand Down

0 comments on commit 7a2913c

Please sign in to comment.