From 320fd6a3beea23abe9cb6d79f1b7d2b180b8003d Mon Sep 17 00:00:00 2001 From: txfly Date: Wed, 7 Aug 2019 17:42:09 +0800 Subject: [PATCH] Fix "Failed to create syso file: exit status 1" error when "windres.exe" is in the "Program Files (x86)" or "Program Files" path. --- internal/cmd/profile-setup.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/cmd/profile-setup.go b/internal/cmd/profile-setup.go index c2f4e8d..3990213 100644 --- a/internal/cmd/profile-setup.go +++ b/internal/cmd/profile-setup.go @@ -183,10 +183,12 @@ func profileSetupHandler(cmd *cobra.Command, args []string) { defaultGcc := "gcc" defaultGxx := "g++" defaultObjdump := "objdump" + defaultRes := "windres" if runtime.GOOS == "windows" { defaultGcc += ".exe" defaultGxx += ".exe" defaultObjdump += ".exe" + defaultRes += ".exe" } fmt.Println() @@ -232,10 +234,20 @@ func profileSetupHandler(cmd *cobra.Command, args []string) { cCyanBold.Print("Path to windres : ") windresPath, _ = reader.ReadString('\n') windresPath = strings.TrimSpace(windresPath) - if !fileExists(windresPath) { - cRedBold.Println("The specified path does not exist") - os.Exit(1) + if windresPath == "" { + windresPath = defaultRes + } else { + if !strings.HasSuffix(windresPath, defaultRes) { + windresPath = fp.Join(windresPath, defaultRes) + } + windresPath = strings.ReplaceAll(windresPath, "Program Files", "Progra~1") + windresPath = strings.ReplaceAll(windresPath, "Program Files (x86)", "Progra~2") + if !fileExists(windresPath) { + cRedBold.Println("The specified path does not exist") + os.Exit(1) + } } + } // Save config file