Skip to content
Snippets Groups Projects
Commit ad22356e authored by Damien Neil's avatar Damien Neil
Browse files

all: rename internal/safefilepath to internal/filepathlite

The safefilepath package was originally added to contain
the FromFS function. We subsequently added FromFS to path/filepath
as Localize. The safefilepath package now exists only to permit
the os package to import Localize.

Rename safefilepath to filepathlite to better indicate that it's
a low-dependency version of filepath.

Change-Id: I4c5f9b28e8581f841947b48c5cac9954cd0c9535
Reviewed-on: https://go-review.googlesource.com/c/go/+/581517


LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: default avatarIan Lance Taylor <iant@google.com>
parent d69f8744
No related branches found
No related tags found
No related merge requests found
...@@ -174,7 +174,7 @@ var depsRules = ` ...@@ -174,7 +174,7 @@ var depsRules = `
io/fs io/fs
< internal/testlog < internal/testlog
< internal/poll < internal/poll
< internal/safefilepath < internal/filepathlite
< os < os
< os/signal; < os/signal;
...@@ -183,7 +183,7 @@ var depsRules = ` ...@@ -183,7 +183,7 @@ var depsRules = `
unicode, fmt !< net, os, os/signal; unicode, fmt !< net, os, os/signal;
os/signal, internal/safefilepath, STR os/signal, internal/filepathlite, STR
< path/filepath < path/filepath
< io/ioutil; < io/ioutil;
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Package safefilepath manipulates operating-system file paths. // Package filepathlite manipulates operating-system file paths.
package safefilepath package filepathlite
import ( import (
"errors" "errors"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package safefilepath package filepathlite
import "internal/bytealg" import "internal/bytealg"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
//go:build unix || (js && wasm) || wasip1 //go:build unix || (js && wasm) || wasip1
package safefilepath package filepathlite
import "internal/bytealg" import "internal/bytealg"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package safefilepath package filepathlite
import ( import (
"internal/bytealg" "internal/bytealg"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
package os package os
import ( import (
"internal/safefilepath" "internal/filepathlite"
"io" "io"
"io/fs" "io/fs"
"sort" "sort"
...@@ -146,7 +146,7 @@ func CopyFS(dir string, fsys fs.FS) error { ...@@ -146,7 +146,7 @@ func CopyFS(dir string, fsys fs.FS) error {
return err return err
} }
fpath, err := safefilepath.Localize(path) fpath, err := filepathlite.Localize(path)
if err != nil { if err != nil {
return err return err
} }
...@@ -157,7 +157,7 @@ func CopyFS(dir string, fsys fs.FS) error { ...@@ -157,7 +157,7 @@ func CopyFS(dir string, fsys fs.FS) error {
// TODO(panjf2000): handle symlinks with the help of fs.ReadLinkFS // TODO(panjf2000): handle symlinks with the help of fs.ReadLinkFS
// once https://go.dev/issue/49580 is done. // once https://go.dev/issue/49580 is done.
// we also need safefilepath.IsLocal from https://go.dev/cl/564295. // we also need filepathlite.IsLocal from https://go.dev/cl/564295.
if !d.Type().IsRegular() { if !d.Type().IsRegular() {
return &PathError{Op: "CopyFS", Path: path, Err: ErrInvalid} return &PathError{Op: "CopyFS", Path: path, Err: ErrInvalid}
} }
......
...@@ -45,8 +45,8 @@ package os ...@@ -45,8 +45,8 @@ package os
import ( import (
"errors" "errors"
"internal/filepathlite"
"internal/poll" "internal/poll"
"internal/safefilepath"
"internal/testlog" "internal/testlog"
"io" "io"
"io/fs" "io/fs"
...@@ -766,7 +766,7 @@ func (dir dirFS) join(name string) (string, error) { ...@@ -766,7 +766,7 @@ func (dir dirFS) join(name string) (string, error) {
if dir == "" { if dir == "" {
return "", errors.New("os: DirFS with empty root") return "", errors.New("os: DirFS with empty root")
} }
name, err := safefilepath.Localize(name) name, err := filepathlite.Localize(name)
if err != nil { if err != nil {
return "", ErrInvalid return "", ErrInvalid
} }
......
...@@ -13,7 +13,7 @@ package filepath ...@@ -13,7 +13,7 @@ package filepath
import ( import (
"errors" "errors"
"internal/safefilepath" "internal/filepathlite"
"io/fs" "io/fs"
"os" "os"
"slices" "slices"
...@@ -221,7 +221,7 @@ func unixIsLocal(path string) bool { ...@@ -221,7 +221,7 @@ func unixIsLocal(path string) bool {
// //
// The path returned by Localize will always be local, as reported by IsLocal. // The path returned by Localize will always be local, as reported by IsLocal.
func Localize(path string) (string, error) { func Localize(path string) (string, error) {
return safefilepath.Localize(path) return filepathlite.Localize(path)
} }
// ToSlash returns the result of replacing each separator character // ToSlash returns the result of replacing each separator character
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
package filepath package filepath
import ( import (
"internal/safefilepath" "internal/filepathlite"
"os" "os"
"strings" "strings"
"syscall" "syscall"
...@@ -42,7 +42,7 @@ func isLocal(path string) bool { ...@@ -42,7 +42,7 @@ func isLocal(path string) bool {
if part == "." || part == ".." { if part == "." || part == ".." {
hasDots = true hasDots = true
} }
if safefilepath.IsReservedName(part) { if filepathlite.IsReservedName(part) {
return false return false
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment