os, syscall: implement Stat and Lstat

File.Stat is left as a stub for now.

Tests are a bit stubbed down because os.ReadDir, os.Symlink, and t.TempDir are not yet (fully) implemented.
TODO: reimport tests from upstream as those materialize.
This commit is contained in:
Dan Kegel
2021-11-28 08:30:55 -08:00
committed by Ron Evans
parent 5127b9d65b
commit ec9fd3fb38
17 changed files with 1118 additions and 25 deletions
-25
View File
@@ -171,11 +171,6 @@ func (f *File) Stat() (FileInfo, error) {
return nil, &PathError{"stat", f.name, ErrNotImplemented}
}
// Sync is a stub, not yet implemented
func (f *File) Sync() error {
return ErrNotImplemented
}
func (f *File) SyscallConn() (syscall.RawConn, error) {
return nil, ErrNotImplemented
}
@@ -190,16 +185,6 @@ func (f *File) Truncate(size int64) error {
return &PathError{"truncate", f.name, ErrNotImplemented}
}
const (
PathSeparator = '/' // OS-specific path separator
PathListSeparator = ':' // OS-specific path list separator
)
// IsPathSeparator reports whether c is a directory separator character.
func IsPathSeparator(c uint8) bool {
return PathSeparator == c
}
// PathError records an error and the operation and file path that caused it.
// TODO: PathError moved to io/fs in go 1.16 and left an alias in os/errors.go.
// Do the same once we drop support for go 1.15.
@@ -245,16 +230,6 @@ const (
O_TRUNC int = syscall.O_TRUNC
)
// Stat is a stub, not yet implemented
func Stat(name string) (FileInfo, error) {
return nil, &PathError{"stat", name, ErrNotImplemented}
}
// Lstat is a stub, not yet implemented
func Lstat(name string) (FileInfo, error) {
return nil, &PathError{"lstat", name, ErrNotImplemented}
}
func Getwd() (string, error) {
return syscall.Getwd()
}