From 12eee9edbc0a63ba5802541ec9bfec4a925637ee Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Nov 2011 12:38:54 -0500 Subject: [PATCH] os: fix windows build TBR=brainman CC=golang-dev https://golang.org/cl/5449048 --- src/pkg/os/export_test.go | 1 - src/pkg/os/stat_windows.go | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pkg/os/export_test.go b/src/pkg/os/export_test.go index 29f051162a..9c6ef42974 100644 --- a/src/pkg/os/export_test.go +++ b/src/pkg/os/export_test.go @@ -6,5 +6,4 @@ package os // Export for testing. -var TimespecToTime = timespecToTime var Atime = atime diff --git a/src/pkg/os/stat_windows.go b/src/pkg/os/stat_windows.go index d024915ee0..ddecd1118f 100644 --- a/src/pkg/os/stat_windows.go +++ b/src/pkg/os/stat_windows.go @@ -77,7 +77,11 @@ func basename(name string) string { return name } -func toFileInfo(name string, fa, sizehi, sizelo uint32, ctime, atime, wtime syscall.Filetime) FileInfo { +type winTimes struct { + atime, ctime syscall.Filetime +} + +func toFileInfo(name string, fa, sizehi, sizelo uint32, ctime, atime, mtime syscall.Filetime) FileInfo { fs := new(FileStat) fs.mode = 0 if fa&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 { @@ -90,10 +94,16 @@ func toFileInfo(name string, fa, sizehi, sizelo uint32, ctime, atime, wtime sysc } fs.size = int64(sizehi)<<32 + int64(sizelo) fs.name = name - fs.modTime = time.Unix(0, wtime.Nanoseconds()) + fs.modTime = time.Unix(0, mtime.Nanoseconds()) + fs.Sys = &winTimes{atime, ctime} return fs } func sameFile(fs1, fs2 *FileStat) bool { return false } + +// For testing. +func atime(fi FileInfo) time.Time { + return time.Unix(0, fi.(*FileStat).Sys.(*winTimes).atime.Nanoseconds()) +}