Skip to content

Commit

Permalink
fix: change joins to use filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
tmountain committed Feb 5, 2021
1 parent b9450d7 commit dfff6dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"path"
"path/filepath"
)

//go:embed themes/*
Expand Down Expand Up @@ -107,7 +108,7 @@ func MakeDefault() Config {

// If stockfish cannot be found, set the config to the AppDir
if stockfish == "" {
stockfish = path.Join(AppDir(), StockfishFilename())
stockfish = filepath.Join(AppDir(), StockfishFilename())
}

engine.Path = stockfish
Expand Down
16 changes: 8 additions & 8 deletions pkg/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"io"
"io/ioutil"
"net/http"
"path/filepath"

"os"
"path"
"regexp"
"runtime"
"strings"
Expand Down Expand Up @@ -108,7 +108,7 @@ func SearchDirForStockfish(dir string) string {
}

for _, f := range files {
fullPath := path.Join(dir, f.Name())
fullPath := filepath.Join(dir, f.Name())
if runtime.GOOS == "windows" && MatchStockfishWin(f.Name()) {
return f.Name()
}
Expand All @@ -128,7 +128,7 @@ func ensureUchessDir() string {
return ""
}

uchessDir := path.Join(home, uchessDirName())
uchessDir := filepath.Join(home, uchessDirName())
if !FileExists(uchessDir) {
err = os.Mkdir(uchessDir, os.ModeDir)
if err != nil {
Expand Down Expand Up @@ -184,7 +184,7 @@ func findTmpStockfish(dlDir string) (string, error) {
for _, file := range files {
fileName := file.Name()
if isStockfishBin(fileName) {
return path.Join(dlDir, fileName), nil
return filepath.Join(dlDir, fileName), nil
}
}
return "", nil
Expand Down Expand Up @@ -218,7 +218,7 @@ func downloadStockfish() bool {
defer os.RemoveAll(dlDir)

// dlPath is the full path that the initial zip was saved to
dlPath := path.Join(dlDir, "stockfish.zip")
dlPath := filepath.Join(dlDir, "stockfish.zip")
if err = DownloadFile(stockfish, dlPath); err != nil {
fmt.Println(err.Error())
return false
Expand All @@ -238,7 +238,7 @@ func downloadStockfish() bool {

// Move and rename the extracted binary
if uchessDir := ensureUchessDir(); uchessDir != "" {
finalPath := path.Join(uchessDir, StockfishFilename())
finalPath := filepath.Join(uchessDir, StockfishFilename())
if err = os.Rename(sfPath, finalPath); err != nil {
fmt.Println(err.Error())
return false
Expand All @@ -262,7 +262,7 @@ func AppDir() string {
fmt.Println(err.Error())
return ""
}
return path.Join(homeDir, uchessDirName())
return filepath.Join(homeDir, uchessDirName())
}

func pathDelim() string {
Expand All @@ -286,7 +286,7 @@ func FindStockfish() string {
for _, p := range paths {
searchResult := SearchDirForStockfish(p)
if searchResult != "" {
return path.Join(p, searchResult)
return filepath.Join(p, searchResult)
}
}
return ""
Expand Down

0 comments on commit dfff6dd

Please sign in to comment.