Merge pull request #7491 from thaJeztah/chtimes_redundancy
archive: windows: chtimes(): remove redundant conversion
This commit is contained in:
commit
4a0ddfa974
@ -25,18 +25,17 @@ import (
|
|||||||
// chtimes will set the create time on a file using the given modtime.
|
// chtimes will set the create time on a file using the given modtime.
|
||||||
// This requires calling SetFileTime and explicitly including the create time.
|
// This requires calling SetFileTime and explicitly including the create time.
|
||||||
func chtimes(path string, atime, mtime time.Time) error {
|
func chtimes(path string, atime, mtime time.Time) error {
|
||||||
ctimespec := windows.NsecToTimespec(mtime.UnixNano())
|
pathp, err := windows.UTF16PtrFromString(path)
|
||||||
pathp, e := windows.UTF16PtrFromString(path)
|
if err != nil {
|
||||||
if e != nil {
|
return err
|
||||||
return e
|
|
||||||
}
|
}
|
||||||
h, e := windows.CreateFile(pathp,
|
h, err := windows.CreateFile(pathp,
|
||||||
windows.FILE_WRITE_ATTRIBUTES, windows.FILE_SHARE_WRITE, nil,
|
windows.FILE_WRITE_ATTRIBUTES, windows.FILE_SHARE_WRITE, nil,
|
||||||
windows.OPEN_EXISTING, windows.FILE_FLAG_BACKUP_SEMANTICS, 0)
|
windows.OPEN_EXISTING, windows.FILE_FLAG_BACKUP_SEMANTICS, 0)
|
||||||
if e != nil {
|
if err != nil {
|
||||||
return e
|
return err
|
||||||
}
|
}
|
||||||
defer windows.Close(h)
|
defer windows.Close(h)
|
||||||
c := windows.NsecToFiletime(windows.TimespecToNsec(ctimespec))
|
c := windows.NsecToFiletime(mtime.UnixNano())
|
||||||
return windows.SetFileTime(h, &c, nil, nil)
|
return windows.SetFileTime(h, &c, nil, nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user