Source file
src/os/stat_wasip1.go
1
2
3
4
5
6
7 package os
8
9 import (
10 "internal/filepathlite"
11 "syscall"
12 "time"
13 )
14
15 func fillFileStatFromSys(fs *fileStat, name string) {
16 fs.name = filepathlite.Base(name)
17 fs.size = int64(fs.sys.Size)
18 fs.mode = FileMode(fs.sys.Mode)
19 fs.modTime = time.Unix(0, int64(fs.sys.Mtime))
20
21 switch fs.sys.Filetype {
22 case syscall.FILETYPE_BLOCK_DEVICE:
23 fs.mode |= ModeDevice
24 case syscall.FILETYPE_CHARACTER_DEVICE:
25 fs.mode |= ModeDevice | ModeCharDevice
26 case syscall.FILETYPE_DIRECTORY:
27 fs.mode |= ModeDir
28 case syscall.FILETYPE_SOCKET_DGRAM:
29 fs.mode |= ModeSocket
30 case syscall.FILETYPE_SOCKET_STREAM:
31 fs.mode |= ModeSocket
32 case syscall.FILETYPE_SYMBOLIC_LINK:
33 fs.mode |= ModeSymlink
34 }
35 }
36
37
38 func atime(fi FileInfo) time.Time {
39 st := fi.Sys().(*syscall.Stat_t)
40 return time.Unix(0, int64(st.Atime))
41 }
42
View as plain text