From 53fa1be9b65f01469eafcc7c57499d73e35715a7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 22 Jun 2005 06:14:28 +0000 Subject: Improve support for time stamps and other wide integers. * gnulib.modules: Add inttostr, quote, quotearg. * lib/system.h (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. (INT_STRLEN_BOUND): Remove. Include "intprops.h" instead. (UINTMAX_STRSIZE_BOUND): Define in terms of INT_BUFSIZE_BOUND, not INT_STRLEN_BOUND. [HAVE_UTIME_H]: Don't include utime.h. * paxlib/DISTFILES: Remove convert.c. * paxlib/convert.c: Remove. * paxlib/error.c: Include quote.h, quotearg.h. * paxlib/paxlib.h: Include inttostr.h. (STRINGIFY_BIGINT): Define in terms of umaxtostr. (stringify_uintmax_t_backwards): Remove decl. * tests/genfile.c: Include instead of rolling our own. (exec_checkpoint): Use utimens instead of rolling our own. Don't pass extra args to error. (main): Wrap message inside _(). --- tests/genfile.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/genfile.c b/tests/genfile.c index 21364d5..081ba59 100644 --- a/tests/genfile.c +++ b/tests/genfile.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -40,16 +41,6 @@ # define SIGCHLD SIGCLD #endif -#if HAVE_UTIME_H -# include -#else -struct utimbuf - { - long actime; - long modtime; - }; -#endif - enum pattern { DEFAULT_PATTERN, @@ -509,10 +500,14 @@ exec_checkpoint (struct action *p) { case OPT_TOUCH: { - struct utimbuf u; + struct timespec ts[2]; - u.actime = u.modtime = p->ts.tv_sec; - utime (p->name, &u); + ts[0] = ts[1] = p->ts; + if (utimens (p->name, ts) != 0) + { + error (0, errno, _("cannot set time on `%s'"), p->name); + break; + } } break; @@ -521,8 +516,7 @@ exec_checkpoint (struct action *p) FILE *fp = fopen (p->name, "a"); if (!fp) { - error (0, errno, _("cannot open `%s'"), - p->name, strerror (errno)); + error (0, errno, _("cannot open `%s'"), p->name); break; } @@ -536,8 +530,7 @@ exec_checkpoint (struct action *p) int fd = open (p->name, O_RDWR); if (fd == -1) { - error (0, errno, _("cannot open `%s'"), - p->name, strerror (errno)); + error (0, errno, _("cannot open `%s'"), p->name); break; } ftruncate (fd, p->size); @@ -709,7 +702,7 @@ main (int argc, char **argv) { case mode_stat: if (argc == 0) - error (EXIT_FAILURE, 0, "--stat requires file names"); + error (EXIT_FAILURE, 0, _("--stat requires file names")); while (argc--) print_stat (*argv++); -- cgit v1.2.1