about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2013-06-25 19:49:01 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2013-06-27 21:41:03 -0700
commitea62fd1090fda26e1e4b68bdc7ef2e11864d80b6 (patch)
treef96628b6e5f499e6c55a27da069634cb8fbd8cea /src/libstd
parent9b6dfb85782a6ec50c39292626acf2c74b0ae754 (diff)
downloadrust-ea62fd1090fda26e1e4b68bdc7ef2e11864d80b6.tar.gz
rust-ea62fd1090fda26e1e4b68bdc7ef2e11864d80b6.zip
rustpkg: Implement RUST_PATH
Unfortunately, the main test for this is ignored due to #7071.

Closes #5682
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/path.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 700bfff3f5d..89792694011 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -382,6 +382,15 @@ impl Path {
             Some(ref st) => Some(st.st_mode as uint),
         }
     }
+
+    /// Execute a function on p as well as all of its ancestors
+    pub fn each_parent(&self, f: &fn(&Path)) {
+        if !self.components.is_empty() {
+            f(self);
+            self.pop().each_parent(f);
+        }
+    }
+
 }
 
 #[cfg(target_os = "freebsd")]