Revert "Kludge: work around lack of syscall.seek on 386 and arm, #1906"
This reverts commit 60b483bd3b
.
Этот коммит содержится в:
родитель
cd867b72b9
коммит
ee663ccb96
5 изменённых файлов: 27 добавлений и 84 удалений
|
@ -180,6 +180,19 @@ func (f *File) Readdirnames(n int) (names []string, err error) {
|
|||
return nil, &PathError{"readdirnames", f.name, ErrNotImplemented}
|
||||
}
|
||||
|
||||
// Seek sets the offset for the next Read or Write on file to offset, interpreted
|
||||
// according to whence: 0 means relative to the origin of the file, 1 means
|
||||
// relative to the current offset, and 2 means relative to the end.
|
||||
// It returns the new offset and an error, if any.
|
||||
// The behavior of Seek on a file opened with O_APPEND is not specified.
|
||||
//
|
||||
// If f is a directory, the behavior of Seek varies by operating
|
||||
// system; you can seek to the beginning of the directory on Unix-like
|
||||
// operating systems, but not on Windows.
|
||||
func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
|
||||
return f.handle.Seek(offset, whence)
|
||||
}
|
||||
|
||||
func (f *File) SyscallConn() (syscall.RawConn, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
|
|
@ -82,20 +82,6 @@ func (f unixFileHandle) Seek(offset int64, whence int) (int64, error) {
|
|||
return newoffset, handleSyscallError(err)
|
||||
}
|
||||
|
||||
// Seek sets the offset for the next Read or Write on file to offset, interpreted
|
||||
// according to whence: 0 means relative to the origin of the file, 1 means
|
||||
// relative to the current offset, and 2 means relative to the end.
|
||||
// It returns the new offset and an error, if any.
|
||||
// The behavior of Seek on a file opened with O_APPEND is not specified.
|
||||
//
|
||||
// If f is a directory, the behavior of Seek varies by operating
|
||||
// system; you can seek to the beginning of the directory on Unix-like
|
||||
// operating systems, but not on Windows.
|
||||
// TODO: move this back to file.go once syscall.seek is implemented on 386 and arm.
|
||||
func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
|
||||
return f.handle.Seek(offset, whence)
|
||||
}
|
||||
|
||||
// isWindowsNulName reports whether name is os.DevNull ('NUL') on Windows.
|
||||
// True is returned if name is 'NUL' whatever the case.
|
||||
func isWindowsNulName(name string) bool {
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
// +build linux,!baremetal,386 linux,!baremetal,arm,!wasi
|
||||
|
||||
// Functions broken by lack of seek().
|
||||
// Stat is broken because it uses Time, which has a preadn function that uses seek :-(
|
||||
//
|
||||
// TODO: remove this file once tinygo gets syscall.Seek support on i386
|
||||
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package os
|
||||
|
||||
// Seek sets the offset for the next Read or Write on file to offset, interpreted
|
||||
// according to whence: 0 means relative to the origin of the file, 1 means
|
||||
// relative to the current offset, and 2 means relative to the end.
|
||||
// It returns the new offset and an error, if any.
|
||||
// The behavior of Seek on a file opened with O_APPEND is not specified.
|
||||
//
|
||||
// If f is a directory, the behavior of Seek varies by operating
|
||||
// system; you can seek to the beginning of the directory on Unix-like
|
||||
// operating systems, but not on Windows.
|
||||
func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
|
||||
return f.handle.Seek(offset, whence)
|
||||
}
|
||||
|
||||
// Stat returns the FileInfo structure describing file.
|
||||
// If there is an error, it will be of type *PathError.
|
||||
func (f *File) Stat() (FileInfo, error) {
|
||||
return nil, &PathError{Op: "fstat", Path: f.name, Err: ErrNotImplemented}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
// +build darwin linux,!baremetal,!386,!arm wasi
|
||||
|
||||
// Functions broken by lack of seek().
|
||||
// Stat is broken because it uses Time, which has a preadn function that uses seek :-(
|
||||
//
|
||||
// TODO: merge these functions back where they belong once tinygo gets syscall.Seek support on i386
|
||||
|
||||
package os
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Seek sets the offset for the next Read or Write on file to offset, interpreted
|
||||
// according to whence: 0 means relative to the origin of the file, 1 means
|
||||
// relative to the current offset, and 2 means relative to the end.
|
||||
// It returns the new offset and an error, if any.
|
||||
// The behavior of Seek on a file opened with O_APPEND is not specified.
|
||||
//
|
||||
// If f is a directory, the behavior of Seek varies by operating
|
||||
// system; you can seek to the beginning of the directory on Unix-like
|
||||
// operating systems, but not on Windows.
|
||||
func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
|
||||
return f.handle.Seek(offset, whence)
|
||||
}
|
||||
|
||||
// Stat returns the FileInfo structure describing file.
|
||||
// If there is an error, it will be of type *PathError.
|
||||
func (f *File) Stat() (FileInfo, error) {
|
||||
var fs fileStat
|
||||
err := ignoringEINTR(func() error {
|
||||
return syscall.Fstat(int(f.handle.(unixFileHandle)), &fs.sys)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, &PathError{Op: "fstat", Path: f.name, Err: err}
|
||||
}
|
||||
fillFileStatFromSys(&fs, f.name)
|
||||
return &fs, nil
|
||||
}
|
|
@ -15,6 +15,20 @@ func (f *File) Sync() error {
|
|||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
// Stat returns the FileInfo structure describing file.
|
||||
// If there is an error, it will be of type *PathError.
|
||||
func (f *File) Stat() (FileInfo, error) {
|
||||
var fs fileStat
|
||||
err := ignoringEINTR(func() error {
|
||||
return syscall.Fstat(int(f.handle.(unixFileHandle)), &fs.sys)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, &PathError{Op: "fstat", Path: f.name, Err: err}
|
||||
}
|
||||
fillFileStatFromSys(&fs, f.name)
|
||||
return &fs, nil
|
||||
}
|
||||
|
||||
// statNolog stats a file with no test logging.
|
||||
func statNolog(name string) (FileInfo, error) {
|
||||
var fs fileStat
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче