]> git.lizzy.rs Git - rust.git/commitdiff
Add each_parent to WindowsPath
authorCorey Richardson <corey@octayn.net>
Fri, 28 Jun 2013 12:51:31 +0000 (08:51 -0400)
committerCorey Richardson <corey@octayn.net>
Fri, 28 Jun 2013 14:47:59 +0000 (10:47 -0400)
src/libstd/path.rs

index 9b4a3270f28a05df2a46c8fe49f08654839b3f61..a5e82c31d79008786354acd6dac5569b14224d19 100644 (file)
@@ -508,6 +508,14 @@ pub fn get_ctime(&self) -> Option<(i64, int)> {
             }
         }
     }
+
+    /// 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);
+        }
+    }
 }
 
 impl ToStr for PosixPath {