1
0
mirror of https://github.com/golang/go synced 2024-11-12 08:20:22 -07:00

archive/zip: add File.DataOffset

Accessor to find where the bytes of a file start.

R=golang-dev, rsc, dsymonds, adg
CC=golang-dev
https://golang.org/cl/12784045
This commit is contained in:
Brad Fitzpatrick 2013-08-13 16:29:51 -07:00
parent 45cb2e1b70
commit a2599cf50e

View File

@ -114,6 +114,19 @@ func (rc *ReadCloser) Close() error {
return rc.f.Close()
}
// DataOffset returns the offset of the file's possibly-compressed
// data, relative to the beginning of the zip file.
//
// Most callers should instead use Open, which transparently
// decompresses data and verifies checksums.
func (f *File) DataOffset() (offset int64, err error) {
bodyOffset, err := f.findBodyOffset()
if err != nil {
return
}
return f.headerOffset + bodyOffset, nil
}
// Open returns a ReadCloser that provides access to the File's contents.
// Multiple files may be read concurrently.
func (f *File) Open() (rc io.ReadCloser, err error) {