Skip to content

Commit 1b0c666

Browse files
committed
---
yaml --- r: 15598 b: refs/heads/try c: 8688b1b h: refs/heads/master v: v3
1 parent 5390e01 commit 1b0c666

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
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 7235f3cee2fd7ceaf697232cd2a2c3b9ceba50ba
5+
refs/heads/try: 8688b1b845f3ceede2a62da6a2fc2256e6bcfd2a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/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)