+/* Restore stat attributes (owner, group, mode and times) for
+ FILE_NAME, using information given in *STAT_INFO.
+ If CURRENT_STAT_INFO is nonzero, *CURRENT_STAT_INFO is the
+ file's currernt status.
+ If not restoring permissions, invert the
+ INVERT_PERMISSIONS bits from the file's current permissions.
+ PERMSTATUS specifies the status of the file's permissions.
+ TYPEFLAG specifies the type of the file. */
+
+/* FIXME: About proper restoration of symbolic link attributes, we still do
+ not have it right. Pretesters' reports tell us we need further study and
+ probably more configuration. For now, just use lchown if it exists, and
+ punt for the rest. Sigh! */
+
+static void
+set_stat (char const *file_name, struct stat const *stat_info,
+ struct stat const *current_stat_info,
+ mode_t invert_permissions, enum permstatus permstatus,
+ char typeflag)
+{
+ struct utimbuf utimbuf;
+
+ if (typeflag != SYMTYPE)
+ {
+ /* We do the utime before the chmod because some versions of utime are
+ broken and trash the modes of the file. */
+
+ if (! touch_option && permstatus != INTERDIR_PERMSTATUS)
+ {
+ /* We set the accessed time to `now', which is really the time we
+ started extracting files, unless incremental_option is used, in
+ which case .st_atime is used. */
+
+ /* FIXME: incremental_option should set ctime too, but how? */
+
+ if (incremental_option)
+ utimbuf.actime = stat_info->st_atime;
+ else
+ utimbuf.actime = start_time;
+
+ utimbuf.modtime = stat_info->st_mtime;
+
+ if (utime (file_name, &utimbuf) < 0)
+ utime_error (file_name);
+ else
+ {
+ check_time (file_name, utimbuf.actime);
+ check_time (file_name, utimbuf.modtime);
+ }
+ }