intial release

This commit is contained in:
nezu 2024-10-20 23:04:38 +02:00
parent abbfcabe8d
commit dd7e923bff
11 changed files with 1234 additions and 0 deletions

17
platform/linux.go Normal file
View file

@ -0,0 +1,17 @@
//go:build linux
package platform
func IsWindowsRetryable(_ error) bool {
return false
}
func WindowsRename(from, to string) error {
panic("not implemented")
}
func FindProgram() string {
// who knows, could be a million things, including this executable itself
// let the user/packager decide where to find it
return ""
}

48
platform/windows.go Normal file
View file

@ -0,0 +1,48 @@
//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 ""
}