/usr/share/gocode/src/github.com/akavel/rsrc/binutil/sizedfile.go is in golang-github-akavel-rsrc-dev 2+git20151103.6.ba14da1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | package binutil
import (
"io"
"os"
)
type SizedReader interface {
io.Reader
Size() int64
}
type SizedFile struct {
f *os.File
s *io.SectionReader // helper, for Size()
}
func (r *SizedFile) Read(p []byte) (n int, err error) { return r.s.Read(p) }
func (r *SizedFile) Size() int64 { return r.s.Size() }
func (r *SizedFile) Close() error { return r.f.Close() }
func SizedOpen(filename string) (*SizedFile, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
info, err := f.Stat()
if err != nil {
return nil, err
}
return &SizedFile{
f: f,
s: io.NewSectionReader(f, 0, info.Size()),
}, nil
}
|