10 //setCTime will set the create time on a file. On Windows, this requires
11 //calling SetFileTime and explicitly including the create time.
12 func setCTime(path string, ctime time.Time) error {
13 ctimespec := syscall.NsecToTimespec(ctime.UnixNano())
14 pathp, e := syscall.UTF16PtrFromString(path)
18 h, e := syscall.CreateFile(pathp,
19 syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil,
20 syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0)
24 defer syscall.Close(h)
25 c := syscall.NsecToFiletime(syscall.TimespecToNsec(ctimespec))
26 return syscall.SetFileTime(h, &c, nil, nil)