From dbcaba7231c9113c97614e9fcd0a8ffa4441fdd5 Mon Sep 17 00:00:00 2001 From: knoxfighter Date: Fri, 22 Mar 2019 00:49:43 +0100 Subject: [PATCH] switched from path to filepath for files --- src/handlers.go | 2 +- src/mod_modInfo.go | 5 ++--- src/mods.go | 2 +- src/vendor/lockfile/lockfile.go | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/handlers.go b/src/handlers.go index d6e1739..47fabcc 100644 --- a/src/handlers.go +++ b/src/handlers.go @@ -63,7 +63,7 @@ func DLSave(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) save := vars["save"] - saveName := path.Join(config.FactorioSavesDir, save) + saveName := filepath.Join(config.FactorioSavesDir, save) w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", save)) log.Printf("%s downloading: %s", r.Host, saveName) diff --git a/src/mod_modInfo.go b/src/mod_modInfo.go index 4cb1d26..f24b32e 100644 --- a/src/mod_modInfo.go +++ b/src/mod_modInfo.go @@ -9,7 +9,6 @@ import ( "lockfile" "log" "os" - "path" "path/filepath" "strings" ) @@ -134,7 +133,7 @@ func (modInfoList *ModInfoList) deleteMod(modName string) error { //search for mod, that should be deleted for _, mod := range modInfoList.Mods { if mod.Name == modName { - filePath := path.Join(modInfoList.Destination, mod.FileName) + filePath := filepath.Join(modInfoList.Destination, mod.FileName) fileLock.LockW(filePath) //delete mod @@ -195,7 +194,7 @@ func (modInfoList *ModInfoList) createMod(modName string, fileName string, modFi var err error //save uploaded file - filePath := path.Join(modInfoList.Destination, fileName) + filePath := filepath.Join(modInfoList.Destination, fileName) newFile, err := os.Create(filePath) if err != nil { log.Printf("error on creating new file - %s: %s", fileName, err) diff --git a/src/mods.go b/src/mods.go index 3905e1a..d9f8445 100644 --- a/src/mods.go +++ b/src/mods.go @@ -276,7 +276,7 @@ func modStartUp() { } newJson, _ := json.Marshal(modSimpleList) - err = ioutil.WriteFile(modSimpleList.Destination+"/mod-list.json", newJson, 0664) + err = ioutil.WriteFile(filepath.Join(modSimpleList.Destination,"mod-list.json"), newJson, 0664) if err != nil { log.Printf("error when writing new mod-list: %s", err) return err diff --git a/src/vendor/lockfile/lockfile.go b/src/vendor/lockfile/lockfile.go index 01d0213..6e7b653 100644 --- a/src/vendor/lockfile/lockfile.go +++ b/src/vendor/lockfile/lockfile.go @@ -4,7 +4,7 @@ import ( "errors" "log" "os" - "path" + "path/filepath" "sync" "time" ) @@ -30,7 +30,7 @@ func NewLock() FileLock { } func makeAbsolutePath(target string) string { - if path.IsAbs(target) { + if filepath.IsAbs(target) { return target } @@ -40,7 +40,7 @@ func makeAbsolutePath(target string) string { return "" } - return path.Join(wd, target) + return filepath.Join(wd, target) } func (fl *FileLock) Lock(filePath string) error {