changeset 4105:7f998811f2f0

Don't call ftruncate() when it's not needed.
author Bruno Haible <bruno@clisp.org>
date Tue, 31 Dec 2002 13:02:48 +0000
parents f16f0fbf6ce2
children aa367eec7a72
files lib/ChangeLog lib/utime.c
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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.
--- a/lib/utime.c
+++ b/lib/utime.c
@@ -65,7 +65,7 @@
 	 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;