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

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

Issue 6257059: code review 6257059: path/filepath: implement documented SkipDir behavior
Left Patch Set: diff -r 40632db23c46 https://code.google.com/p/go Created 12 years, 9 months ago
Right Patch Set: diff -r d34e1877830c https://code.google.com/p/go Created 12 years, 9 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/path/filepath/path_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
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
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
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 }
LEFTRIGHT

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