use utimes() rather than obsolescent utime()

utime is obsolescent in POSIX.1-2008, use utimes() for now.
Untested.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
This commit is contained in:
Bernhard Reutner-Fischer 2009-11-14 23:35:00 +01:00
parent e3600a042e
commit cc8b6871a7
2 changed files with 3 additions and 6 deletions

View File

@ -105,15 +105,13 @@ int FAST_FUNC bbunpack(char **argv,
if (status >= 0) { if (status >= 0) {
/* TODO: restore other things? */ /* TODO: restore other things? */
if (info.mtime) { if (info.mtime) {
struct utimbuf times; struct timeval times = {.tv_sec = info.mtime,
.tv_usec = 0};
times.actime = info.mtime;
times.modtime = info.mtime;
/* Note: we closed it first. /* Note: we closed it first.
* On some systems calling utime * On some systems calling utime
* then closing resets the mtime * then closing resets the mtime
* back to current time. */ * back to current time. */
utime(new_name, &times); /* ignoring errors */ utimes(new_name, &times); /* ignoring errors */
} }
/* Delete _compressed_ file */ /* Delete _compressed_ file */

View File

@ -40,7 +40,6 @@
#include <termios.h> #include <termios.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <utime.h>
/* Try to pull in PATH_MAX */ /* Try to pull in PATH_MAX */
#include <limits.h> #include <limits.h>
#include <sys/param.h> #include <sys/param.h>