LEFT | RIGHT |
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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if !info.IsDir() { | 313 if !info.IsDir() { |
314 return nil | 314 return nil |
315 } | 315 } |
316 | 316 |
317 list, err := readDir(path) | 317 list, err := readDir(path) |
318 if err != nil { | 318 if err != nil { |
319 return walkFn(path, info, err) | 319 return walkFn(path, info, err) |
320 } | 320 } |
321 | 321 |
322 for _, fileInfo := range list { | 322 for _, fileInfo := range list { |
323 » » if err = walk(Join(path, fileInfo.Name()), fileInfo, walkFn); er
r != nil && err != SkipDir { | 323 » » err = walk(Join(path, fileInfo.Name()), fileInfo, walkFn) |
324 » » » return err | 324 » » if err != nil { |
| 325 » » » if !fileInfo.IsDir() || err != SkipDir { |
| 326 » » » » return err |
| 327 » » » } |
325 } | 328 } |
326 } | 329 } |
327 return nil | 330 return nil |
328 } | 331 } |
329 | 332 |
330 // Walk walks the file tree rooted at root, calling walkFn for each file or | 333 // Walk walks the file tree rooted at root, calling walkFn for each file or |
331 // directory in the tree, including root. All errors that arise visiting files | 334 // directory in the tree, including root. All errors that arise visiting files |
332 // and directories are filtered by walkFn. The files are walked in lexical | 335 // and directories are filtered by walkFn. The files are walked in lexical |
333 // order, which makes the output deterministic but means that for very | 336 // order, which makes the output deterministic but means that for very |
334 // large directories Walk can be inefficient. | 337 // large directories Walk can be inefficient. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 dir := Clean(path[len(vol) : i+1]) | 410 dir := Clean(path[len(vol) : i+1]) |
408 last := len(dir) - 1 | 411 last := len(dir) - 1 |
409 if last > 0 && os.IsPathSeparator(dir[last]) { | 412 if last > 0 && os.IsPathSeparator(dir[last]) { |
410 dir = dir[:last] | 413 dir = dir[:last] |
411 } | 414 } |
412 if dir == "" { | 415 if dir == "" { |
413 dir = "." | 416 dir = "." |
414 } | 417 } |
415 return vol + dir | 418 return vol + dir |
416 } | 419 } |
LEFT | RIGHT |