Class ZipArchiveEntry
- All Implemented Interfaces:
Cloneable,ArchiveEntry,EntryStreamOffsets
- Direct Known Subclasses:
JarArchiveEntry,ZipFile.Entry
The extra data is expected to follow the recommendation of APPNOTE.TXT:
- the extra byte array consists of a sequence of extra fields
- each extra fields starts by a two byte header id followed by a two byte sequence holding the length of the remainder of data.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIndicates how the comment of this entry has been determined.static enumHow to try to parse the extra fields.static enumIndicates how the name of this entry has been determined. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final longstatic final intstatic final intstatic final intstatic final intprivate ZipArchiveEntry.CommentSourcestatic final intprivate longprivate long(package private) static final ZipArchiveEntry[](package private) static LinkedList<ZipArchiveEntry> static final intstatic final intstatic final intstatic final longstatic final intstatic final intstatic final intstatic final intprivate longstatic final intstatic final intprivate final Function<ZipShort, ZipExtraField> private ZipExtraField[]static final longstatic final intprivate GeneralPurposeBitprivate intprivate booleanprivate booleanprivate longstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final longstatic final intstatic final intstatic final intprivate intTheZipEntrybase class only supports the compression methods STORED and DEFLATED.private Stringprivate ZipArchiveEntry.NameSourceprivate intstatic final intstatic final intprivate intprivate byte[]private static final intprivate static final intprivate longTheZipEntry.setSize(long)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).private longprivate UnparseableExtraFieldDataprivate intprivate intprivate static final StringFields inherited from interface org.apache.commons.compress.archivers.ArchiveEntry
SIZE_UNKNOWNFields inherited from interface org.apache.commons.compress.archivers.EntryStreamOffsets
OFFSET_UNKNOWN -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedZipArchiveEntry(File inputFile, String entryName) Creates a new ZIP entry taking some information from the given file and using the provided name.ZipArchiveEntry(String name) Creates a new ZIP entry with the specified name.ZipArchiveEntry(Path inputPath, String entryName, LinkOption... options) Creates a new ZIP entry taking some information from the given path and using the provided name.privateZipArchiveEntry(Function<ZipShort, ZipExtraField> extraFieldFactory, File inputFile, String entryName) Creates a new ZIP entry taking some information from the given file and using the provided name.privateZipArchiveEntry(Function<ZipShort, ZipExtraField> extraFieldFactory, String name) Creates a new ZIP entry with the specified name.privateZipArchiveEntry(Function<ZipShort, ZipExtraField> extraFieldFactory, Path inputPath, String entryName, LinkOption... options) Creates a new ZIP entry taking some information from the given path and using the provided name.privateZipArchiveEntry(Function<ZipShort, ZipExtraField> extraFieldFactory, ZipEntry entry) Creates a new ZIP entry with fields taken from the specified ZIP entry.ZipArchiveEntry(ZipEntry entry) Creates a new ZIP entry with fields taken from the specified ZIP entry.ZipArchiveEntry(ZipArchiveEntry entry) Creates a new ZIP entry with fields taken from the specified ZIP entry. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an extra field - replacing an already present extra field of the same type.voidAdds an extra field - replacing an already present extra field of the same type.private voidaddInfoZipExtendedTimestamp(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime creationTime) private voidaddNTFSTimestamp(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime creationTime) private static booleancanConvertToInfoZipExtendedTimestamp(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime creationTime) clone()Overwrite clone.private ZipExtraField[]copyOf(ZipExtraField[] src, int length) booleanprivate ZipExtraFieldfindMatching(ZipShort headerId, List<ZipExtraField> fs) private ZipExtraFieldprotected intGets currently configured alignment.private ZipExtraField[]private ZipExtraField[]Gets all extra fields, including unparseable ones.byte[]Retrieves the extra data for the central directory.The source of the comment field value.longGets the offset of data stream within the archive file,longThe number of the split segment this entry starts at.longRetrieves the external file attributes.getExtraField(ZipShort type) Gets an extra field by its header id.Gets all extra fields that have been parsed successfully.getExtraFields(boolean includeUnparseable) Gets extra fields.getExtraFields(ExtraFieldParsingBehavior parsingBehavior) Gets extra fields.The "general purpose bit" field.intGets the internal file attributes.WrapsZipEntry.getTime()with aDateas the entry's last modified date.byte[]Gets the extra data for the local file data.longGets the local header offset.private ZipExtraField[]intGets the compression method of this entry, or -1 if the compression method has not been specified.getName()Gets the name of the entry.The source of the name field value.private ZipExtraField[]private ZipExtraField[]intPlatform specification to put into the "version made by" part of the central file header.intThe content of the flags field.byte[]Returns the raw bytes that made up the name before it has been converted using the configured or guessed encoding.longgetSize()Gets the uncompressed size of the entry data.longgetTime()intGets the UNIX permission.Gets up extra field data that couldn't be parsed correctly.private ZipExtraField[]intGets the "version made by" field.intGets the "version required to expand" field.inthashCode()Gets the hash code of the entry.private voidprivate voidprivate voidbooleanIs this entry a directory?private static booleanisDirectoryEntryName(String entryName) booleanTests whether the stream is contiguous, that is, not split among several archive parts, interspersed with control blocks, and so on.booleanReturns true if this entry represents a unix symlink, in which case the entry's content contains the target path for the symlink.private voidmergeExtraFields(ZipExtraField[] f, boolean local) If there are no extra fields, use the given fields as new extra data - otherwise merge the fields assuming the existing fields and the new fields stem from different locations inside the archive.private ZipExtraField[]parseExtraFields(byte[] data, boolean local, ExtraFieldParsingBehavior parsingBehavior) voidremoveExtraField(ZipShort type) Remove an extra field.voidRemoves unparseable extra field data.private booleanvoidsetAlignment(int alignment) Sets alignment for this entry.private voidsetAttributes(Path inputPath, LinkOption... options) voidsetCentralDirectoryExtra(byte[] b) Sets the central directory part of extra fields.voidsetCommentSource(ZipArchiveEntry.CommentSource commentSource) Sets the source of the comment field value.setCreationTime(FileTime time) protected voidsetDataOffset(long dataOffset) Sets the data offset.voidsetDiskNumberStart(long diskNumberStart) The number of the split segment this entry starts at.voidsetExternalAttributes(long value) Sets the external file attributes.protected voidsetExtra()UnfortunatelyZipOutputStreamseems to access the extra data directly, so overriding getExtra doesn't help - we need to modify super's data directly and on every update.voidsetExtra(byte[] extra) Parses the given bytes as extra field data and consumes any unparseable data as anUnparseableExtraFieldDatainstance.voidsetExtraFields(ZipExtraField[] fields) Replaces all currently attached extra fields with the new array.private voidvoidsetGeneralPurposeBit(GeneralPurposeBit generalPurposeBit) Sets the "general purpose bit" field.voidsetInternalAttributes(int internalAttributes) Sets the internal file attributes.setLastAccessTime(FileTime fileTime) setLastModifiedTime(FileTime fileTime) protected voidsetLocalHeaderOffset(long localHeaderOffset) voidsetMethod(int method) Sets the compression method of this entry.protected voidSets the name of the entry.protected voidSets the name using the raw bytes and the string created from it by guessing or using the configured encoding.voidsetNameSource(ZipArchiveEntry.NameSource nameSource) Sets the source of the name field value.protected voidsetPlatform(int platform) Sets the platform (UNIX or FAT).voidsetRawFlag(int rawFlag) Sets the content of the flags field.voidsetSize(long size) Sets the uncompressed size of the entry data.protected voidsetStreamContiguous(boolean isStreamContiguous) voidsetTime(long timeEpochMillis) voidSets the modification time of the entry.voidsetUnixMode(int mode) Sets UNIX permissions in a way that is understood by Info-Zip's unzip command.voidsetVersionMadeBy(int versionMadeBy) Sets the "version made by" field.voidsetVersionRequired(int versionRequired) Sets the "version required to expand" field.private static StringtoDirectoryEntryName(String entryName) private static StringtoEntryName(File inputFile, String entryName) private static StringtoEntryName(Path inputPath, String entryName, LinkOption... options) private voidprivate voidWorkaround for the fact that, as of Java 17,ZipEntrydoes not properly modify the entry'sxdostimefield, only settingmtime.private voidWorkaround for the fact that, as of Java 17,ZipEntryparses NTFS timestamps with a maximum precision of microseconds, which is lower than the 100ns precision provided by this extra field.Methods inherited from class java.util.zip.ZipEntry
getComment, getCompressedSize, getCrc, getCreationTime, getExtra, getLastAccessTime, getLastModifiedTime, setComment, setCompressedSize, setCrc, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.compress.archivers.ArchiveEntry
resolveIn
-
Field Details
-
ZIP_DIR_SEP
- See Also:
-
EMPTY_ARRAY
-
EMPTY_LINKED_LIST
-
PLATFORM_UNIX
public static final int PLATFORM_UNIX- See Also:
-
PLATFORM_FAT
public static final int PLATFORM_FAT- See Also:
-
CRC_UNKNOWN
public static final int CRC_UNKNOWN- See Also:
-
SHORT_MASK
private static final int SHORT_MASK- See Also:
-
SHORT_SHIFT
private static final int SHORT_SHIFT- See Also:
-
method
private int methodTheZipEntrybase class only supports the compression methods STORED and DEFLATED. We override the field so that any compression methods can be used.The default value -1 means that the method has not been specified.
- See Also:
-
size
private long sizeTheZipEntry.setSize(long)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.
-
internalAttributes
private int internalAttributes -
versionRequired
private int versionRequired -
versionMadeBy
private int versionMadeBy -
platform
private int platform -
rawFlag
private int rawFlag -
externalAttributes
private long externalAttributes -
alignment
private int alignment -
extraFields
-
unparseableExtra
-
name
-
rawName
private byte[] rawName -
generalPurposeBit
-
localHeaderOffset
private long localHeaderOffset -
dataOffset
private long dataOffset -
isStreamContiguous
private boolean isStreamContiguous -
nameSource
-
extraFieldFactory
-
commentSource
-
diskNumberStart
private long diskNumberStart -
lastModifiedDateSet
private boolean lastModifiedDateSet -
time
private long time -
LOCSIG
static final long LOCSIG- See Also:
-
EXTSIG
static final long EXTSIG- See Also:
-
CENSIG
static final long CENSIG- See Also:
-
ENDSIG
static final long ENDSIG- See Also:
-
LOCHDR
static final int LOCHDR- See Also:
-
EXTHDR
static final int EXTHDR- See Also:
-
CENHDR
static final int CENHDR- See Also:
-
ENDHDR
static final int ENDHDR- See Also:
-
LOCVER
static final int LOCVER- See Also:
-
LOCFLG
static final int LOCFLG- See Also:
-
LOCHOW
static final int LOCHOW- See Also:
-
LOCTIM
static final int LOCTIM- See Also:
-
LOCCRC
static final int LOCCRC- See Also:
-
LOCSIZ
static final int LOCSIZ- See Also:
-
LOCLEN
static final int LOCLEN- See Also:
-
LOCNAM
static final int LOCNAM- See Also:
-
LOCEXT
static final int LOCEXT- See Also:
-
EXTCRC
static final int EXTCRC- See Also:
-
EXTSIZ
static final int EXTSIZ- See Also:
-
EXTLEN
static final int EXTLEN- See Also:
-
CENVEM
static final int CENVEM- See Also:
-
CENVER
static final int CENVER- See Also:
-
CENFLG
static final int CENFLG- See Also:
-
CENHOW
static final int CENHOW- See Also:
-
CENTIM
static final int CENTIM- See Also:
-
CENCRC
static final int CENCRC- See Also:
-
CENSIZ
static final int CENSIZ- See Also:
-
CENLEN
static final int CENLEN- See Also:
-
CENNAM
static final int CENNAM- See Also:
-
CENEXT
static final int CENEXT- See Also:
-
CENCOM
static final int CENCOM- See Also:
-
CENDSK
static final int CENDSK- See Also:
-
CENATT
static final int CENATT- See Also:
-
CENATX
static final int CENATX- See Also:
-
CENOFF
static final int CENOFF- See Also:
-
ENDSUB
static final int ENDSUB- See Also:
-
ENDTOT
static final int ENDTOT- See Also:
-
ENDSIZ
static final int ENDSIZ- See Also:
-
ENDOFF
static final int ENDOFF- See Also:
-
ENDCOM
static final int ENDCOM- See Also:
-
-
Constructor Details
-
ZipArchiveEntry
protected ZipArchiveEntry() -
ZipArchiveEntry
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.
- Parameters:
inputFile- file to create the entry fromentryName- name of the entry
-
ZipArchiveEntry
private ZipArchiveEntry(Function<ZipShort, ZipExtraField> extraFieldFactory, File inputFile, String 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.
- Parameters:
extraFieldFactory- custom lookup factory for extra fields or nullinputFile- file to create the entry fromentryName- name of the entry
-
ZipArchiveEntry
private ZipArchiveEntry(Function<ZipShort, ZipExtraField> extraFieldFactory, Path inputPath, String entryName, LinkOption... options) throws IOExceptionCreates a new ZIP entry taking some information from the given path 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.
- Parameters:
extraFieldFactory- custom lookup factory for extra fields or nullinputPath- path to create the entry from.entryName- name of the entry.options- options indicating how symbolic links are handled.- Throws:
IOException- if an I/O error occurs.
-
ZipArchiveEntry
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 "/".
- Parameters:
extraFieldFactory- custom lookup factory for extra fields or nullname- the name of the entry
-
ZipArchiveEntry
private ZipArchiveEntry(Function<ZipShort, ZipExtraField> extraFieldFactory, ZipEntry entry) throws ZipExceptionCreates 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 "/".
- Parameters:
extraFieldFactory- the extra field lookup factory.entry- the entry to get fields from- Throws:
ZipException- on error
-
ZipArchiveEntry
Creates a new ZIP entry taking some information from the given path 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.
- Parameters:
inputPath- path to create the entry from.entryName- name of the entry.options- options indicating how symbolic links are handled.- Throws:
IOException- if an I/O error occurs.- Since:
- 1.21
-
ZipArchiveEntry
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 "/".
- Parameters:
name- the name of the entry- Since:
- 1.26.0
-
ZipArchiveEntry
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 "/".
- Parameters:
entry- the entry to get fields from- Throws:
ZipException- on error
-
ZipArchiveEntry
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 "/".
- Parameters:
entry- the entry to get fields from- Throws:
ZipException- on error
-
-
Method Details
-
canConvertToInfoZipExtendedTimestamp
-
isDirectoryEntryName
-
toDirectoryEntryName
-
toEntryName
-
toEntryName
-
addAsFirstExtraField
Adds an extra field - replacing an already present extra field of the same type.The new extra field will be the first one.
- Parameters:
ze- an extra field
-
addExtraField
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.
- Parameters:
ze- an extra field
-
addInfoZipExtendedTimestamp
-
addNTFSTimestamp
-
clone
Overwrite clone. -
copyOf
-
equals
-
findMatching
-
findUnparseable
-
getAlignment
protected int getAlignment()Gets currently configured alignment.- Returns:
- alignment for this entry.
- Since:
- 1.14
-
getAllExtraFields
-
getAllExtraFieldsNoCopy
Gets all extra fields, including unparseable ones.- Returns:
- An array of all extra fields. Not necessarily a copy of internal data structures, hence private method
-
getCentralDirectoryExtra
public byte[] getCentralDirectoryExtra()Retrieves the extra data for the central directory.- Returns:
- the central directory extra data
-
getCommentSource
The source of the comment field value.- Returns:
- source of the comment field value
- Since:
- 1.16
-
getDataOffset
public long getDataOffset()Description copied from interface:EntryStreamOffsetsGets the offset of data stream within the archive file,- Specified by:
getDataOffsetin interfaceEntryStreamOffsets- Returns:
- the offset of entry data stream,
OFFSET_UNKNOWNif not known.
-
getDiskNumberStart
public long getDiskNumberStart()The number of the split segment this entry starts at.- Returns:
- the number of the split segment this entry starts at.
- Since:
- 1.20
-
getExternalAttributes
public long getExternalAttributes()Retrieves the external file attributes.Note:
ZipArchiveInputStreamis unable to fill this field, you must useZipFileif you want to read entries using this attribute.- Returns:
- the external file attributes
-
getExtraField
Gets an extra field by its header id.- Parameters:
type- the header id- Returns:
- null if no such field exists.
-
getExtraFields
Gets all extra fields that have been parsed successfully.Note: The set of extra fields may be incomplete when
ZipArchiveInputStreamhas been used as some extra fields use the central directory to store additional information.- Returns:
- an array of the extra fields
-
getExtraFields
Gets extra fields.- Parameters:
includeUnparseable- whether to also return unparseable extra fields asUnparseableExtraFieldDataif such data exists.- Returns:
- an array of the extra fields
- Since:
- 1.1
-
getExtraFields
public ZipExtraField[] getExtraFields(ExtraFieldParsingBehavior parsingBehavior) throws ZipException Gets extra fields.- Parameters:
parsingBehavior- controls parsing of extra fields.- Returns:
- an array of the extra fields
- Throws:
ZipException- if parsing fails, can not happen ifparsingBehaviorisZipArchiveEntry.ExtraFieldParsingMode.BEST_EFFORT.- Since:
- 1.19
-
getGeneralPurposeBit
The "general purpose bit" field.- Returns:
- the general purpose bit
- Since:
- 1.1
-
getInternalAttributes
public int getInternalAttributes()Gets the internal file attributes.Note:
ZipArchiveInputStreamis unable to fill this field, you must useZipFileif you want to read entries using this attribute.- Returns:
- the internal file attributes
-
getLastModifiedDate
WrapsZipEntry.getTime()with aDateas the entry's last modified date.Changes to the implementation of
ZipEntry.getTime()leak through and the returned value may depend on your local time zone as well as your version of Java.- Specified by:
getLastModifiedDatein interfaceArchiveEntry- Returns:
- the last modified date of this entry.
-
getLocalFileDataExtra
public byte[] getLocalFileDataExtra()Gets the extra data for the local file data.- Returns:
- the extra data for local file
-
getLocalHeaderOffset
public long getLocalHeaderOffset()Gets the local header offset.- Returns:
- the local header offset.
- Since:
- 1.24.0
-
getMergedFields
-
getMethod
public int getMethod()Gets the compression method of this entry, or -1 if the compression method has not been specified. -
getName
Gets the name of the entry.This method returns the raw name as it is stored inside of the archive.
- Specified by:
getNamein interfaceArchiveEntry- Overrides:
getNamein classZipEntry- Returns:
- the entry name
-
getNameSource
The source of the name field value.- Returns:
- source of the name field value
- Since:
- 1.16
-
getParseableExtraFields
-
getParseableExtraFieldsNoCopy
-
getPlatform
public int getPlatform()Platform specification to put into the "version made by" part of the central file header.- Returns:
- PLATFORM_FAT unless
setUnixModehas been called, in which case PLATFORM_UNIX will be returned.
-
getRawFlag
public int getRawFlag()The content of the flags field.- Returns:
- content of the flags field
- Since:
- 1.11
-
getRawName
public byte[] getRawName()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.
- Returns:
- the raw name bytes
- Since:
- 1.2
-
getSize
public long getSize()Gets the uncompressed size of the entry data.Note:
ZipArchiveInputStreammay create entries that returnSIZE_UNKNOWNas long as the entry hasn't been read completely.- Specified by:
getSizein interfaceArchiveEntry- Overrides:
getSizein classZipEntry- Returns:
- the entry size
-
getTime
public long getTime()Override to work around bug JDK-8130914
-
getUnixMode
public int getUnixMode()Gets the UNIX permission.- Returns:
- the unix permissions
-
getUnparseableExtraFieldData
Gets up extra field data that couldn't be parsed correctly.- Returns:
- null if no such field exists.
- Since:
- 1.1
-
getUnparseableOnly
-
getVersionMadeBy
public int getVersionMadeBy()Gets the "version made by" field.- Returns:
- "version made by" field
- Since:
- 1.11
-
getVersionRequired
public int getVersionRequired()Gets the "version required to expand" field.- Returns:
- "version required to expand" field
- Since:
- 1.11
-
hashCode
public int hashCode()Gets the hash code of the entry. This uses the name as the hash code. -
internalAddExtraField
-
internalRemoveExtraField
-
internalSetLastModifiedTime
-
isDirectory
public boolean isDirectory()Is this entry a directory?- Specified by:
isDirectoryin interfaceArchiveEntry- Overrides:
isDirectoryin classZipEntry- Returns:
- true if the entry is a directory
-
isStreamContiguous
public boolean isStreamContiguous()Description copied from interface:EntryStreamOffsetsTests whether the stream is contiguous, that is, not split among several archive parts, interspersed with control blocks, and so on.- Specified by:
isStreamContiguousin interfaceEntryStreamOffsets- Returns:
- true if stream is contiguous, false otherwise.
-
isUnixSymlink
public boolean isUnixSymlink()Returns true if this entry represents a unix symlink, in which case the entry's content contains the target path for the symlink.- Returns:
- true if the entry represents a unix symlink, false otherwise.
- Since:
- 1.5
-
mergeExtraFields
If there are no extra fields, use the given fields as new extra data - otherwise merge the fields assuming the existing fields and the new fields stem from different locations inside the archive.- Parameters:
f- the extra fields to mergelocal- whether the new fields originate from local data
-
parseExtraFields
private ZipExtraField[] parseExtraFields(byte[] data, boolean local, ExtraFieldParsingBehavior parsingBehavior) throws ZipException - Throws:
ZipException
-
removeExtraField
Remove an extra field.- Parameters:
type- the type of extra field to remove
-
removeUnparseableExtraFieldData
public void removeUnparseableExtraFieldData()Removes unparseable extra field data.- Since:
- 1.1
-
requiresExtraTimeFields
private boolean requiresExtraTimeFields() -
setAlignment
public void setAlignment(int alignment) Sets alignment for this entry.- Parameters:
alignment- requested alignment, 0 for default.- Since:
- 1.14
-
setAttributes
- Throws:
IOException
-
setCentralDirectoryExtra
public void setCentralDirectoryExtra(byte[] b) Sets the central directory part of extra fields.- Parameters:
b- an array of bytes to be parsed into extra fields
-
setCommentSource
Sets the source of the comment field value.- Parameters:
commentSource- source of the comment field value- Since:
- 1.16
-
setCreationTime
- Overrides:
setCreationTimein classZipEntry
-
setDataOffset
protected void setDataOffset(long dataOffset) Sets the data offset.- Parameters:
dataOffset- new value of data offset.
-
setDiskNumberStart
public void setDiskNumberStart(long diskNumberStart) The number of the split segment this entry starts at.- Parameters:
diskNumberStart- the number of the split segment this entry starts at.- Since:
- 1.20
-
setExternalAttributes
public void setExternalAttributes(long value) Sets the external file attributes.- Parameters:
value- anlongvalue
-
setExtra
protected void setExtra()UnfortunatelyZipOutputStreamseems to access the extra data directly, so overriding getExtra doesn't help - we need to modify super's data directly and on every update. -
setExtra
Parses the given bytes as extra field data and consumes any unparseable data as anUnparseableExtraFieldDatainstance.- Overrides:
setExtrain classZipEntry- Parameters:
extra- an array of bytes to be parsed into extra fields- Throws:
RuntimeException- if the bytes cannot be parsedRuntimeException- on error
-
setExtraFields
Replaces all currently attached extra fields with the new array.- Parameters:
fields- an array of extra fields
-
setExtraTimeFields
private void setExtraTimeFields() -
setGeneralPurposeBit
Sets the "general purpose bit" field.- Parameters:
generalPurposeBit- the general purpose bit- Since:
- 1.1
-
setInternalAttributes
public void setInternalAttributes(int internalAttributes) Sets the internal file attributes.- Parameters:
internalAttributes- anintvalue
-
setLastAccessTime
- Overrides:
setLastAccessTimein classZipEntry
-
setLastModifiedTime
- Overrides:
setLastModifiedTimein classZipEntry
-
setLocalHeaderOffset
protected void setLocalHeaderOffset(long localHeaderOffset) -
setMethod
public void setMethod(int method) Sets the compression method of this entry. -
setName
Sets the name of the entry.- Parameters:
name- the name to use
-
setName
Sets the name using the raw bytes and the string created from it by guessing or using the configured encoding.- Parameters:
name- the name to use created from the raw bytes using the guessed or configured encodingrawName- the bytes originally read as name from the archive- Since:
- 1.2
-
setNameSource
Sets the source of the name field value.- Parameters:
nameSource- source of the name field value- Since:
- 1.16
-
setPlatform
protected void setPlatform(int platform) Sets the platform (UNIX or FAT).- Parameters:
platform- anintvalue - 0 is FAT, 3 is UNIX
-
setRawFlag
public void setRawFlag(int rawFlag) Sets the content of the flags field.- Parameters:
rawFlag- content of the flags field- Since:
- 1.11
-
setSize
public void setSize(long size) Sets the uncompressed size of the entry data.- Overrides:
setSizein classZipEntry- Parameters:
size- the uncompressed size in bytes- Throws:
IllegalArgumentException- if the specified size is less than 0
-
setStreamContiguous
protected void setStreamContiguous(boolean isStreamContiguous) -
setTime
Sets the modification time of the entry.- Parameters:
fileTime- the entry modification time.- Since:
- 1.21
-
setTime
public void setTime(long timeEpochMillis) Override to work around bug JDK-8130914
-
setUnixMode
public void setUnixMode(int mode) Sets UNIX permissions in a way that is understood by Info-Zip's unzip command.- Parameters:
mode- anintvalue
-
setVersionMadeBy
public void setVersionMadeBy(int versionMadeBy) Sets the "version made by" field.- Parameters:
versionMadeBy- "version made by" field- Since:
- 1.11
-
setVersionRequired
public void setVersionRequired(int versionRequired) Sets the "version required to expand" field.- Parameters:
versionRequired- "version required to expand" field- Since:
- 1.11
-
updateTimeFieldsFromExtraFields
private void updateTimeFieldsFromExtraFields() -
updateTimeFromExtendedTimestampField
private void updateTimeFromExtendedTimestampField()Workaround for the fact that, as of Java 17,ZipEntrydoes not properly modify the entry'sxdostimefield, only settingmtime. While this is not strictly necessary, it's better to maintain the same behavior between this and the NTFS field. -
updateTimeFromNtfsField
private void updateTimeFromNtfsField()Workaround for the fact that, as of Java 17,ZipEntryparses NTFS timestamps with a maximum precision of microseconds, which is lower than the 100ns precision provided by this extra field.
-