mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-09 01:56:47 -05:00
Updates more instances of path->filepath
This commit is contained in:
parent
222b916002
commit
b18a70cef9
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"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
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package d2config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -16,7 +16,7 @@ const (
|
||||
// DefaultConfigPath returns the absolute path for the default config file location
|
||||
func DefaultConfigPath() string {
|
||||
if configDir, err := os.UserConfigDir(); err == nil {
|
||||
return path.Join(configDir, od2ConfigDirName, od2ConfigFileName)
|
||||
return filepath.Join(configDir, od2ConfigDirName, od2ConfigFileName)
|
||||
}
|
||||
|
||||
return LocalConfigPath()
|
||||
@ -24,5 +24,5 @@ func DefaultConfigPath() string {
|
||||
|
||||
// LocalConfigPath returns the absolute path to the directory of the OpenDiablo2 executable
|
||||
func LocalConfigPath() string {
|
||||
return path.Join(path.Dir(os.Args[0]), od2ConfigFileName)
|
||||
return filepath.Join(filepath.Dir(os.Args[0]), od2ConfigFileName)
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package d2config
|
||||
|
||||
import (
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
@ -60,7 +60,7 @@ func DefaultConfig() *Configuration {
|
||||
}
|
||||
case "linux":
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -82,7 +81,7 @@ func (f *HeroStateFactory) GetAllHeroStates() ([]*HeroState, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
gameState := f.LoadHeroState(path.Join(basePath, file.Name()))
|
||||
gameState := f.LoadHeroState(filepath.Join(basePath, file.Name()))
|
||||
if gameState == nil || gameState.HeroType == d2enum.HeroNone {
|
||||
|
||||
} else if gameState.Stats == nil || gameState.Skills == nil {
|
||||
@ -224,7 +223,7 @@ func (f *HeroStateFactory) getGameBaseSavePath() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return path.Join(configDir, "OpenDiablo2/Saves"), nil
|
||||
return filepath.Join(configDir, "OpenDiablo2/Saves"), nil
|
||||
}
|
||||
|
||||
func (f *HeroStateFactory) getFirstFreeFileName() string {
|
||||
@ -232,7 +231,7 @@ func (f *HeroStateFactory) getFirstFreeFileName() string {
|
||||
basePath, _ := f.getGameBaseSavePath()
|
||||
|
||||
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) {
|
||||
return filePath
|
||||
}
|
||||
@ -246,7 +245,7 @@ func (f *HeroStateFactory) Save(state *HeroState) error {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package d2gamescreen
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||
@ -72,7 +72,7 @@ type Credits struct {
|
||||
|
||||
// LoadContributors loads the contributors data from file
|
||||
func (v *Credits) LoadContributors() []string {
|
||||
file, err := os.Open(path.Join("./", "CONTRIBUTORS"))
|
||||
file, err := os.Open(filepath.Join("./", "CONTRIBUTORS"))
|
||||
if err != nil || file == nil {
|
||||
v.Warning("CONTRIBUTORS file is missing")
|
||||
return []string{"MISSING CONTRIBUTOR FILES!"}
|
||||
|
Loading…
Reference in New Issue
Block a user