[LON-CAPA-cvs] cvs: loncom /build help_graphics_converter.pl

foxr foxr at source.lon-capa.org
Mon Jan 2 06:37:02 EST 2012


foxr		Mon Jan  2 11:37:02 2012 EDT

  Modified files:              
    /loncom/build	help_graphics_converter.pl 
  Log:
  BZ 6534 - Make the converter aware of relative mtimes as well as
  just the non-empty existence of the destination file.
  
  
Index: loncom/build/help_graphics_converter.pl
diff -u loncom/build/help_graphics_converter.pl:1.4 loncom/build/help_graphics_converter.pl:1.5
--- loncom/build/help_graphics_converter.pl:1.4	Mon Aug 19 21:40:55 2002
+++ loncom/build/help_graphics_converter.pl	Mon Jan  2 11:37:02 2012
@@ -28,6 +28,30 @@
 
 use strict;
 
+##
+#  Sub to determine the relative modification dates of files:
+#
+# @param file1 - First file
+# @param file2 - Seond file
+#
+# @return - 0 if file 1's mtime is <= file2's 1 otherwise.
+sub newer {
+    my ($file1, $file2) = @_;
+
+    # IF file2 does not exist, return false to force the build:
+
+    if (not (-s $file2)) {
+	return 0;
+    }
+
+    # Check modification times if file2 exists:
+
+    my $m1 = (stat($file1))[9];
+    my $m2 = (stat($file2))[9];
+
+    return $m2 > $m1;
+}
+
 my $dirprefix = "../html/adm/help/";
 
 # Check that the png directory exists
@@ -55,8 +79,8 @@
     
     
     print "Converting $filename... gif";
-    system ("convert $file $gifdest\n") if (not (-s $gifdest));
+    system ("convert $file $gifdest\n") if (not &newer($file, $gifdest));
     print " eps";
-    system ("convert $file $epsdest\n") if (not (-s $epsdest));
+    system ("convert $file $epsdest\n") if (not &newer($file, $epsdest));
     print " done.\n";
 }




More information about the LON-CAPA-cvs mailing list