summaryrefslogtreecommitdiff
path: root/src/lib/path.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-04-07 21:53:39 -0700
committerRuss Cox <rsc@golang.org>2009-04-07 21:53:39 -0700
commit7b8f226f32c3969d832005df9f211406727c71f6 (patch)
tree924f2a83b20e63c16d82f3408bd4c220dd9a1c57 /src/lib/path.go
parent4d7afea2e9f9b7dfdf0296dba8973bcb7dd608a0 (diff)
downloadgolang-7b8f226f32c3969d832005df9f211406727c71f6.tar.gz
fumbly fingers + non-working ^C
submitted CL without applying edits. make changes from CL 27142 review R=r DELTA=26 (17 added, 3 deleted, 6 changed) OCL=27155 CL=27199
Diffstat (limited to 'src/lib/path.go')
-rw-r--r--src/lib/path.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/lib/path.go b/src/lib/path.go
index fdfcd4bfd..a7e2c26c3 100644
--- a/src/lib/path.go
+++ b/src/lib/path.go
@@ -12,9 +12,9 @@ import "io"
// by purely lexical processing. It applies the following rules
// iteratively until no further processing can be done:
//
-// 1. Replace multiple slashes by a single slash.
+// 1. Replace multiple slashes with a single slash.
// 2. Eliminate each . path name element (the current directory).
-// 3. Eliminate each .. path name element (the parent directory)
+// 3. Eliminate each inner .. path name element (the parent directory)
// along with the non-.. element that precedes it.
// 4. Eliminate .. elements that begin a rooted path:
// that is, replace "/.." by "/" at the beginning of a path.
@@ -114,13 +114,10 @@ func Split(path string) (dir, file string) {
// Join joins dir and file into a single path, adding a separating
// slash if necessary. If dir is empty, it returns file.
func Join(dir, file string) string {
- switch {
- case dir == "":
+ if dir == "" {
return file;
- case dir[len(dir)-1] == '/':
- return dir + file;
}
- return dir + "/" + file;
+ return Clean(dir + "/" + file);
}
// Ext returns the file name extension used by path.