diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2009-11-15 02:12:53 +0300 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2009-11-15 02:12:53 +0300 |
commit | a307af1af62c51e33e2801d74dbc35560af0fc0e (patch) | |
tree | 8d1164763328f7b580afceda831b979de97b7da7 /coreutils/touch.c | |
parent | cc8b6871a71e42a3e0bdb79e534b90cc3eb4c8e6 (diff) |
use utimes() rather than obsolescent utime()
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'coreutils/touch.c')
-rw-r--r-- | coreutils/touch.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c index e79092fc1..7d1bf0d9e 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -49,13 +49,13 @@ int touch_main(int argc UNUSED_PARAM, char **argv) "date\0" Required_argument "d" ; # endif - struct utimbuf timebuf; + struct timeval timebuf = {.tv_usec = 0}; char *reference_file = NULL; char *date_str = NULL; #else # define reference_file NULL # define date_str NULL -# define timebuf (*(struct utimbuf*)NULL) +# define timebuf (*(struct timeval*)NULL) #endif int fd; int status = EXIT_SUCCESS; @@ -83,8 +83,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) if (reference_file) { struct stat stbuf; xstat(reference_file, &stbuf); - timebuf.actime = stbuf.st_atime; - timebuf.modtime = stbuf.st_mtime; + timebuf.tv_sec = stbuf.st_mtime; } if (date_str) { @@ -100,12 +99,11 @@ int touch_main(int argc UNUSED_PARAM, char **argv) tm_time.tm_isdst = -1; /* Be sure to recheck dst */ t = validate_tm_time(date_str, &tm_time); - timebuf.actime = t; - timebuf.modtime = t; + timebuf.tv_sec = t; } do { - if (utime(*argv, reference_file ? &timebuf : NULL)) { + if (utimes(*argv, reference_file ? &timebuf : NULL)) { if (errno == ENOENT) { /* no such file */ if (opts) { /* creation is disabled, so ignore */ continue; @@ -116,7 +114,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) ); if ((fd >= 0) && !close(fd)) { if (reference_file) - utime(*argv, &timebuf); + utimes(*argv, &timebuf); continue; } } |