mirror of
https://github.com/rclone/rclone.git
synced 2025-01-20 07:02:45 +08:00
local: fix setting of btime on directories on Windows
Before this change this would give errors like this failed to set metadata on directory: failed to set birth (creation) time: Access is denied. This was caused by opening the directory in the wrong mode.
This commit is contained in:
parent
7b01564f83
commit
a60da2ef38
|
@ -4,7 +4,6 @@
|
||||||
package local
|
package local
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -13,7 +12,13 @@ const haveSetBTime = true
|
||||||
|
|
||||||
// setBTime sets the birth time of the file passed in
|
// setBTime sets the birth time of the file passed in
|
||||||
func setBTime(name string, btime time.Time) (err error) {
|
func setBTime(name string, btime time.Time) (err error) {
|
||||||
h, err := syscall.Open(name, os.O_RDWR, 0755)
|
pathp, err := syscall.UTF16PtrFromString(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
h, err := syscall.CreateFile(pathp,
|
||||||
|
syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil,
|
||||||
|
syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user