mirror of
https://github.com/golang/go
synced 2024-11-20 08:24:42 -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:
parent
1192c175fe
commit
901976cfc3
7
src/pkg/os/stat_windows.go
Executable file → Normal file
7
src/pkg/os/stat_windows.go
Executable file → Normal 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.Size = int64(sizehi)<<32 + int64(sizelo)
|
||||||
fi.Name = name
|
fi.Name = name
|
||||||
fi.FollowedSymlink = false
|
fi.FollowedSymlink = false
|
||||||
// TODO(brainman): use ctime atime wtime to prime following FileInfo fields
|
fi.Atime_ns = atime.Microseconds() * 1000
|
||||||
fi.Atime_ns = 0
|
fi.Mtime_ns = wtime.Microseconds() * 1000
|
||||||
fi.Mtime_ns = 0
|
fi.Ctime_ns = ctime.Microseconds() * 1000
|
||||||
fi.Ctime_ns = 0
|
|
||||||
return fi
|
return fi
|
||||||
}
|
}
|
||||||
|
@ -369,16 +369,11 @@ func Ftruncate(fd int, length int64) (errno int) {
|
|||||||
|
|
||||||
func Gettimeofday(tv *Timeval) (errno int) {
|
func Gettimeofday(tv *Timeval) (errno int) {
|
||||||
var ft Filetime
|
var ft Filetime
|
||||||
// 100-nanosecond intervals since January 1, 1601
|
|
||||||
GetSystemTimeAsFileTime(&ft)
|
GetSystemTimeAsFileTime(&ft)
|
||||||
t := uint64(ft.HighDateTime)<<32 + uint64(ft.LowDateTime)
|
ms := ft.Microseconds()
|
||||||
// convert into microseconds
|
|
||||||
t /= 10
|
|
||||||
// change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
|
|
||||||
t -= 11644473600000000
|
|
||||||
// split into sec / usec
|
// split into sec / usec
|
||||||
tv.Sec = int32(t / 1e6)
|
tv.Sec = int32(ms / 1e6)
|
||||||
tv.Usec = int32(t) - tv.Sec
|
tv.Usec = int32(ms) - tv.Sec
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
|
|
||||||
package syscall
|
package syscall
|
||||||
|
@ -113,6 +113,16 @@ type Filetime struct {
|
|||||||
HighDateTime uint32
|
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 {
|
type Win32finddata struct {
|
||||||
FileAttributes uint32
|
FileAttributes uint32
|
||||||
CreationTime Filetime
|
CreationTime Filetime
|
||||||
|
Loading…
Reference in New Issue
Block a user