Files
bd2/go/internal/common/config/replace_windows.go
T
Flechazo fe67072b7d refactor(all): share core services and streamline launcher workflows
Centralize configuration, logging, database decryption and resource metadata.
Use task dependencies for development, SDK and release builds; move source tools and game downloads to Go with ordered client preparation.
Rename the client to BD2 Launcher, add native icons, and update packaging and SDK checks.
2026-10-14 00:04:21 +08:00

35 lines
692 B
Go

//go:build windows
package config
import (
"os"
"syscall"
"unsafe"
)
var moveFileEx = syscall.NewLazyDLL("kernel32.dll").NewProc("MoveFileExW")
func replaceFile(source, destination string) error {
sourcePtr, err := syscall.UTF16PtrFromString(source)
if err != nil {
return err
}
destinationPtr, err := syscall.UTF16PtrFromString(destination)
if err != nil {
return err
}
result, _, callErr := moveFileEx.Call(
uintptr(unsafe.Pointer(sourcePtr)),
uintptr(unsafe.Pointer(destinationPtr)),
0x1|0x8, // MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH
)
if result == 0 {
if callErr != syscall.Errno(0) {
return callErr
}
return os.ErrInvalid
}
return nil
}