Source file src/os/stat_netbsd.go

     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.
     4  
     5  package os
     6  
     7  import (
     8  	"internal/filepathlite"
     9  	"syscall"
    10  	"time"
    11  )
    12  
    13  func fillFileStatFromSys(fs *fileStat, name string) {
    14  	fs.name = filepathlite.Base(name)
    15  	fs.size = fs.sys.Size
    16  	fs.modTime = time.Unix(fs.sys.Mtimespec.Unix())
    17  	fs.mode = FileMode(fs.sys.Mode & 0777)
    18  	switch fs.sys.Mode & syscall.S_IFMT {
    19  	case syscall.S_IFBLK:
    20  		fs.mode |= ModeDevice
    21  	case syscall.S_IFCHR:
    22  		fs.mode |= ModeDevice | ModeCharDevice
    23  	case syscall.S_IFDIR:
    24  		fs.mode |= ModeDir
    25  	case syscall.S_IFIFO:
    26  		fs.mode |= ModeNamedPipe
    27  	case syscall.S_IFLNK:
    28  		fs.mode |= ModeSymlink
    29  	case syscall.S_IFREG:
    30  		// nothing to do
    31  	case syscall.S_IFSOCK:
    32  		fs.mode |= ModeSocket
    33  	}
    34  	if fs.sys.Mode&syscall.S_ISGID != 0 {
    35  		fs.mode |= ModeSetgid
    36  	}
    37  	if fs.sys.Mode&syscall.S_ISUID != 0 {
    38  		fs.mode |= ModeSetuid
    39  	}
    40  	if fs.sys.Mode&syscall.S_ISVTX != 0 {
    41  		fs.mode |= ModeSticky
    42  	}
    43  }
    44  
    45  // For testing.
    46  func atime(fi FileInfo) time.Time {
    47  	return time.Unix(fi.Sys().(*syscall.Stat_t).Atimespec.Unix())
    48  }
    49  

View as plain text