mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
It has no external users, and this package still has too many different responsibilities, some of which may be available elsewhere, so moving it internal so that we can decide to dismantle it further. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
26 lines
653 B
Go
26 lines
653 B
Go
package system
|
|
|
|
import (
|
|
"time"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
// setCTime will set the create time on a file. On Windows, this requires
|
|
// calling SetFileTime and explicitly including the create time.
|
|
func setCTime(path string, ctime time.Time) error {
|
|
pathp, err := windows.UTF16PtrFromString(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
h, err := windows.CreateFile(pathp,
|
|
windows.FILE_WRITE_ATTRIBUTES, windows.FILE_SHARE_WRITE, nil,
|
|
windows.OPEN_EXISTING, windows.FILE_FLAG_BACKUP_SEMANTICS, 0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer windows.Close(h)
|
|
c := windows.NsecToFiletime(ctime.UnixNano())
|
|
return windows.SetFileTime(h, &c, nil, nil)
|
|
}
|