/* Diff files from a tar archive.
Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001,
- 2003, 2004 Free Software Foundation, Inc.
+ 2003, 2004, 2005 Free Software Foundation, Inc.
Written by John Gilmore, on 1987-04-30.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#include <system.h>
-#if HAVE_UTIME_H
-# include <utime.h>
-#else
-struct utimbuf
- {
- long actime;
- long modtime;
- };
-#endif
-
#if HAVE_LINUX_FD_H
# include <linux/fd.h>
#endif
#include <quotearg.h>
+#include <utimens.h>
#include "common.h"
#include <rmt.h>
\f
static void
-diff_dir ()
+diff_dir (void)
{
struct stat stat_data;
}
static void
-diff_file ()
+diff_file (void)
{
struct stat stat_data;
}
else
{
- int fd = open (current_stat_info.file_name, O_RDONLY | O_BINARY);
+ diff_handle = open (current_stat_info.file_name, O_RDONLY | O_BINARY);
- if (fd < 0)
+ if (diff_handle < 0)
{
open_error (current_stat_info.file_name);
skip_member ();
else
{
int status;
- struct utimbuf restore_times;
-
- restore_times.actime = stat_data.st_atime;
- restore_times.modtime = stat_data.st_mtime;
if (current_stat_info.is_sparse)
sparse_diff_file (diff_handle, ¤t_stat_info);
{
if (multi_volume_option)
{
- assign_string (&save_name,
+ assign_string (&save_name,
current_stat_info.orig_file_name);
save_totsize = current_stat_info.stat.st_size;
/* save_sizeleft is set in read_and_process. */
assign_string (&save_name, 0);
}
- status = close (fd);
+ status = close (diff_handle);
if (status != 0)
close_error (current_stat_info.file_name);
if (atime_preserve_option)
- utime (current_stat_info.file_name, &restore_times);
+ {
+ struct timespec ts[2];
+ ts[0] = get_stat_atime (&stat_data);
+ ts[1] = get_stat_mtime (&stat_data);
+ if (utimens (current_stat_info.file_name, ts) != 0)
+ utime_error (current_stat_info.file_name);
+ }
}
}
}
}
static void
-diff_link ()
+diff_link (void)
{
struct stat file_data;
struct stat link_data;
#ifdef HAVE_READLINK
static void
-diff_symlink ()
+diff_symlink (void)
{
size_t len = strlen (current_stat_info.link_name);
char *linkbuf = alloca (len + 1);
#endif
static void
-diff_special ()
+diff_special (void)
{
struct stat stat_data;
}
static void
-diff_dumpdir ()
+diff_dumpdir (void)
{
char *dumpdir_buffer = get_directory_contents (current_stat_info.file_name,
0);
}
static void
-diff_multivol ()
+diff_multivol (void)
{
struct stat stat_data;
int fd, status;
diff_dir ();
return;
}
-
+
if (!get_stat_data (current_stat_info.file_name, &stat_data))
return;
}
fd = open (current_stat_info.file_name, O_RDONLY | O_BINARY);
-
+
if (fd < 0)
{
open_error (current_stat_info.file_name);
if (multi_volume_option)
assign_string (&save_name, 0);
-
+
status = close (fd);
if (status != 0)
close_error (current_stat_info.file_name);
diff_symlink ();
break;
#endif
-
+
case CHRTYPE:
case BLKTYPE:
case FIFOTYPE:
case GNUTYPE_DUMPDIR:
diff_dumpdir ();
/* Fall through. */
-
+
case DIRTYPE:
diff_dir ();
break;