Skip to content

Commit ee663cc

Browse files
dkegel-fastlydeadprogram
authored andcommitted
Revert "Kludge: work around lack of syscall.seek on 386 and arm, #1906"
This reverts commit 60b483b.
1 parent cd867b7 commit ee663cc

File tree

5 files changed

+27
-84
lines changed

5 files changed

+27
-84
lines changed

src/os/file.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ func (f *File) Readdirnames(n int) (names []string, err error) {
180180
return nil, &PathError{"readdirnames", f.name, ErrNotImplemented}
181181
}
182182

183+
// Seek sets the offset for the next Read or Write on file to offset, interpreted
184+
// according to whence: 0 means relative to the origin of the file, 1 means
185+
// relative to the current offset, and 2 means relative to the end.
186+
// It returns the new offset and an error, if any.
187+
// The behavior of Seek on a file opened with O_APPEND is not specified.
188+
//
189+
// If f is a directory, the behavior of Seek varies by operating
190+
// system; you can seek to the beginning of the directory on Unix-like
191+
// operating systems, but not on Windows.
192+
func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
193+
return f.handle.Seek(offset, whence)
194+
}
195+
183196
func (f *File) SyscallConn() (syscall.RawConn, error) {
184197
return nil, ErrNotImplemented
185198
}

src/os/file_windows.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,6 @@ func (f unixFileHandle) Seek(offset int64, whence int) (int64, error) {
8282
return newoffset, handleSyscallError(err)
8383
}
8484

85-
// Seek sets the offset for the next Read or Write on file to offset, interpreted
86-
// according to whence: 0 means relative to the origin of the file, 1 means
87-
// relative to the current offset, and 2 means relative to the end.
88-
// It returns the new offset and an error, if any.
89-
// The behavior of Seek on a file opened with O_APPEND is not specified.
90-
//
91-
// If f is a directory, the behavior of Seek varies by operating
92-
// system; you can seek to the beginning of the directory on Unix-like
93-
// operating systems, but not on Windows.
94-
// TODO: move this back to file.go once syscall.seek is implemented on 386 and arm.
95-
func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
96-
return f.handle.Seek(offset, whence)
97-
}
98-
9985
// isWindowsNulName reports whether name is os.DevNull ('NUL') on Windows.
10086
// True is returned if name is 'NUL' whatever the case.
10187
func isWindowsNulName(name string) bool {

src/os/seek_unix_bad.go

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/os/seek_unix_good.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/os/stat_unix.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ func (f *File) Sync() error {
1515
return ErrNotImplemented
1616
}
1717

18+
// Stat returns the FileInfo structure describing file.
19+
// If there is an error, it will be of type *PathError.
20+
func (f *File) Stat() (FileInfo, error) {
21+
var fs fileStat
22+
err := ignoringEINTR(func() error {
23+
return syscall.Fstat(int(f.handle.(unixFileHandle)), &fs.sys)
24+
})
25+
if err != nil {
26+
return nil, &PathError{Op: "fstat", Path: f.name, Err: err}
27+
}
28+
fillFileStatFromSys(&fs, f.name)
29+
return &fs, nil
30+
}
31+
1832
// statNolog stats a file with no test logging.
1933
func statNolog(name string) (FileInfo, error) {
2034
var fs fileStat

0 commit comments

Comments
 (0)