Don't call ftruncate() when it's not needed.
authorBruno Haible <bruno@clisp.org>
Tue, 31 Dec 2002 13:02:48 +0000 (13:02 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 31 Dec 2002 13:02:48 +0000 (13:02 +0000)
lib/ChangeLog
lib/utime.c

index 1ff4fef..4cbc903 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-22  Bruno Haible  <bruno@clisp.org>
+
+       * utime.c (utime_null): No need to call ftruncate if the file was
+       nonempty.
+
 2002-12-23  Bruno Haible  <bruno@clisp.org>
 
        * memcoll.c (STRCOLL): New macro.
index 237afde..f5507cb 100644 (file)
@@ -65,7 +65,7 @@ utime_null (const char *file)
         of patches, but that system doesn't use this code: it has utimes.
         || fsync (fd) < 0
       */
-      || ftruncate (fd, st.st_size) < 0
+      || (st.st_size == 0 && ftruncate (fd, st.st_size) < 0)
       || close (fd) < 0)
     status = -1;
   return status;