degal/filesystem.py
changeset 85 7da934333469
parent 79 e5400304a3d3
child 93 d3872a673fbe
--- a/degal/filesystem.py	Wed Jun 10 23:33:28 2009 +0300
+++ b/degal/filesystem.py	Thu Jun 11 00:36:19 2009 +0300
@@ -531,6 +531,33 @@
         # perform the copy
         shutil.copyfile(file.path, self.path)
 
+    def newer_than (self, file) :
+        """
+            Tests if this file is newer than the given file.
+            
+            Returns True if it is, False if it isn't, or None if either file doesn't exist.
+
+            XXX: stat cache?
+        """
+
+        stat_self = self.stat(soft=True)
+        stat_file = file.stat(soft=True)
+
+        if stat_self and stat_file :
+            return stat_self.st_mtime > stat_file.st_mtime
+
+        else :
+            return None
+    
+    def older_than (self, file) :
+        """
+            Tests if this file is older than the given file.
+
+            Opposite of newer_than.
+        """
+
+        return file.newer_than(self)
+
 class Directory (Node) :
     """
         A directory is a node that contains other nodes.