summaryrefslogtreecommitdiff
path: root/src/pkg/path/filepath/path.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-08-03 17:26:15 +0200
committerOndřej Surý <ondrej@sury.org>2011-08-03 17:31:49 +0200
commitb757d264230d65f988e08158e096a09497d39eb4 (patch)
treee20ec608a2ec8ebf603fa7aa060eb9723c4780b9 /src/pkg/path/filepath/path.go
parent5976088995f5c0d0bcada7d491fda4b6245e54e0 (diff)
downloadgolang-b757d264230d65f988e08158e096a09497d39eb4.tar.gz
Imported Upstream version 2011.07.29
Diffstat (limited to 'src/pkg/path/filepath/path.go')
-rw-r--r--src/pkg/path/filepath/path.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/pkg/path/filepath/path.go b/src/pkg/path/filepath/path.go
index b181483ed..3d5b915c1 100644
--- a/src/pkg/path/filepath/path.go
+++ b/src/pkg/path/filepath/path.go
@@ -38,19 +38,19 @@ const (
// Getting Dot-Dot right,''
// http://plan9.bell-labs.com/sys/doc/lexnames.html
func Clean(path string) string {
+ vol := VolumeName(path)
+ path = path[len(vol):]
if path == "" {
- return "."
+ return vol + "."
}
- rooted := IsAbs(path)
+ rooted := os.IsPathSeparator(path[0])
// Invariants:
// reading from path; r is index of next byte to process.
// writing to buf; w is index of next byte to write.
// dotdot is index in buf where .. must stop, either because
// it is the leading slash or it is a leading ../../.. prefix.
- prefix := volumeName(path)
- path = path[len(prefix):]
n := len(path)
buf := []byte(path)
r, w, dotdot := 0, 0, 0
@@ -110,7 +110,7 @@ func Clean(path string) string {
w++
}
- return prefix + string(buf[0:w])
+ return FromSlash(vol + string(buf[0:w]))
}
// ToSlash returns the result of replacing each separator character
@@ -140,8 +140,8 @@ func SplitList(path string) []string {
}
// Split splits path immediately following the final Separator,
-// partitioning it into a directory and a file name components.
-// If there are no separators in path, Split returns an empty base
+// separating it into a directory and file name component.
+// If there is no Separator in path, Split returns an empty dir
// and file set to path.
func Split(path string) (dir, file string) {
i := len(path) - 1