Commit 73d57642 authored by Rob Pike's avatar Rob Pike

filepath: remove string constants. They are unnecessary.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4527090
parent 581bd378
......@@ -119,7 +119,7 @@ func findPackageRoot(path string) (root *pkgroot, pkg string, err os.Error) {
return
}
for _, r := range gopath {
rpath := r.srcDir() + filepath.SeparatorString
rpath := r.srcDir() + string(filepath.Separator)
if !strings.HasPrefix(path, rpath) {
continue
}
......
......@@ -15,10 +15,8 @@ import (
)
const (
Separator = os.PathSeparator
ListSeparator = os.PathListSeparator
SeparatorString = string(Separator)
ListSeparatorString = string(ListSeparator)
Separator = os.PathSeparator
ListSeparator = os.PathListSeparator
)
// Clean returns the shortest path name equivalent to path
......@@ -121,7 +119,7 @@ func ToSlash(path string) string {
if Separator == '/' {
return path
}
return strings.Replace(path, SeparatorString, "/", -1)
return strings.Replace(path, string(Separator), "/", -1)
}
// FromSlash returns the result of replacing each slash ('/') character
......@@ -130,7 +128,7 @@ func FromSlash(path string) string {
if Separator == '/' {
return path
}
return strings.Replace(path, "/", SeparatorString, -1)
return strings.Replace(path, "/", string(Separator), -1)
}
// SplitList splits a list of paths joined by the OS-specific ListSeparator.
......@@ -138,7 +136,7 @@ func SplitList(path string) []string {
if path == "" {
return []string{}
}
return strings.Split(path, ListSeparatorString, -1)
return strings.Split(path, string(ListSeparator), -1)
}
// Split splits path immediately following the final Separator,
......@@ -158,7 +156,7 @@ func Split(path string) (dir, file string) {
func Join(elem ...string) string {
for i, e := range elem {
if e != "" {
return Clean(strings.Join(elem[i:], SeparatorString))
return Clean(strings.Join(elem[i:], string(Separator)))
}
}
return ""
......@@ -236,7 +234,7 @@ func EvalSymlinks(path string) (string, os.Error) {
if IsAbs(dest) {
b.Reset()
}
path = dest + SeparatorString + path
path = dest + string(Separator) + path
}
return Clean(b.String()), nil
}
......@@ -354,7 +352,7 @@ func Base(path string) string {
}
// If empty now, it had only slashes.
if path == "" {
return SeparatorString
return string(Separator)
}
return path
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment