github.com/jingleWang/moby@v1.13.1/pkg/system/stat_darwin.go (about) 1 package system 2 3 import ( 4 "syscall" 5 ) 6 7 // fromStatT creates a system.StatT type from a syscall.Stat_t type 8 func fromStatT(s *syscall.Stat_t) (*StatT, error) { 9 return &StatT{size: s.Size, 10 mode: uint32(s.Mode), 11 uid: s.Uid, 12 gid: s.Gid, 13 rdev: uint64(s.Rdev), 14 mtim: s.Mtimespec}, nil 15 } 16 17 // FromStatT loads a system.StatT from a syscall.Stat_t. 18 func FromStatT(s *syscall.Stat_t) (*StatT, error) { 19 return fromStatT(s) 20 } 21 22 // Stat takes a path to a file and returns 23 // a system.StatT type pertaining to that file. 24 // 25 // Throws an error if the file does not exist 26 func Stat(path string) (*StatT, error) { 27 s := &syscall.Stat_t{} 28 if err := syscall.Stat(path, s); err != nil { 29 return nil, err 30 } 31 return fromStatT(s) 32 }