summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-06-22 06:14:28 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-06-22 06:14:28 +0000
commit53fa1be9b65f01469eafcc7c57499d73e35715a7 (patch)
tree52bc4fdd56c82dcd254136e04f4cb09402f978bd /tests
parent49113b5fbf40e65bb5b154ce2a11b9ec0b19be35 (diff)
downloadpaxutils-53fa1be9b65f01469eafcc7c57499d73e35715a7.tar.gz
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 <utimens.h> 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 _().
Diffstat (limited to 'tests')
-rw-r--r--tests/genfile.c29
1 files changed, 11 insertions, 18 deletions
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 <argmatch.h>
#include <argp.h>
#include <argcv.h>
+#include <utimens.h>
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
@@ -40,16 +41,6 @@
# define SIGCHLD SIGCLD
#endif
-#if HAVE_UTIME_H
-# include <utime.h>
-#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++);