fix ReadAt

This commit is contained in:
Brian Tiger Chow 2018-11-20 13:34:41 -05:00
parent 709edc9d8f
commit e151fe9493
1 changed files with 4 additions and 1 deletions

View File

@ -193,8 +193,11 @@ func (f *File) Read(b []byte) (n int, err error) {
} }
func (f *File) ReadAt(b []byte, off int64) (n int, err error) { func (f *File) ReadAt(b []byte, off int64) (n int, err error) {
prev := atomic.LoadInt64(&f.at)
atomic.StoreInt64(&f.at, off) atomic.StoreInt64(&f.at, off)
return f.Read(b) n, err = f.Read(b)
atomic.StoreInt64(&f.at, prev)
return
} }
func (f *File) Truncate(size int64) error { func (f *File) Truncate(size int64) error {