switched from path to filepath for files

This commit is contained in:
knoxfighter 2019-03-22 00:49:43 +01:00
parent 27a5f62560
commit dbcaba7231
4 changed files with 7 additions and 8 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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 {