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.
12 func fillFileStatFromSys(fs
*fileStat
, name
string) {
13 fs
.name
= basename(name
)
15 fs
.modTime
= timespecToTime(fs
.sys
.Mtime
, fs
.sys
.MtimeNsec
)
16 fs
.mode
= FileMode(fs
.sys
.Mode
& 0777)
17 switch fs
.sys
.Mode
& syscall
.S_IFMT
{
21 fs
.mode |
= ModeDevice | ModeCharDevice
25 fs
.mode |
= ModeNamedPipe
27 fs
.mode |
= ModeSymlink
30 case syscall
.S_IFSOCK
:
33 if fs
.sys
.Mode
&syscall
.S_ISGID
!= 0 {
36 if fs
.sys
.Mode
&syscall
.S_ISUID
!= 0 {
39 if fs
.sys
.Mode
&syscall
.S_ISVTX
!= 0 {
44 func timespecToTime(sec
, nsec
int64) time
.Time
{
45 return time
.Unix(sec
, nsec
)
49 func atime(fi FileInfo
) time
.Time
{
50 st
:= fi
.Sys().(*syscall
.Stat_t
)
51 return timespecToTime(st
.Atime
, st
.AtimeNsec
)