Merge pull request #3727 from JoeKar/fix/path2filepath
Some checks are pending
Build and Test / test (1.19.x, macos-latest) (push) Waiting to run
Build and Test / test (1.19.x, ubuntu-latest) (push) Waiting to run
Build and Test / test (1.19.x, windows-latest) (push) Waiting to run
Build and Test / test (1.23.x, macos-latest) (push) Waiting to run
Build and Test / test (1.23.x, ubuntu-latest) (push) Waiting to run
Build and Test / test (1.23.x, windows-latest) (push) Waiting to run

Convert leftover usages of `path` to `filepath`
This commit is contained in:
Jöran Karl 2025-04-27 13:16:00 +02:00 committed by GitHub
commit 333770bbd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 11 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

View File

@ -427,7 +427,6 @@ func importPath() *lua.LTable {
func importFilePath() *lua.LTable { func importFilePath() *lua.LTable {
pkg := L.NewTable() pkg := L.NewTable()
L.SetField(pkg, "Join", luar.New(L, filepath.Join))
L.SetField(pkg, "Abs", luar.New(L, filepath.Abs)) L.SetField(pkg, "Abs", luar.New(L, filepath.Abs))
L.SetField(pkg, "Base", luar.New(L, filepath.Base)) L.SetField(pkg, "Base", luar.New(L, filepath.Base))
L.SetField(pkg, "Clean", luar.New(L, filepath.Clean)) L.SetField(pkg, "Clean", luar.New(L, filepath.Clean))