Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Starting in .NET 10, GnuTarEntry and PaxTarEntry no longer automatically set access time (atime) and change time (ctime) fields when creating new entries. These fields are problematic in tar entries because not all tar readers support them. The fields will still be preserved when reading, and you set them directly. But they won't be set on existing entries that didn't have them to start, or when converting from other entry types.
The behavior of TarEntry.ModificationTime is unchanged. It's initialized to UtcNow for tar entries created with a constructor, and uses the file modification time for entries created from files.
Other minor fixes have been made to System.Formats.Tar to prioritize round-tripping of TarEntry entries from read to write without change.
Version introduced
.NET 10 Preview 5
Previous behavior
Previously, GnuTarEntry and PaxTarEntry always added atime and ctime values when creating new entries.
New behavior
Starting in .NET 10, GnuTarEntry and PaxTarEntry only set atime and ctime if:
- The entry is read from a tar archive that already contains these fields.
- The user explicitly set them using the appropriate properties.
The behavior of TarEntry.ModificationTime remains unchanged. It's initialized to DateTime.UtcNow for tar entries created with a constructor, and uses the file modification time for entries created from files.
Type of breaking change
This is a behavioral change.
Reason for change
This change was made for better compatibility with other tar readers and to improve round-tripping of tar files without modification.
Recommended action
No action required for most users—most archives have no use for these timestamps.
If you require these fields to be set, you can use the following APIs:
- For
GnuTarEntry: Use the GnuTarEntry.AccessTime and GnuTarEntry.ChangeTime properties. - For
PaxTarEntry: Use the constructor that accepts extended attributes: PaxTarEntry(TarEntryType, String, IEnumerable<KeyValuePair<String,String>>).
However, be aware that setting these fields creates a tar file that isn't readable by many tar clients.