Commit 901976cf authored by Alex Brainman's avatar Alex Brainman Committed by Andrew Gerrand

implement os.FileInfo.*time_ns for windows

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/1145044
parent 1192c175
......@@ -39,9 +39,8 @@ func setFileInfo(fi *FileInfo, name string, fa, sizehi, sizelo uint32, ctime, at
fi.Size = int64(sizehi)<<32 + int64(sizelo)
fi.Name = name
fi.FollowedSymlink = false
// TODO(brainman): use ctime atime wtime to prime following FileInfo fields
fi.Atime_ns = 0
fi.Mtime_ns = 0
fi.Ctime_ns = 0
fi.Atime_ns = atime.Microseconds() * 1000
fi.Mtime_ns = wtime.Microseconds() * 1000
fi.Ctime_ns = ctime.Microseconds() * 1000
return fi
}
......@@ -369,16 +369,11 @@ func Ftruncate(fd int, length int64) (errno int) {
func Gettimeofday(tv *Timeval) (errno int) {
var ft Filetime
// 100-nanosecond intervals since January 1, 1601
GetSystemTimeAsFileTime(&ft)
t := uint64(ft.HighDateTime)<<32 + uint64(ft.LowDateTime)
// convert into microseconds
t /= 10
// change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
t -= 11644473600000000
ms := ft.Microseconds()
// split into sec / usec
tv.Sec = int32(t / 1e6)
tv.Usec = int32(t) - tv.Sec
tv.Sec = int32(ms / 1e6)
tv.Usec = int32(ms) - tv.Sec
return 0
}
......
// mksyscall_mingw.sh -l32 syscall_mingw.go zsyscall_mingw_386.go
// mksyscall_windows.sh -l32 syscall_windows.go syscall_windows_386.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall
......
......@@ -113,6 +113,16 @@ type Filetime struct {
HighDateTime uint32
}
func (ft *Filetime) Microseconds() int64 {
// 100-nanosecond intervals since January 1, 1601
ms := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)
// convert into microseconds
ms /= 10
// change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
ms -= 11644473600000000
return ms
}
type Win32finddata struct {
FileAttributes uint32
CreationTime Filetime
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment