/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.commons.compress.archivers.zip; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.NoSuchElementException; import java.util.Objects; import java.util.function.Function; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.EntryStreamOffsets; import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.io.file.attribute.FileTimes; import org.apache.commons.lang3.ArrayUtils; /** * Extension that adds better handling of extra fields and provides access to the internal and external file attributes. * *
* The extra data is expected to follow the recommendation of APPNOTE.TXT: *
** Any extra data that cannot be parsed by the rules above will be consumed as "unparseable" extra data and treated differently by the methods of this class. * Versions prior to Apache Commons Compress 1.1 would have thrown an exception if any attempt was made to read or write extra data not conforming to the * recommendation. *
* * @NotThreadSafe */ public class ZipArchiveEntry extends ZipEntry implements ArchiveEntry, EntryStreamOffsets { /** * Enumerates how the comment of this entry has been determined. * * @since 1.16 */ public enum CommentSource { /** * The comment has been read from the archive using the encoding of the archive specified when creating the {@link ZipArchiveInputStream} or * {@link ZipFile} (defaults to the platform's default encoding). */ COMMENT, /** * The comment has been read from an {@link UnicodeCommentExtraField Unicode Extra Field}. */ UNICODE_EXTRA_FIELD } /** * Enumerates how to try to parse the extra fields. * ** Configures the behavior for: *
** Wrap extra data that doesn't follow the recommended pattern in an {@link UnparseableExtraFieldData} instance. *
* ** This is the default behavior starting with Commons Compress 1.19. *
*/ BEST_EFFORT(ExtraFieldUtils.UnparseableExtraField.READ) { @Override public ZipExtraField fill(final ZipExtraField field, final byte[] data, final int off, final int len, final boolean local) { return fillAndMakeUnrecognizedOnError(field, data, off, len, local); } }, /** * Try to parse as many extra fields as possible and wrap unknown extra fields in {@link UnrecognizedExtraField}. * ** Wrap extra data that doesn't follow the recommended pattern in an {@link UnparseableExtraFieldData} instance. *
* ** Throw an exception if an extra field that is generally supported cannot be parsed. *
* ** This used to be the default behavior prior to Commons Compress 1.19. *
*/ STRICT_FOR_KNOW_EXTRA_FIELDS(ExtraFieldUtils.UnparseableExtraField.READ), /** * Try to parse as many extra fields as possible and wrap unknown extra fields as well as supported extra fields that cannot be parsed in * {@link UnrecognizedExtraField}. * ** Ignore extra data that doesn't follow the recommended pattern. *
*/ ONLY_PARSEABLE_LENIENT(ExtraFieldUtils.UnparseableExtraField.SKIP) { @Override public ZipExtraField fill(final ZipExtraField field, final byte[] data, final int off, final int len, final boolean local) { return fillAndMakeUnrecognizedOnError(field, data, off, len, local); } }, /** * Try to parse as many extra fields as possible and wrap unknown extra fields in {@link UnrecognizedExtraField}. * ** Ignore extra data that doesn't follow the recommended pattern. *
* ** Throw an exception if an extra field that is generally supported cannot be parsed. *
*/ ONLY_PARSEABLE_STRICT(ExtraFieldUtils.UnparseableExtraField.SKIP), /** * Throw an exception if any of the recognized extra fields cannot be parsed or any extra field violates the recommended pattern. */ DRACONIC(ExtraFieldUtils.UnparseableExtraField.THROW); private static ZipExtraField fillAndMakeUnrecognizedOnError(final ZipExtraField field, final byte[] data, final int off, final int len, final boolean local) { try { return ExtraFieldUtils.fillExtraField(field, data, off, len, local); } catch (final ZipException ex) { final UnrecognizedExtraField u = new UnrecognizedExtraField(); u.setHeaderId(field.getHeaderId()); if (local) { u.setLocalFileDataData(Arrays.copyOfRange(data, off, off + len)); } else { u.setCentralDirectoryData(Arrays.copyOfRange(data, off, off + len)); } return u; } } private final ExtraFieldUtils.UnparseableExtraField onUnparseableData; ExtraFieldParsingMode(final ExtraFieldUtils.UnparseableExtraField onUnparseableData) { this.onUnparseableData = onUnparseableData; } @Override public ZipExtraField createExtraField(final ZipShort headerId) { return ExtraFieldUtils.createExtraField(headerId); } @Override public ZipExtraField fill(final ZipExtraField field, final byte[] data, final int off, final int len, final boolean local) throws ZipException { return ExtraFieldUtils.fillExtraField(field, data, off, len, local); } @Override public ZipExtraField onUnparseableExtraField(final byte[] data, final int off, final int len, final boolean local, final int claimedLength) throws ZipException { return onUnparseableData.onUnparseableExtraField(data, off, len, local, claimedLength); } } /** * Indicates how the name of this entry has been determined. * * @since 1.16 */ public enum NameSource { /** * The name has been read from the archive using the encoding of the archive specified when creating the {@link ZipArchiveInputStream} or * {@link ZipFile} (defaults to the platform's default encoding). */ NAME, /** * The name has been read from the archive and the archive specified the EFS flag which indicates the name has been encoded as UTF-8. */ NAME_WITH_EFS_FLAG, /** * The name has been read from an {@link UnicodePathExtraField Unicode Extra Field}. */ UNICODE_EXTRA_FIELD } private static final String ZIP_DIR_SEP = "/"; static final ZipArchiveEntry[] EMPTY_ARRAY = {}; static LinkedList* The default value -1 means that the method has not been specified. *
* @see COMPRESS-93 */ private int method = ZipMethod.UNKNOWN_CODE; /** * The {@link ZipEntry#setSize} method in the base class throws an IllegalArgumentException if the size is bigger than 2GB for Java versions * < 7 and even in Java 7+ if the implementation in java.util.zip doesn't support Zip64 itself (it is an optional feature). ** We need to keep our own size information for Zip64 support. *
*/ private long size = SIZE_UNKNOWN; private int internalAttributes; private int versionRequired; private int versionMadeBy; private int platform = PLATFORM_FAT; private int rawFlag; private long externalAttributes; private int alignment; private ZipExtraField[] extraFields; private UnparseableExtraFieldData unparseableExtra; private String name; private byte[] rawName; private GeneralPurposeBit generalPurposeBit = new GeneralPurposeBit(); private long localHeaderOffset = OFFSET_UNKNOWN; private long dataOffset = OFFSET_UNKNOWN; private boolean isStreamContiguous; private NameSource nameSource = NameSource.NAME; private final Function* The name will be adjusted to end with a forward slash "/" if the file is a directory. If the file is not a directory a potential trailing forward slash * will be stripped from the entry name. *
* * @param inputFile file to create the entry from * @param entryName name of the entry */ public ZipArchiveEntry(final File inputFile, final String entryName) { this(null, inputFile, entryName); } /** * Creates a new ZIP entry taking some information from the given file and using the provided name. * ** The name will be adjusted to end with a forward slash "/" if the file is a directory. If the file is not a directory a potential trailing forward slash * will be stripped from the entry name. *
* * @param extraFieldFactory custom lookup factory for extra fields or null * @param inputFile file to create the entry from * @param entryName name of the entry */ private ZipArchiveEntry(final Function* The name will be adjusted to end with a forward slash "/" if the file is a directory. If the file is not a directory a potential trailing forward slash * will be stripped from the entry name. *
* * @param extraFieldFactory custom lookup factory for extra fields or null * @param inputPath path to create the entry from. * @param entryName name of the entry. * @param options options indicating how symbolic links are handled. * @throws IOException if an I/O error occurs. */ private ZipArchiveEntry(final Function* Assumes the entry represents a directory if and only if the name ends with a forward slash "/". *
* * @param extraFieldFactory custom lookup factory for extra fields or null * @param name the name of the entry */ private ZipArchiveEntry(final Function* Assumes the entry represents a directory if and only if the name ends with a forward slash "/". *
* * @param extraFieldFactory the extra field lookup factory. * @param entry the entry to get fields from * @throws ZipException on error */ private ZipArchiveEntry(final Function* The name will be adjusted to end with a forward slash "/" if the file is a directory. If the file is not a directory a potential trailing forward slash * will be stripped from the entry name. *
* * @param inputPath path to create the entry from. * @param entryName name of the entry. * @param options options indicating how symbolic links are handled. * @throws IOException if an I/O error occurs. * @since 1.21 */ public ZipArchiveEntry(final Path inputPath, final String entryName, final LinkOption... options) throws IOException { this(null, inputPath, entryName, options); } /** * Creates a new ZIP entry with the specified name. * ** Assumes the entry represents a directory if and only if the name ends with a forward slash "/". *
* * @param name the name of the entry * @since 1.26.0 */ public ZipArchiveEntry(final String name) { this((Function* Assumes the entry represents a directory if and only if the name ends with a forward slash "/". *
* * @param entry the entry to get fields from * @throws ZipException on error */ public ZipArchiveEntry(final ZipArchiveEntry entry) throws ZipException { this((ZipEntry) entry); setInternalAttributes(entry.getInternalAttributes()); setExternalAttributes(entry.getExternalAttributes()); setExtraFields(entry.getAllExtraFieldsNoCopy()); setPlatform(entry.getPlatform()); final GeneralPurposeBit other = entry.getGeneralPurposeBit(); setGeneralPurposeBit(other == null ? null : (GeneralPurposeBit) other.clone()); } /** * Creates a new ZIP entry with fields taken from the specified ZIP entry. * ** Assumes the entry represents a directory if and only if the name ends with a forward slash "/". *
* * @param entry the entry to get fields from * @throws ZipException on error */ public ZipArchiveEntry(final ZipEntry entry) throws ZipException { this(null, entry); } /** * Adds an extra field - replacing an already present extra field of the same type. * ** The new extra field will be the first one. *
* * @param ze an extra field */ public void addAsFirstExtraField(final ZipExtraField ze) { if (ze instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) ze; } else { if (getExtraField(ze.getHeaderId()) != null) { internalRemoveExtraField(ze.getHeaderId()); } final ZipExtraField[] copy = extraFields; final int newLen = ArrayUtils.getLength(extraFields) + 1; extraFields = new ZipExtraField[newLen]; extraFields[0] = ze; if (copy != null) { System.arraycopy(copy, 0, extraFields, 1, extraFields.length - 1); } } setExtra(); } /** * Adds an extra field - replacing an already present extra field of the same type. * ** If no extra field of the same type exists, the field will be added as last field. *
* * @param ze an extra field */ public void addExtraField(final ZipExtraField ze) { internalAddExtraField(ze); setExtra(); } private void addInfoZipExtendedTimestamp(final FileTime lastModifiedTime, final FileTime lastAccessTime, final FileTime creationTime) { final X5455_ExtendedTimestamp infoZipTimestamp = new X5455_ExtendedTimestamp(); if (lastModifiedTime != null) { infoZipTimestamp.setModifyFileTime(lastModifiedTime); } if (lastAccessTime != null) { infoZipTimestamp.setAccessFileTime(lastAccessTime); } if (creationTime != null) { infoZipTimestamp.setCreateFileTime(creationTime); } internalAddExtraField(infoZipTimestamp); } private void addNTFSTimestamp(final FileTime lastModifiedTime, final FileTime lastAccessTime, final FileTime creationTime) { final X000A_NTFS ntfsTimestamp = new X000A_NTFS(); if (lastModifiedTime != null) { ntfsTimestamp.setModifyFileTime(lastModifiedTime); } if (lastAccessTime != null) { ntfsTimestamp.setAccessFileTime(lastAccessTime); } if (creationTime != null) { ntfsTimestamp.setCreateFileTime(creationTime); } internalAddExtraField(ntfsTimestamp); } /** * Overwrite clone. * * @return a cloned copy of this ZipArchiveEntry */ @Override public Object clone() { final ZipArchiveEntry e = (ZipArchiveEntry) super.clone(); e.setInternalAttributes(getInternalAttributes()); e.setExternalAttributes(getExternalAttributes()); e.setExtraFields(getAllExtraFieldsNoCopy()); return e; } private ZipExtraField[] copyOf(final ZipExtraField[] src, final int length) { return Arrays.copyOf(src, length); } @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final ZipArchiveEntry other = (ZipArchiveEntry) obj; final String myName = getName(); final String otherName = other.getName(); if (!Objects.equals(myName, otherName)) { return false; } String myComment = getComment(); String otherComment = other.getComment(); if (myComment == null) { myComment = ""; } if (otherComment == null) { otherComment = ""; } return Objects.equals(getLastModifiedTime(), other.getLastModifiedTime()) && Objects.equals(getLastAccessTime(), other.getLastAccessTime()) && Objects.equals(getCreationTime(), other.getCreationTime()) && myComment.equals(otherComment) && getInternalAttributes() == other.getInternalAttributes() && getPlatform() == other.getPlatform() && getExternalAttributes() == other.getExternalAttributes() && getMethod() == other.getMethod() && getSize() == other.getSize() && getCrc() == other.getCrc() && getCompressedSize() == other.getCompressedSize() && Arrays.equals(getCentralDirectoryExtra(), other.getCentralDirectoryExtra()) && Arrays.equals(getLocalFileDataExtra(), other.getLocalFileDataExtra()) && localHeaderOffset == other.localHeaderOffset && dataOffset == other.dataOffset && generalPurposeBit.equals(other.generalPurposeBit); } private ZipExtraField findMatching(final ZipShort headerId, final List* Note: {@link ZipArchiveInputStream} is unable to fill this field, you must use {@link ZipFile} if you want to read entries using this * attribute. *
* * @return the external file attributes */ public long getExternalAttributes() { return externalAttributes; } /** * Gets an extra field by its header id. * * @param type the header id * @return null if no such field exists. */ public ZipExtraField getExtraField(final ZipShort type) { if (extraFields != null) { for (final ZipExtraField extraField : extraFields) { if (type.equals(extraField.getHeaderId())) { return extraField; } } } return null; } /** * Gets all extra fields that have been parsed successfully. * ** Note: The set of extra fields may be incomplete when {@link ZipArchiveInputStream} has been used as some extra fields use the central * directory to store additional information. *
* * @return an array of the extra fields */ public ZipExtraField[] getExtraFields() { return getParseableExtraFields(); } /** * Gets extra fields. * * @param includeUnparseable whether to also return unparseable extra fields as {@link UnparseableExtraFieldData} if such data exists. * @return an array of the extra fields * @since 1.1 */ public ZipExtraField[] getExtraFields(final boolean includeUnparseable) { return includeUnparseable ? getAllExtraFields() : getParseableExtraFields(); } /** * Gets extra fields. * * @param parsingBehavior controls parsing of extra fields. * @return an array of the extra fields * @throws ZipException if parsing fails, cannot happen if {@code * parsingBehavior} is {@link ExtraFieldParsingMode#BEST_EFFORT}. * @since 1.19 */ public ZipExtraField[] getExtraFields(final ExtraFieldParsingBehavior parsingBehavior) throws ZipException { if (parsingBehavior == ExtraFieldParsingMode.BEST_EFFORT) { return getExtraFields(true); } if (parsingBehavior == ExtraFieldParsingMode.ONLY_PARSEABLE_LENIENT) { return getExtraFields(false); } final byte[] local = getExtra(); final List* Note: {@link ZipArchiveInputStream} is unable to fill this field, you must use {@link ZipFile} if you want to read entries using this * attribute. *
* * @return the internal file attributes */ public int getInternalAttributes() { return internalAttributes; } /** * Wraps {@link ZipEntry#getTime} with a {@link Date} as the entry's last modified date. * ** Changes to the implementation of {@link ZipEntry#getTime()} leak through and the returned value may depend on your local time zone as well as * your version of Java. *
*/ @Override public Date getLastModifiedDate() { return new Date(getTime()); } /** * Gets the extra data for the local file data. * * @return the extra data for local file */ public byte[] getLocalFileDataExtra() { final byte[] extra = getExtra(); return extra != null ? extra : ByteUtils.EMPTY_BYTE_ARRAY; } /** * Gets the local header offset. * * @return the local header offset. * @since 1.24.0 */ public long getLocalHeaderOffset() { return this.localHeaderOffset; } private ZipExtraField[] getMergedFields() { final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length + 1); zipExtraFields[extraFields.length] = unparseableExtra; return zipExtraFields; } /** * Gets the compression method of this entry, or -1 if the compression method has not been specified. * * @return compression method * @since 1.1 */ @Override public int getMethod() { return method; } /** * Gets the name of the entry. * ** This method returns the raw name as it is stored inside of the archive. *
* * @return the entry name */ @Override public String getName() { return name == null ? super.getName() : name; } /** * The source of the name field value. * * @return source of the name field value * @since 1.16 */ public NameSource getNameSource() { return nameSource; } private ZipExtraField[] getParseableExtraFields() { final ZipExtraField[] parseableExtraFields = getParseableExtraFieldsNoCopy(); return parseableExtraFields == extraFields ? copyOf(parseableExtraFields, parseableExtraFields.length) : parseableExtraFields; } private ZipExtraField[] getParseableExtraFieldsNoCopy() { if (extraFields == null) { return ExtraFieldUtils.EMPTY_ZIP_EXTRA_FIELD_ARRAY; } return extraFields; } /** * Platform specification to put into the "version made by" part of the central file header. * * @return PLATFORM_FAT unless {@link #setUnixMode setUnixMode} has been called, in which case PLATFORM_UNIX will be returned. */ public int getPlatform() { return platform; } /** * The content of the flags field. * * @return content of the flags field * @since 1.11 */ public int getRawFlag() { return rawFlag; } /** * Returns the raw bytes that made up the name before it has been converted using the configured or guessed encoding. * ** This method will return null if this instance has not been read from an archive. *
* * @return the raw name bytes * @since 1.2 */ public byte[] getRawName() { if (rawName != null) { return Arrays.copyOf(rawName, rawName.length); } return null; } /** * Gets the uncompressed size of the entry data. * ** Note: {@link ZipArchiveInputStream} may create entries that return {@link #SIZE_UNKNOWN SIZE_UNKNOWN} as long as the entry hasn't been * read completely. *
* * @return the entry size */ @Override public long getSize() { return size; } /** * {@inheritDoc} * ** Override to work around bug JDK-8130914 *
* * @return The last modification time of the entry in milliseconds since the epoch, or -1 if not specified * @see #setTime(long) * @see #setLastModifiedTime(FileTime) */ @Override public long getTime() { if (lastModifiedDateSet) { return getLastModifiedTime().toMillis(); } return time != -1 ? time : super.getTime(); } /** * Gets the Unix permission. * * @return the Unix permissions. */ public int getUnixMode() { return platform != PLATFORM_UNIX ? 0 : (int) (getExternalAttributes() >> SHORT_SHIFT & SHORT_MASK); } /** * Gets up extra field data that couldn't be parsed correctly. * * @return null if no such field exists. * @since 1.1 */ public UnparseableExtraFieldData getUnparseableExtraFieldData() { return unparseableExtra; } private ZipExtraField[] getUnparseableOnly() { return unparseableExtra == null ? ExtraFieldUtils.EMPTY_ZIP_EXTRA_FIELD_ARRAY : new ZipExtraField[] { unparseableExtra }; } /** * Gets the "version made by" field. * * @return "version made by" field * @since 1.11 */ public int getVersionMadeBy() { return versionMadeBy; } /** * Gets the "version required to expand" field. * * @return "version required to expand" field * @since 1.11 */ public int getVersionRequired() { return versionRequired; } /** * Gets the hash code of the entry. This uses the name as the hash code. * * @return a hash code. */ @Override public int hashCode() { // this method has severe consequences on performance. We cannot rely // on the super.hashCode() method since super.getName() always return // the empty string in the current implementation (there's no setter) // so it is basically draining the performance of a hashmap lookup return getName().hashCode(); } private void internalAddExtraField(final ZipExtraField ze) { if (ze instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) ze; } else if (extraFields == null) { extraFields = new ZipExtraField[] { ze }; } else { if (getExtraField(ze.getHeaderId()) != null) { internalRemoveExtraField(ze.getHeaderId()); } final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length + 1); zipExtraFields[zipExtraFields.length - 1] = ze; extraFields = zipExtraFields; } } private void internalRemoveExtraField(final ZipShort type) { if (extraFields == null) { return; } final List* Override to work around bug JDK-8130914 *
* * @param timeEpochMillis The last modification time of the entry in milliseconds since the epoch. * @see #getTime() * @see #getLastModifiedTime() */ @Override public void setTime(final long timeEpochMillis) { if (ZipUtil.isDosTime(timeEpochMillis)) { super.setTime(timeEpochMillis); this.time = timeEpochMillis; lastModifiedDateSet = false; setExtraTimeFields(); } else { setLastModifiedTime(FileTime.fromMillis(timeEpochMillis)); } } /** * Sets Unix permissions in a way that is understood by Info-Zip's unzip command. * * @param mode an {@code int} value */ public void setUnixMode(final int mode) { // CheckStyle:MagicNumberCheck OFF - no point setExternalAttributes(mode << SHORT_SHIFT // MS-DOS read-only attribute | ((mode & 0200) == 0 ? 1 : 0) // MS-DOS directory flag | (isDirectory() ? 0x10 : 0)); // CheckStyle:MagicNumberCheck ON platform = PLATFORM_UNIX; } /** * Sets the "version made by" field. * * @param versionMadeBy "version made by" field * @since 1.11 */ public void setVersionMadeBy(final int versionMadeBy) { this.versionMadeBy = versionMadeBy; } /** * Sets the "version required to expand" field. * * @param versionRequired "version required to expand" field * @since 1.11 */ public void setVersionRequired(final int versionRequired) { this.versionRequired = versionRequired; } private void updateTimeFieldsFromExtraFields() { // Update times from X5455_ExtendedTimestamp field updateTimeFromExtendedTimestampField(); // Update times from X000A_NTFS field, overriding X5455_ExtendedTimestamp if both are present updateTimeFromNtfsField(); } /** * Workaround for the fact that, as of Java 17, {@link ZipEntry} does not properly modify the entry's {@code xdostime} field, only setting * {@code mtime}. While this is not strictly necessary, it's better to maintain the same behavior between this and the NTFS field. */ private void updateTimeFromExtendedTimestampField() { final ZipExtraField extraField = getExtraField(X5455_ExtendedTimestamp.HEADER_ID); if (extraField instanceof X5455_ExtendedTimestamp) { final X5455_ExtendedTimestamp extendedTimestamp = (X5455_ExtendedTimestamp) extraField; if (extendedTimestamp.isBit0_modifyTimePresent()) { final FileTime modifyTime = extendedTimestamp.getModifyFileTime(); if (modifyTime != null) { internalSetLastModifiedTime(modifyTime); } } if (extendedTimestamp.isBit1_accessTimePresent()) { final FileTime accessTime = extendedTimestamp.getAccessFileTime(); if (accessTime != null) { super.setLastAccessTime(accessTime); } } if (extendedTimestamp.isBit2_createTimePresent()) { final FileTime creationTime = extendedTimestamp.getCreateFileTime(); if (creationTime != null) { super.setCreationTime(creationTime); } } } } /** * Workaround for the fact that, as of Java 17, {@link ZipEntry} parses NTFS timestamps with a maximum precision of microseconds, which is * lower than the 100ns precision provided by this extra field. */ private void updateTimeFromNtfsField() { final ZipExtraField extraField = getExtraField(X000A_NTFS.HEADER_ID); if (extraField instanceof X000A_NTFS) { final X000A_NTFS ntfsTimestamp = (X000A_NTFS) extraField; final FileTime modifyTime = ntfsTimestamp.getModifyFileTime(); if (modifyTime != null) { internalSetLastModifiedTime(modifyTime); } final FileTime accessTime = ntfsTimestamp.getAccessFileTime(); if (accessTime != null) { super.setLastAccessTime(accessTime); } final FileTime creationTime = ntfsTimestamp.getCreateFileTime(); if (creationTime != null) { super.setCreationTime(creationTime); } } } }