Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(384)

Delta Between Two Patch Sets: src/pkg/path/path.go

Issue 160200044: [dev.power64] code review 160200044: build: merge default into dev.power64 (Closed)
Left Patch Set: Created 10 years, 4 months ago
Right Patch Set: diff -r be0c14f62257b42485019e9e1db23cf40d2e249f https://code.google.com/p/go Created 10 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/path/filepath/path_windows.go ('k') | src/pkg/reflect/all_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package path implements utility routines for manipulating slash-separated 5 // Package path implements utility routines for manipulating slash-separated
6 // paths. 6 // paths.
7 package path 7 package path
8 8
9 import ( 9 import (
10 "strings" 10 "strings"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 // Dir returns all but the last element of path, typically the path's directory. 200 // Dir returns all but the last element of path, typically the path's directory.
201 // After dropping the final element using Split, the path is Cleaned and trailin g 201 // After dropping the final element using Split, the path is Cleaned and trailin g
202 // slashes are removed. 202 // slashes are removed.
203 // If the path is empty, Dir returns ".". 203 // If the path is empty, Dir returns ".".
204 // If the path consists entirely of slashes followed by non-slash bytes, Dir 204 // If the path consists entirely of slashes followed by non-slash bytes, Dir
205 // returns a single slash. In any other case, the returned path does not end in a 205 // returns a single slash. In any other case, the returned path does not end in a
206 // slash. 206 // slash.
207 func Dir(path string) string { 207 func Dir(path string) string {
208 dir, _ := Split(path) 208 dir, _ := Split(path)
209 » dir = Clean(dir) 209 » return Clean(dir)
210 » last := len(dir) - 1 210 }
211 » if last > 0 && dir[last] == '/' {
212 » » dir = dir[:last]
213 » }
214 » if dir == "" {
215 » » dir = "."
216 » }
217 » return dir
218 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b