path.Join -> path/filepath.Join

This commit is contained in:
Felipe Martin 2020-11-14 11:40:26 +01:00
parent 56b2faf88a
commit 31c46a3e5d
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
2 changed files with 8 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import (
"log"
"os"
"path"
"path/filepath"
"strconv"
"strings"
@ -50,12 +51,12 @@ func getGamesFromProvider(provider string) []games.Game {
func processGames(games []games.Game, outputPath string, dryRun bool) {
for _, game := range games {
destinationPath := path.Join(helpers.ExpandUser(outputPath), game.Platform)
destinationPath := filepath.Join(helpers.ExpandUser(outputPath), game.Platform)
if len(game.Name) > 0 {
destinationPath = path.Join(destinationPath, game.Name)
destinationPath = filepath.Join(destinationPath, game.Name)
} else {
log.Printf("[IMPORTANT] Game ID %d has no name!", game.ID)
destinationPath = path.Join(destinationPath, strconv.FormatUint(game.ID, 10))
destinationPath = filepath.Join(destinationPath, strconv.FormatUint(game.ID, 10))
}
// Check if folder exists
@ -65,7 +66,7 @@ func processGames(games []games.Game, outputPath string, dryRun bool) {
log.Printf("=> Proceesing screenshots for %s %s", game.Name, game.Notes)
for _, screenshot := range game.Screenshots {
destinationPath := path.Join(destinationPath, screenshot.GetDestinationName())
destinationPath := filepath.Join(destinationPath, screenshot.GetDestinationName())
if _, err := os.Stat(destinationPath); !os.IsNotExist(err) {
sourceMd5, err := helpers.Md5File(screenshot.Path)

View File

@ -4,7 +4,7 @@ import (
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
"runtime"
"strings"
@ -41,9 +41,9 @@ func GetGames() []games.Game {
getScreenshotsFromPath(&minecraftFlatpak, "~/.var/app/com.mojang.Minecraft/.minecraft/screenshots")
result = append(result, minecraftFlatpak)
} else if runtime.GOOS == "windows" {
getScreenshotsFromPath(&minecraftStandalone, path.Join(os.Getenv("APPDATA"), ".minecraft/screenshots"))
getScreenshotsFromPath(&minecraftStandalone, filepath.Join(os.Getenv("APPDATA"), ".minecraft/screenshots"))
} else if runtime.GOOS == "darwin" {
getScreenshotsFromPath(&minecraftStandalone, path.Join(helpers.ExpandUser("~/Library/Application Support/minecraft/screenshots")))
getScreenshotsFromPath(&minecraftStandalone, filepath.Join(helpers.ExpandUser("~/Library/Application Support/minecraft/screenshots")))
}
result = append(result, minecraftStandalone)