summaryrefslogtreecommitdiff
path: root/lib/sbin/CSTUtils.pl
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-10-20 12:46:22 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-10-20 12:46:22 +0000
commit91d9f35c351b54547d7cab6d69c1ccc554d22d17 (patch)
tree27eb648bc7abc83a8c687c390e60fbf56c8c58f6 /lib/sbin/CSTUtils.pl
parent019f6271792eba1d1d4d9c385bd545638d8d3cc4 (diff)
CST only writes files which have changed (still a couple more writes
to replace). Also a bug fix for Build Headers for when the file to be included is in the include directory of the thorn. git-svn-id: http://svn.cactuscode.org/flesh/trunk@1068 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/CSTUtils.pl')
-rw-r--r--lib/sbin/CSTUtils.pl39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/sbin/CSTUtils.pl b/lib/sbin/CSTUtils.pl
index e56a85e0..20966453 100644
--- a/lib/sbin/CSTUtils.pl
+++ b/lib/sbin/CSTUtils.pl
@@ -134,6 +134,45 @@ sub chompme
}
}
+#/*@@
+# @routine WriteFile
+# @date Tue Oct 19 21:09:12 CEST 1999
+# @author Gabrielle Allen
+# @desc
+# Writes a file only if the contents haven't changed
+# @enddesc
+# @calls
+# @calledby
+# @history
+#
+# @endhistory
+#@@*/
+
+sub WriteFile
+{
+ local ($filename,$data) = @_;
+ local ($data_in);
+
+# Read in file
+ $data_in = "";
+ if (-e $filename)
+ {
+ open(IN, "<$filename");
+ while (<IN>)
+ {
+ $data_in .= $_;
+ }
+ }
+
+ if ($data ne $data_in)
+ {
+ print "Creating new file $filename\n";
+ open(OUT, ">$filename") || die("Can't open $filename\n");
+ print OUT $data;
+ close OUT;
+ }
+
+}
1;