Files
MyGoNavi/internal/app/sql_audit_atomic_replace_windows.go
Syngnat 4d5c0e6bb9 feat(cli): 新增独立命令行与发布链
- 新增无头运行时及连接、查询、导出、批处理、审计和 MCP 命令
- 复用活动数据根、密文存储与跨进程锁,落实写入安全和取消语义
- 增加六平台 CLI 归档、独立校验和、Docker、npm 与 WinGet 分发
- 隔离 GUI/CLI 更新资产并强化 macOS 签名与公证门禁
- 补充并发、审计、事务及发布契约回归测试

Refs #902
2026-08-11 10:34:58 +08:00

37 lines
983 B
Go

//go:build windows
package app
import "golang.org/x/sys/windows"
func atomicReplaceSQLAuditFile(source, target string) error {
sourcePath, err := windows.UTF16PtrFromString(source)
if err != nil {
return err
}
targetPath, err := windows.UTF16PtrFromString(target)
if err != nil {
return err
}
return windows.MoveFileEx(
sourcePath,
targetPath,
windows.MOVEFILE_REPLACE_EXISTING|windows.MOVEFILE_WRITE_THROUGH,
)
}
// atomicCreateSQLAuditFile publishes source only when target does not exist.
// MoveFileEx without MOVEFILE_REPLACE_EXISTING maps to a CREATE_NEW-style
// operation and keeps the destination hidden until the move completes.
func atomicCreateSQLAuditFile(source, target string) error {
sourcePath, err := windows.UTF16PtrFromString(source)
if err != nil {
return err
}
targetPath, err := windows.UTF16PtrFromString(target)
if err != nil {
return err
}
return windows.MoveFileEx(sourcePath, targetPath, windows.MOVEFILE_WRITE_THROUGH)
}