返回 DeepSeek-Reasonix
move_noreplace_windows.go
根目录 / internal / tool / builtin / move_noreplace_windows.go
1 //go:build windows
2
3 package builtin
4
5 import (
6 "golang.org/x/sys/windows"
7 "os"
8 )
9
10 func renameNoReplace(src, dst string) error {
11 from, err := windows.UTF16PtrFromString(src)
12 if err != nil {
13 return err
14 }
15 to, err := windows.UTF16PtrFromString(dst)
16 if err != nil {
17 return err
18 }
19 // No MOVEFILE_REPLACE_EXISTING and no copy fallback.
20 if err := windows.MoveFileEx(from, to, 0); err != nil {
21 return &os.LinkError{Op: "rename", Old: src, New: dst, Err: err}
22 }
23 return nil
24 }
25
25 lines GO