Source file src/os/stat_wasip1.go

     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  	"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  // For testing.
    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