...
Source file
src/os/stat_js.go
Documentation: os
1
2
3
4
5
6
7 package os
8
9 import (
10 "syscall"
11 "time"
12 )
13
14 func fillFileStatFromSys(fs *fileStat, name string) {
15 fs.name = basename(name)
16 fs.size = fs.sys.Size
17 fs.modTime = time.Unix(fs.sys.Mtime, fs.sys.MtimeNsec)
18 fs.mode = FileMode(fs.sys.Mode & 0777)
19 switch fs.sys.Mode & syscall.S_IFMT {
20 case syscall.S_IFBLK:
21 fs.mode |= ModeDevice
22 case syscall.S_IFCHR:
23 fs.mode |= ModeDevice | ModeCharDevice
24 case syscall.S_IFDIR:
25 fs.mode |= ModeDir
26 case syscall.S_IFIFO:
27 fs.mode |= ModeNamedPipe
28 case syscall.S_IFLNK:
29 fs.mode |= ModeSymlink
30 case syscall.S_IFREG:
31
32 case syscall.S_IFSOCK:
33 fs.mode |= ModeSocket
34 }
35 if fs.sys.Mode&syscall.S_ISGID != 0 {
36 fs.mode |= ModeSetgid
37 }
38 if fs.sys.Mode&syscall.S_ISUID != 0 {
39 fs.mode |= ModeSetuid
40 }
41 if fs.sys.Mode&syscall.S_ISVTX != 0 {
42 fs.mode |= ModeSticky
43 }
44 }
45
46
47 func atime(fi FileInfo) time.Time {
48 st := fi.Sys().(*syscall.Stat_t)
49 return time.Unix(st.Atime, st.AtimeNsec)
50 }
51
View as plain text