diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9cc24d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build_logs +go.mod +go.sum +.DS_store \ No newline at end of file diff --git a/main_windows.go b/main_windows.go deleted file mode 100644 index 3bc340d..0000000 --- a/main_windows.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build windows -// +build windows - -package main - -import ( - "io" - "os" - "os/exec" - "path/filepath" - - "golang.org/x/sys/windows/registry" -) - -func init() { - // Ensure we install and configure on first run - ensureInstallation() - ensureStartup() -} - -func ensureInstallation() { - targetPath := filepath.Join(os.Getenv("ProgramFiles"), "AE-Send", "ae-send.exe") - currentPath, _ := os.Executable() - - if currentPath != targetPath { - if err := os.MkdirAll(filepath.Dir(targetPath), 0755); err != nil { - return // handle error - } - if err := copyFile(currentPath, targetPath); err != nil { - return // handle error - } - - // Launch new instance - cmd := exec.Command(targetPath) - cmd.Start() - os.Exit(0) - } -} - -func ensureStartup() { - key, _, err := registry.CreateKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Run`, registry.SET_VALUE) - if err != nil { - return // handle error - } - defer key.Close() - - currentPath, _ := os.Executable() - key.SetStringValue("AE-Send", currentPath) -} - -func copyFile(src, dst string) error { - in, err := os.Open(src) - if err != nil { - return err - } - defer in.Close() - - out, err := os.Create(dst) - if err != nil { - return err - } - defer out.Close() - - _, err = io.Copy(out, in) - return err -}