1 // Copyright 2009 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 // +build darwin freebsd netbsd
14 func fillFileStatFromSys(fs *fileStat, name string) {
15 fs.name = basename(name)
16 fs.size = int64(fs.sys.Size)
17 fs.modTime = timespecToTime(fs.sys.Mtimespec)
18 fs.mode = FileMode(fs.sys.Mode & 0777)
19 switch fs.sys.Mode & syscall.S_IFMT {
20 case syscall.S_IFBLK, syscall.S_IFWHT:
23 fs.mode |= ModeDevice | ModeCharDevice
27 fs.mode |= ModeNamedPipe
29 fs.mode |= ModeSymlink
32 case syscall.S_IFSOCK:
35 if fs.sys.Mode&syscall.S_ISGID != 0 {
38 if fs.sys.Mode&syscall.S_ISUID != 0 {
41 if fs.sys.Mode&syscall.S_ISVTX != 0 {
46 func timespecToTime(ts syscall.Timespec) time.Time {
47 return time.Unix(int64(ts.Sec), int64(ts.Nsec))
51 func atime(fi FileInfo) time.Time {
52 return timespecToTime(fi.Sys().(*syscall.Stat_t).Atimespec)