// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package os

import (
	
	
)

func fillFileStatFromSys( *fileStat,  string) {
	.name = basename()
	.size = .sys.Size
	.modTime = timespecToTime(.sys.Mtim)
	.mode = FileMode(.sys.Mode & 0777)
	switch .sys.Mode & syscall.S_IFMT {
	case syscall.S_IFBLK:
		.mode |= ModeDevice
	case syscall.S_IFCHR:
		.mode |= ModeDevice | ModeCharDevice
	case syscall.S_IFDIR:
		.mode |= ModeDir
	case syscall.S_IFIFO:
		.mode |= ModeNamedPipe
	case syscall.S_IFLNK:
		.mode |= ModeSymlink
	case syscall.S_IFREG:
		// nothing to do
	case syscall.S_IFSOCK:
		.mode |= ModeSocket
	}
	if .sys.Mode&syscall.S_ISGID != 0 {
		.mode |= ModeSetgid
	}
	if .sys.Mode&syscall.S_ISUID != 0 {
		.mode |= ModeSetuid
	}
	if .sys.Mode&syscall.S_ISVTX != 0 {
		.mode |= ModeSticky
	}
}

func timespecToTime( syscall.Timespec) time.Time {
	return time.Unix(int64(.Sec), int64(.Nsec))
}

// For testing.
func atime( FileInfo) time.Time {
	return timespecToTime(.Sys().(*syscall.Stat_t).Atim)
}