diff options
Diffstat (limited to 'src/libcore/os.rs')
| -rw-r--r-- | src/libcore/os.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 26d4790705a..299b9429ac3 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -550,6 +550,7 @@ pub fn tmpdir() -> Path { } } /// Recursively walk a directory structure +#[cfg(stage0)] pub fn walk_dir(p: &Path, f: &fn(&Path) -> bool) { walk_dir_(p, f); @@ -577,6 +578,14 @@ pub fn walk_dir(p: &Path, f: &fn(&Path) -> bool) { return keepgoing; } } +/// Recursively walk a directory structure +#[cfg(not(stage0))] +pub fn walk_dir(p: &Path, f: &fn(&Path) -> bool) -> bool { + list_dir(p).each(|q| { + let path = &p.push(*q); + f(path) && (!path_is_dir(path) || walk_dir(path, f)) + }) +} /// Indicates whether a path represents a directory pub fn path_is_dir(p: &Path) -> bool { |
