Skip to content

Commit 397ea9f

Browse files
committed
---
yaml --- r: 12592 b: refs/heads/master c: 8688b1b h: refs/heads/master v: v3
1 parent c05c061 commit 397ea9f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7235f3cee2fd7ceaf697232cd2a2c3b9ceba50ba
2+
refs/heads/master: 8688b1b845f3ceede2a62da6a2fc2256e6bcfd2a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/os.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export homedir, list_dir, list_dir_path, path_is_dir, path_exists,
3434
copy_file;
3535
export last_os_error;
3636
export set_exit_status;
37+
export walk_dir;
3738

3839
// FIXME: move these to str perhaps?
3940
export as_c_charp, fill_charp_buf;
@@ -387,7 +388,34 @@ fn homedir() -> option<path> {
387388
}
388389
}
389390

391+
#[doc = "Recursively walk a directory structure"]
392+
fn walk_dir(p: path, f: fn(path) -> bool) {
390393

394+
walk_dir_(p, f);
395+
396+
fn walk_dir_(p: path, f: fn(path) -> bool) -> bool {
397+
let mut keepgoing = true;
398+
list_dir(p).each {|q|
399+
let path = path::connect(p, q);
400+
if !f(path) {
401+
keepgoing = false;
402+
false
403+
} else {
404+
if path_is_dir(path) {
405+
if !walk_dir_(path, f) {
406+
keepgoing = false;
407+
false
408+
} else {
409+
true
410+
}
411+
} else {
412+
true
413+
}
414+
}
415+
}
416+
ret keepgoing;
417+
}
418+
}
391419

392420
#[doc = "Indicates whether a path represents a directory"]
393421
fn path_is_dir(p: path) -> bool {

0 commit comments

Comments
 (0)