2022-05-24 19:06:16 +02:00
|
|
|
//go:build windows
|
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package local
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"syscall"
|
2022-08-05 17:35:41 +02:00
|
|
|
"time"
|
2022-05-24 19:06:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
const haveSetBTime = true
|
|
|
|
|
2022-08-14 04:56:32 +02:00
|
|
|
// setBTime sets the birth time of the file passed in
|
2022-05-24 19:06:16 +02:00
|
|
|
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)
|
|
|
|
}
|