Use File Descriptor in Setting Stat on Output File

Note that the `fd` is only valid while the file is still open. So we need to
move the setting calls to before we close the file. However! We cannot do so
with the `utime()` call (even though `futimens()` exists) because the follow-
ing `close()` call to the `fd` will reset the atime of the file. So it seems
the `utime()` call has to happen after the file is closed.
This commit is contained in:
W. Felix Handte
2023-02-06 14:02:31 -08:00
parent a5a2418df4
commit f746c37d00
4 changed files with 27 additions and 15 deletions
-3
View File
@@ -295,9 +295,6 @@ int UTIL_setFDStat(const int fd, const char *filename, const stat_t *statbuf)
return -1;
}
/* set access and modification times */
res += UTIL_utime(filename, statbuf);
/* Mimic gzip's behavior:
*
* "Change the group first, then the permissions, then the owner.