diff options
author | Joe Tsai <joetsai@digital-static.net> | 2015-12-16 23:10:14 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2015-12-17 15:48:10 +0000 |
commit | 7a2913c9f551588b351efc6d026c1c6f187442e1 (patch) | |
tree | 7ab76499970022182f25cc84263453b84bd449d2 | |
parent | 5c0629b503ff9044906a785f360354a5e45cf9ce (diff) | |
download | go-7a2913c9f551588b351efc6d026c1c6f187442e1.tar.gz go-7a2913c9f551588b351efc6d026c1c6f187442e1.zip |
archive/tar: document how Reader.Read handles header-only files
Commit dd5e14a7511465d20c6e95bf54c9b8f999abbbf6 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 #13647
Change-Id: I4df9a2892bc66b49e0279693d08454bf696cfa31
Reviewed-on: https://go-review.googlesource.com/17913
Reviewed-by: Russ Cox <rsc@golang.org>
-rw-r--r-- | src/archive/tar/reader.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/archive/tar/reader.go b/src/archive/tar/reader.go index 4aa7edbce3..c8cb69a178 100644 --- a/src/archive/tar/reader.go +++ b/src/archive/tar/reader.go @@ -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 |