src/lib/osunix.c 1.47

1.47 2010/03/19 19:11:24 angie
Converted touchFile to maybeTouchFile because ownership of an existing file (not just permissions) can cause problems.
Index: src/lib/osunix.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/osunix.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -b -B -U 4 -r1.46 -r1.47
--- src/lib/osunix.c	13 Mar 2010 23:01:50 -0000	1.46
+++ src/lib/osunix.c	19 Mar 2010 19:11:24 -0000	1.47
@@ -613,21 +613,30 @@
 vaDumpStack(format, args);
 va_end(args);
 }
 
-void touchFile(char *fileName)
-/* If file exists, set its access and mod times to now.  If it doesn't exist, create it. */
+boolean maybeTouchFile(char *fileName)
+/* If file exists, set its access and mod times to now.  If it doesn't exist, create it.
+ * Return FALSE if we have a problem doing so (e.g. when qateam is gdb'ing and code tries 
+ * to touch some file owned by www). */
 {
 if (fileExists(fileName))
     {
     struct utimbuf ut;
     ut.actime = ut.modtime = clock1();
     int ret = utime(fileName, &ut);
     if (ret != 0)
-	errnoAbort("utime(%s, clock1()) failed", fileName);
+	{
+	warn("utime(%s) failed (ownership?)", fileName);
+	return FALSE;
+	}
     }
 else
     {
-    FILE *f = mustOpen(fileName, "w");
+    FILE *f = fopen(fileName, "w");
+    if (f == NULL)
+	return FALSE;
+    else
     carefulClose(&f);
     }
+return TRUE;
 }