mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 08:54:10 +01:00
29 lines
515 B
Go
29 lines
515 B
Go
|
//go:build windows
|
||
|
// +build windows
|
||
|
|
||
|
package local
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"time"
|
||
|
"syscall"
|
||
|
)
|
||
|
|
||
|
const haveSetBTime = true
|
||
|
|
||
|
// setBTime sets the the birth time of the file passed in
|
||
|
func setBTime(name string, btime time.Time) (err error) {
|
||
|
h, err := syscall.Open(name, os.O_RDWR, 0755)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer func() {
|
||
|
closeErr := syscall.Close(h)
|
||
|
if err == nil {
|
||
|
err = closeErr
|
||
|
}
|
||
|
}()
|
||
|
bFileTime := syscall.NsecToFiletime(btime.UnixNano())
|
||
|
return syscall.SetFileTime(h, &bFileTime, nil, nil)
|
||
|
}
|