lychee-slicer/platform/windows.go
2024-10-20 23:04:38 +02:00

48 lines
909 B
Go

//go:build windows
package platform
import (
"os"
"path/filepath"
"syscall"
"github.com/ffred/guitocons"
"github.com/winlabs/gowin32"
"github.com/winlabs/gowin32/wrappers"
)
func init() {
guitocons.Guitocons()
}
func IsWindowsRetryable(err error) bool {
if err == syscall.ERROR_ACCESS_DENIED {
return true
}
return false
}
func WindowsRename(from, to string) error {
return wrappers.SHFileOperation(&wrappers.SHFILEOPSTRUCT{
Func: wrappers.FO_MOVE,
From: gowin32.MakeDoubleNullTerminatedLpstr(from),
To: gowin32.MakeDoubleNullTerminatedLpstr(to),
Flags: wrappers.FOF_NOCONFIRMATION,
})
}
func FindProgram() string {
// get program files path
pf, err := gowin32.GetKnownFolderPath(gowin32.KnownFolderProgramFiles)
if err != nil {
return ""
}
p := filepath.Join(pf, "LycheeSlicer", "LycheeSlicer.exe")
if _, err := os.Stat(p); err == nil {
return p
}
return ""
}