1
0
mirror of https://github.com/golang/go synced 2024-11-12 03:40:21 -07:00

os: return io.EOF from windows ReadAt as documented

Fixes #5619.

R=golang-dev, r, peter.armitage, go.peter.90
CC=golang-dev
https://golang.org/cl/9952044
This commit is contained in:
Alex Brainman 2013-06-10 19:14:41 +10:00
parent 4f514e8691
commit bb6e265fed
3 changed files with 21 additions and 0 deletions

View File

@ -312,6 +312,10 @@ func (f *File) pread(b []byte, off int64) (n int, err error) {
var done uint32
e = syscall.ReadFile(syscall.Handle(f.fd), b, &done, &o)
if e != nil {
if e == syscall.ERROR_HANDLE_EOF {
// end of file
return 0, nil
}
return 0, e
}
return int(done), nil

View File

@ -1114,3 +1114,19 @@ func TestStatDirModeExec(t *testing.T) {
t.Errorf("Stat %q: mode %#o want %#o", path, dir.Mode()&mode, mode)
}
}
func TestReadAtEOF(t *testing.T) {
f := newFile("TestReadAtEOF", t)
defer Remove(f.Name())
defer f.Close()
_, err := f.ReadAt(make([]byte, 10), 0)
switch err {
case io.EOF:
// all good
case nil:
t.Fatalf("ReadAt succeeded")
default:
t.Fatalf("ReadAt failed: %s", err)
}
}

View File

@ -10,6 +10,7 @@ const (
ERROR_PATH_NOT_FOUND Errno = 3
ERROR_ACCESS_DENIED Errno = 5
ERROR_NO_MORE_FILES Errno = 18
ERROR_HANDLE_EOF Errno = 38
ERROR_FILE_EXISTS Errno = 80
ERROR_BROKEN_PIPE Errno = 109
ERROR_BUFFER_OVERFLOW Errno = 111