bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] utime() replacement optimization


From: Bruno Haible
Subject: [Bug-gnulib] utime() replacement optimization
Date: Tue, 31 Dec 2002 14:02:18 +0100 (CET)

Hi,

I did this change. There is a need to ftruncate() a file during "touch"
only if it was and should remain empty.


2002-12-22  Bruno Haible  <address@hidden>

        * utime.c (utime_null): No need to call ftruncate if the file was
        nonempty.

diff -r -c3 gnulib-cvs/lib/utime.c gnulib/lib/utime.c
*** gnulib-cvs/lib/utime.c      2002-12-17 12:42:00.000000000 +0100
--- gnulib/lib/utime.c  2002-12-22 18:46:19.000000000 +0100
***************
*** 65,71 ****
         of patches, but that system doesn't use this code: it has utimes.
         || fsync (fd) < 0
        */
!       || ftruncate (fd, st.st_size) < 0
        || close (fd) < 0)
      status = -1;
    return status;
--- 65,71 ----
         of patches, but that system doesn't use this code: it has utimes.
         || fsync (fd) < 0
        */
!       || (st.st_size == 0 && ftruncate (fd, st.st_size) < 0)
        || close (fd) < 0)
      status = -1;
    return status;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]