diff options
Diffstat (limited to 'src/pkg')
-rw-r--r-- | src/pkg/os/file_windows.go | 4 | ||||
-rw-r--r-- | src/pkg/os/os_test.go | 16 | ||||
-rw-r--r-- | src/pkg/syscall/ztypes_windows.go | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/pkg/os/file_windows.go b/src/pkg/os/file_windows.go index 4cd454207..7a6356614 100644 --- a/src/pkg/os/file_windows.go +++ b/src/pkg/os/file_windows.go @@ -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 diff --git a/src/pkg/os/os_test.go b/src/pkg/os/os_test.go index 29706015d..1009600fe 100644 --- a/src/pkg/os/os_test.go +++ b/src/pkg/os/os_test.go @@ -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) + } +} diff --git a/src/pkg/syscall/ztypes_windows.go b/src/pkg/syscall/ztypes_windows.go index a2006f803..fb74b3e57 100644 --- a/src/pkg/syscall/ztypes_windows.go +++ b/src/pkg/syscall/ztypes_windows.go @@ -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 |