LEFT | RIGHT |
(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 Loading... |
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 Loading... |
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 } |
LEFT | RIGHT |