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

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

Issue 126440043: code review 126440043: path/filepath: make Abs handle paths like c:a.txt properly (Closed)
Left Patch Set: Created 10 years, 7 months ago
Right Patch Set: diff -r 8e4e7940943a2dfd0b60db75fac44865005b2271 https://go.googlecode.com/hg/ Created 10 years, 6 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 | « no previous file | src/pkg/path/filepath/path_plan9.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 filepath implements utility routines for manipulating filename paths 5 // Package filepath implements utility routines for manipulating filename paths
6 // in a way compatible with the target operating system-defined file paths. 6 // in a way compatible with the target operating system-defined file paths.
7 package filepath 7 package filepath
8 8
9 import ( 9 import (
10 "errors" 10 "errors"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // unless one of the components is an absolute symbolic link. 224 // unless one of the components is an absolute symbolic link.
225 func EvalSymlinks(path string) (string, error) { 225 func EvalSymlinks(path string) (string, error) {
226 return evalSymlinks(path) 226 return evalSymlinks(path)
227 } 227 }
228 228
229 // Abs returns an absolute representation of path. 229 // Abs returns an absolute representation of path.
230 // If the path is not absolute it will be joined with the current 230 // If the path is not absolute it will be joined with the current
231 // working directory to turn it into an absolute path. The absolute 231 // working directory to turn it into an absolute path. The absolute
232 // path name for a given file is not guaranteed to be unique. 232 // path name for a given file is not guaranteed to be unique.
233 func Abs(path string) (string, error) { 233 func Abs(path string) (string, error) {
234 return abs(path)
235 }
236
237 func unixAbs(path string) (string, error) {
234 if IsAbs(path) { 238 if IsAbs(path) {
235 return Clean(path), nil 239 return Clean(path), nil
236 } 240 }
237 wd, err := os.Getwd() 241 wd, err := os.Getwd()
238 if err != nil { 242 if err != nil {
239 return "", err 243 return "", err
240 } 244 }
241 return Join(wd, path), nil 245 return Join(wd, path), nil
242 } 246 }
243 247
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 return vol + dir 462 return vol + dir
459 } 463 }
460 464
461 // VolumeName returns leading volume name. 465 // VolumeName returns leading volume name.
462 // Given "C:\foo\bar" it returns "C:" under windows. 466 // Given "C:\foo\bar" it returns "C:" under windows.
463 // Given "\\host\share\foo" it returns "\\host\share". 467 // Given "\\host\share\foo" it returns "\\host\share".
464 // On other platforms it returns "". 468 // On other platforms it returns "".
465 func VolumeName(path string) (v string) { 469 func VolumeName(path string) (v string) {
466 return path[:volumeNameLen(path)] 470 return path[:volumeNameLen(path)]
467 } 471 }
LEFTRIGHT

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