OLD | NEW |
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 367 } |
368 } | 368 } |
369 return nil | 369 return nil |
370 } | 370 } |
371 | 371 |
372 // Walk walks the file tree rooted at root, calling walkFn for each file or | 372 // Walk walks the file tree rooted at root, calling walkFn for each file or |
373 // directory in the tree, including root. All errors that arise visiting files | 373 // directory in the tree, including root. All errors that arise visiting files |
374 // and directories are filtered by walkFn. The files are walked in lexical | 374 // and directories are filtered by walkFn. The files are walked in lexical |
375 // order, which makes the output deterministic but means that for very | 375 // order, which makes the output deterministic but means that for very |
376 // large directories Walk can be inefficient. | 376 // large directories Walk can be inefficient. |
| 377 // Walk does not follow symbolic links. |
377 func Walk(root string, walkFn WalkFunc) error { | 378 func Walk(root string, walkFn WalkFunc) error { |
378 info, err := os.Lstat(root) | 379 info, err := os.Lstat(root) |
379 if err != nil { | 380 if err != nil { |
380 return walkFn(root, nil, err) | 381 return walkFn(root, nil, err) |
381 } | 382 } |
382 return walk(root, info, walkFn) | 383 return walk(root, info, walkFn) |
383 } | 384 } |
384 | 385 |
385 // readDir reads the directory named by dirname and returns | 386 // readDir reads the directory named by dirname and returns |
386 // a sorted list of directory entries. | 387 // a sorted list of directory entries. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 return vol + dir | 458 return vol + dir |
458 } | 459 } |
459 | 460 |
460 // VolumeName returns leading volume name. | 461 // VolumeName returns leading volume name. |
461 // Given "C:\foo\bar" it returns "C:" under windows. | 462 // Given "C:\foo\bar" it returns "C:" under windows. |
462 // Given "\\host\share\foo" it returns "\\host\share". | 463 // Given "\\host\share\foo" it returns "\\host\share". |
463 // On other platforms it returns "". | 464 // On other platforms it returns "". |
464 func VolumeName(path string) (v string) { | 465 func VolumeName(path string) (v string) { |
465 return path[:volumeNameLen(path)] | 466 return path[:volumeNameLen(path)] |
466 } | 467 } |
OLD | NEW |