1
0
mirror of https://github.com/golang/go synced 2024-11-20 06:44:40 -07:00

implement os.FileInfo.*time_ns for windows

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/1145044
This commit is contained in:
Alex Brainman 2010-05-31 13:43:40 +02:00 committed by Andrew Gerrand
parent 1192c175fe
commit 901976cfc3
4 changed files with 17 additions and 13 deletions

7
src/pkg/os/stat_windows.go Executable file → Normal file
View File

@ -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
}

View File

@ -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
}

View File

@ -1,4 +1,4 @@
// 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

View File

@ -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