jit: Fix Darwin bootstrap after r15-1699.
[official-gcc.git] / libgo / go / os / stat_unix.go
blobb4ab62019dd587a22f22760de489509950567677
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 //go:build aix || darwin || dragonfly || freebsd || hurd || (js && wasm) || linux || netbsd || openbsd || solaris
7 package os
9 import (
10 "syscall"
13 // Stat returns the FileInfo structure describing file.
14 // If there is an error, it will be of type *PathError.
15 func (f *File) Stat() (FileInfo, error) {
16 if f == nil {
17 return nil, ErrInvalid
19 var fs fileStat
20 err := f.pfd.Fstat(&fs.sys)
21 if err != nil {
22 return nil, &PathError{Op: "stat", Path: f.name, Err: err}
24 fillFileStatFromSys(&fs, f.name)
25 return &fs, nil
28 // statNolog stats a file with no test logging.
29 func statNolog(name string) (FileInfo, error) {
30 var fs fileStat
31 err := ignoringEINTR(func() error {
32 return syscall.Stat(name, &fs.sys)
34 if err != nil {
35 return nil, &PathError{Op: "stat", Path: name, Err: err}
37 fillFileStatFromSys(&fs, name)
38 return &fs, nil
41 // lstatNolog lstats a file with no test logging.
42 func lstatNolog(name string) (FileInfo, error) {
43 var fs fileStat
44 err := ignoringEINTR(func() error {
45 return syscall.Lstat(name, &fs.sys)
47 if err != nil {
48 return nil, &PathError{Op: "lstat", Path: name, Err: err}
50 fillFileStatFromSys(&fs, name)
51 return &fs, nil