1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-07-01 11:25:26 +00:00

Updates more instances of path->filepath

This commit is contained in:
Will Roberts 2021-03-23 23:18:19 -04:00
parent 222b916002
commit b18a70cef9
5 changed files with 12 additions and 14 deletions

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
@ -201,5 +200,5 @@ func openIgnoreCase(mpqPath string) (*os.File, error) {
} }
} }
return os.Open(path.Join(mpqDir, mpqName)) //nolint:gosec // Will fix later return os.Open(filepath.Join(mpqDir, mpqName)) //nolint:gosec // Will fix later
} }

View File

@ -2,7 +2,7 @@ package d2config
import ( import (
"os" "os"
"path" "path/filepath"
) )
const ( const (
@ -16,7 +16,7 @@ const (
// DefaultConfigPath returns the absolute path for the default config file location // DefaultConfigPath returns the absolute path for the default config file location
func DefaultConfigPath() string { func DefaultConfigPath() string {
if configDir, err := os.UserConfigDir(); err == nil { if configDir, err := os.UserConfigDir(); err == nil {
return path.Join(configDir, od2ConfigDirName, od2ConfigFileName) return filepath.Join(configDir, od2ConfigDirName, od2ConfigFileName)
} }
return LocalConfigPath() return LocalConfigPath()
@ -24,5 +24,5 @@ func DefaultConfigPath() string {
// LocalConfigPath returns the absolute path to the directory of the OpenDiablo2 executable // LocalConfigPath returns the absolute path to the directory of the OpenDiablo2 executable
func LocalConfigPath() string { func LocalConfigPath() string {
return path.Join(path.Dir(os.Args[0]), od2ConfigFileName) return filepath.Join(filepath.Dir(os.Args[0]), od2ConfigFileName)
} }

View File

@ -2,7 +2,7 @@ package d2config
import ( import (
"os/user" "os/user"
"path" "path/filepath"
"runtime" "runtime"
) )
@ -60,7 +60,7 @@ func DefaultConfig() *Configuration {
} }
case "linux": case "linux":
if usr, err := user.Current(); err == nil { if usr, err := user.Current(); err == nil {
config.MpqPath = path.Join(usr.HomeDir, ".wine/drive_c/Program Files (x86)/Diablo II") config.MpqPath = filepath.Join(usr.HomeDir, ".wine/drive_c/Program Files (x86)/Diablo II")
} }
} }

View File

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
@ -82,7 +81,7 @@ func (f *HeroStateFactory) GetAllHeroStates() ([]*HeroState, error) {
continue continue
} }
gameState := f.LoadHeroState(path.Join(basePath, file.Name())) gameState := f.LoadHeroState(filepath.Join(basePath, file.Name()))
if gameState == nil || gameState.HeroType == d2enum.HeroNone { if gameState == nil || gameState.HeroType == d2enum.HeroNone {
} else if gameState.Stats == nil || gameState.Skills == nil { } else if gameState.Stats == nil || gameState.Skills == nil {
@ -224,7 +223,7 @@ func (f *HeroStateFactory) getGameBaseSavePath() (string, error) {
return "", err return "", err
} }
return path.Join(configDir, "OpenDiablo2/Saves"), nil return filepath.Join(configDir, "OpenDiablo2/Saves"), nil
} }
func (f *HeroStateFactory) getFirstFreeFileName() string { func (f *HeroStateFactory) getFirstFreeFileName() string {
@ -232,7 +231,7 @@ func (f *HeroStateFactory) getFirstFreeFileName() string {
basePath, _ := f.getGameBaseSavePath() basePath, _ := f.getGameBaseSavePath()
for { for {
filePath := path.Join(basePath, strconv.Itoa(i)+".od2") filePath := filepath.Join(basePath, strconv.Itoa(i)+".od2")
if _, err := os.Stat(filePath); os.IsNotExist(err) { if _, err := os.Stat(filePath); os.IsNotExist(err) {
return filePath return filePath
} }
@ -246,7 +245,7 @@ func (f *HeroStateFactory) Save(state *HeroState) error {
state.FilePath = f.getFirstFreeFileName() state.FilePath = f.getFirstFreeFileName()
} }
if err := os.MkdirAll(path.Dir(state.FilePath), mkdirPermission); err != nil { if err := os.MkdirAll(filepath.Dir(state.FilePath), mkdirPermission); err != nil {
return err return err
} }

View File

@ -3,7 +3,7 @@ package d2gamescreen
import ( import (
"bufio" "bufio"
"os" "os"
"path" "path/filepath"
"strings" "strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
@ -72,7 +72,7 @@ type Credits struct {
// LoadContributors loads the contributors data from file // LoadContributors loads the contributors data from file
func (v *Credits) LoadContributors() []string { func (v *Credits) LoadContributors() []string {
file, err := os.Open(path.Join("./", "CONTRIBUTORS")) file, err := os.Open(filepath.Join("./", "CONTRIBUTORS"))
if err != nil || file == nil { if err != nil || file == nil {
v.Warning("CONTRIBUTORS file is missing") v.Warning("CONTRIBUTORS file is missing")
return []string{"MISSING CONTRIBUTOR FILES!"} return []string{"MISSING CONTRIBUTOR FILES!"}