path.Join -> path/filepath.Join
This commit is contained in:
parent
56b2faf88a
commit
31c46a3e5d
|
@ -6,6 +6,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -50,12 +51,12 @@ func getGamesFromProvider(provider string) []games.Game {
|
||||||
|
|
||||||
func processGames(games []games.Game, outputPath string, dryRun bool) {
|
func processGames(games []games.Game, outputPath string, dryRun bool) {
|
||||||
for _, game := range games {
|
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 {
|
if len(game.Name) > 0 {
|
||||||
destinationPath = path.Join(destinationPath, game.Name)
|
destinationPath = filepath.Join(destinationPath, game.Name)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("[IMPORTANT] Game ID %d has no name!", game.ID)
|
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
|
// 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)
|
log.Printf("=> Proceesing screenshots for %s %s", game.Name, game.Notes)
|
||||||
for _, screenshot := range game.Screenshots {
|
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) {
|
if _, err := os.Stat(destinationPath); !os.IsNotExist(err) {
|
||||||
sourceMd5, err := helpers.Md5File(screenshot.Path)
|
sourceMd5, err := helpers.Md5File(screenshot.Path)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ func GetGames() []games.Game {
|
||||||
getScreenshotsFromPath(&minecraftFlatpak, "~/.var/app/com.mojang.Minecraft/.minecraft/screenshots")
|
getScreenshotsFromPath(&minecraftFlatpak, "~/.var/app/com.mojang.Minecraft/.minecraft/screenshots")
|
||||||
result = append(result, minecraftFlatpak)
|
result = append(result, minecraftFlatpak)
|
||||||
} else if runtime.GOOS == "windows" {
|
} 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" {
|
} 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)
|
result = append(result, minecraftStandalone)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue