Convert leftover usages of path to filepath

This commit is contained in:
Jöran Karl 2025-04-26 20:33:38 +02:00
parent e5c3a3edc3
commit 1eef4bb3e0
2 changed files with 8 additions and 10 deletions

View File

@ -9,7 +9,6 @@ import (
"io" "io"
"io/fs" "io/fs"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
@ -479,7 +478,7 @@ func (b *Buffer) GetName() string {
name = b.Path name = b.Path
} }
if b.Settings["basename"].(bool) { if b.Settings["basename"].(bool) {
return path.Base(name) return filepath.Base(name)
} }
return name return name
} }

View File

@ -4,7 +4,6 @@ import (
"errors" "errors"
"log" "log"
"os" "os"
"path"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings" "strings"
@ -84,8 +83,8 @@ func (rf realFile) Data() ([]byte, error) {
} }
func (af assetFile) Name() string { func (af assetFile) Name() string {
fn := path.Base(string(af)) fn := filepath.Base(string(af))
return fn[:len(fn)-len(path.Ext(fn))] return fn[:len(fn)-len(filepath.Ext(fn))]
} }
func (af assetFile) Data() ([]byte, error) { func (af assetFile) Data() ([]byte, error) {
@ -125,8 +124,8 @@ func AddRuntimeFilesFromAssets(fileType RTFiletype, directory, pattern string) {
assetLoop: assetLoop:
for _, f := range files { for _, f := range files {
if ok, _ := path.Match(pattern, f); ok { if ok, _ := filepath.Match(pattern, f); ok {
af := assetFile(path.Join(directory, f)) af := assetFile(filepath.Join(directory, f))
for _, rf := range realFiles[fileType] { for _, rf := range realFiles[fileType] {
if af.Name() == rf.Name() { if af.Name() == rf.Name() {
continue assetLoop continue assetLoop
@ -167,7 +166,7 @@ func InitRuntimeFiles(user bool) {
if user { if user {
AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern) AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern)
} }
AddRuntimeFilesFromAssets(fileType, path.Join("runtime", dir), pattern) AddRuntimeFilesFromAssets(fileType, filepath.Join("runtime", dir), pattern)
} }
initRuntimeVars() initRuntimeVars()
@ -300,7 +299,7 @@ func PluginAddRuntimeFile(plugin string, filetype RTFiletype, filePath string) e
if _, err := os.Stat(fullpath); err == nil { if _, err := os.Stat(fullpath); err == nil {
AddRealRuntimeFile(filetype, realFile(fullpath)) AddRealRuntimeFile(filetype, realFile(fullpath))
} else { } else {
fullpath = path.Join("runtime", "plugins", pldir, filePath) fullpath = filepath.Join("runtime", "plugins", pldir, filePath)
AddRuntimeFile(filetype, assetFile(fullpath)) AddRuntimeFile(filetype, assetFile(fullpath))
} }
return nil return nil
@ -317,7 +316,7 @@ func PluginAddRuntimeFilesFromDirectory(plugin string, filetype RTFiletype, dire
if _, err := os.Stat(fullpath); err == nil { if _, err := os.Stat(fullpath); err == nil {
AddRuntimeFilesFromDirectory(filetype, fullpath, pattern) AddRuntimeFilesFromDirectory(filetype, fullpath, pattern)
} else { } else {
fullpath = path.Join("runtime", "plugins", pldir, directory) fullpath = filepath.Join("runtime", "plugins", pldir, directory)
AddRuntimeFilesFromAssets(filetype, fullpath, pattern) AddRuntimeFilesFromAssets(filetype, fullpath, pattern)
} }
return nil return nil