github.com/lovishpuri/go-40569/src@v0.0.0-20230519171745-f8623e7c56cf/os/stat_wasip1.go (about) 1 // Copyright 2023 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. 4 5 //go:build wasip1 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 = int64(fs.sys.Size) 17 fs.mode = FileMode(fs.sys.Mode) 18 fs.modTime = time.Unix(0, int64(fs.sys.Mtime)) 19 20 switch fs.sys.Filetype { 21 case syscall.FILETYPE_BLOCK_DEVICE: 22 fs.mode |= ModeDevice 23 case syscall.FILETYPE_CHARACTER_DEVICE: 24 fs.mode |= ModeDevice | ModeCharDevice 25 case syscall.FILETYPE_DIRECTORY: 26 fs.mode |= ModeDir 27 case syscall.FILETYPE_SOCKET_DGRAM: 28 fs.mode |= ModeSocket 29 case syscall.FILETYPE_SOCKET_STREAM: 30 fs.mode |= ModeSocket 31 case syscall.FILETYPE_SYMBOLIC_LINK: 32 fs.mode |= ModeSymlink 33 } 34 } 35 36 // For testing. 37 func atime(fi FileInfo) time.Time { 38 st := fi.Sys().(*syscall.Stat_t) 39 return time.Unix(0, int64(st.Atime)) 40 }