- java.lang.Object
-
- kala.compress.archivers.zip.X000A_NTFS
-
- All Implemented Interfaces:
ZipExtraField
public class X000A_NTFS extends java.lang.Object implements ZipExtraField
NTFS extra field that was thought to store various attributes but in reality only stores timestamps.4.5.5 -NTFS Extra Field (0x000a): The following is the layout of the NTFS attributes "extra" block. (Note: At this time the Mtime, Atime and Ctime values MAY be used on any WIN32 system.) Note: all fields stored in Intel low-byte/high-byte order. Value Size Description ----- ---- ----------- (NTFS) 0x000a 2 bytes Tag for this "extra" block type TSize 2 bytes Size of the total "extra" block Reserved 4 bytes Reserved for future use Tag1 2 bytes NTFS attribute tag value #1 Size1 2 bytes Size of attribute #1, in bytes (var) Size1 Attribute #1 data . . . TagN 2 bytes NTFS attribute tag value #N SizeN 2 bytes Size of attribute #N, in bytes (var) SizeN Attribute #N data For NTFS, values for Tag1 through TagN are as follows: (currently only one set of attributes is defined for NTFS) Tag Size Description ----- ---- ----------- 0x0001 2 bytes Tag for attribute #1 Size1 2 bytes Size of attribute #1, in bytes Mtime 8 bytes File last modification time Atime 8 bytes File last access time Ctime 8 bytes File creation time- Since:
- 1.11
-
-
Field Summary
Fields Modifier and Type Field Description private ZipEightByteIntegeraccessTimeprivate ZipEightByteIntegercreateTimestatic ZipShortHEADER_IDThe header ID for this extra field.private ZipEightByteIntegermodifyTimeprivate static ZipShortTIME_ATTR_SIZEprivate static ZipShortTIME_ATTR_TAG-
Fields inherited from interface kala.compress.archivers.zip.ZipExtraField
EXTRAFIELD_HEADER_SIZE
-
-
Constructor Summary
Constructors Constructor Description X000A_NTFS()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)private static ZipEightByteIntegerfileTimeToZip(java.nio.file.attribute.FileTime time)java.nio.file.attribute.FileTimegetAccessFileTime()Gets the access time as aFileTimeof this ZIP entry, or null if no such timestamp exists in the ZIP entry.ZipEightByteIntegergetAccessTime()Gets the "File last access time" of this ZIP entry as a ZipEightByteInteger object, orZipEightByteInteger.ZEROif no such timestamp exists in the ZIP entry.byte[]getCentralDirectoryData()Gets the actual data to put into central directory data - without Header-ID or length specifier.ZipShortgetCentralDirectoryLength()Gets the length of the extra field in the local file data - without Header-ID or length specifier.java.nio.file.attribute.FileTimegetCreateFileTime()Gets the create time as aFileTimeof this ZIP entry, or null if no such timestamp exists in the ZIP entry.ZipEightByteIntegergetCreateTime()Gets the "File creation time" of this ZIP entry as a ZipEightByteInteger object, orZipEightByteInteger.ZEROif no such timestamp exists in the ZIP entry.ZipShortgetHeaderId()Gets the Header-ID.byte[]getLocalFileDataData()Gets the actual data to put into local file data - without Header-ID or length specifier.ZipShortgetLocalFileDataLength()Gets the length of the extra field in the local file data - without Header-ID or length specifier.java.nio.file.attribute.FileTimegetModifyFileTime()Gets the modify time as aFileTimeof this ZIP entry, or null if no such timestamp exists in the ZIP entry.ZipEightByteIntegergetModifyTime()Gets the "File last modification time" of this ZIP entry as a ZipEightByteInteger object, orZipEightByteInteger.ZEROif no such timestamp exists in the ZIP entry.inthashCode()voidparseFromCentralDirectoryData(byte[] buffer, int offset, int length)Doesn't do anything special since this class always uses the same parsing logic for both central directory and local file data.voidparseFromLocalFileData(byte[] data, int offset, int length)Populate data from this array as if it was in local file data.private voidreadTimeAttr(byte[] data, int offset, int length)private voidreset()Reset state back to newly constructed state.voidsetAccessFileTime(java.nio.file.attribute.FileTime time)Sets the access time.voidsetAccessTime(ZipEightByteInteger t)Sets the File last access time of this ZIP entry using a ZipEightByteInteger object.voidsetCreateFileTime(java.nio.file.attribute.FileTime time)Sets the create time.voidsetCreateTime(ZipEightByteInteger t)Sets the File creation time of this ZIP entry using a ZipEightByteInteger object.voidsetModifyFileTime(java.nio.file.attribute.FileTime time)Sets the modify time.voidsetModifyTime(ZipEightByteInteger t)Sets the File last modification time of this ZIP entry using a ZipEightByteInteger object.java.lang.StringtoString()Returns a String representation of this class useful for debugging purposes.private static java.nio.file.attribute.FileTimezipToFileTime(ZipEightByteInteger z)
-
-
-
Field Detail
-
HEADER_ID
public static final ZipShort HEADER_ID
The header ID for this extra field.- Since:
- 1.23
-
TIME_ATTR_TAG
private static final ZipShort TIME_ATTR_TAG
-
TIME_ATTR_SIZE
private static final ZipShort TIME_ATTR_SIZE
-
modifyTime
private ZipEightByteInteger modifyTime
-
accessTime
private ZipEightByteInteger accessTime
-
createTime
private ZipEightByteInteger createTime
-
-
Method Detail
-
fileTimeToZip
private static ZipEightByteInteger fileTimeToZip(java.nio.file.attribute.FileTime time)
-
zipToFileTime
private static java.nio.file.attribute.FileTime zipToFileTime(ZipEightByteInteger z)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
getAccessFileTime
public java.nio.file.attribute.FileTime getAccessFileTime()
Gets the access time as aFileTimeof this ZIP entry, or null if no such timestamp exists in the ZIP entry.- Returns:
- access time as a
FileTimeor null. - Since:
- 1.23
-
getAccessTime
public ZipEightByteInteger getAccessTime()
Gets the "File last access time" of this ZIP entry as a ZipEightByteInteger object, orZipEightByteInteger.ZEROif no such timestamp exists in the ZIP entry.- Returns:
- File last access time
-
getCentralDirectoryData
public byte[] getCentralDirectoryData()
Gets the actual data to put into central directory data - without Header-ID or length specifier.- Specified by:
getCentralDirectoryDatain interfaceZipExtraField- Returns:
- the central directory data
-
getCentralDirectoryLength
public ZipShort getCentralDirectoryLength()
Gets the length of the extra field in the local file data - without Header-ID or length specifier.For X5455 the central length is often smaller than the local length, because central cannot contain access or create timestamps.
- Specified by:
getCentralDirectoryLengthin interfaceZipExtraField- Returns:
- a
ZipShortfor the length of the data of this extra field
-
getCreateFileTime
public java.nio.file.attribute.FileTime getCreateFileTime()
Gets the create time as aFileTimeof this ZIP entry, or null if no such timestamp exists in the ZIP entry.- Returns:
- create time as a
FileTimeor null. - Since:
- 1.23
-
getCreateTime
public ZipEightByteInteger getCreateTime()
Gets the "File creation time" of this ZIP entry as a ZipEightByteInteger object, orZipEightByteInteger.ZEROif no such timestamp exists in the ZIP entry.- Returns:
- File creation time
-
getHeaderId
public ZipShort getHeaderId()
Gets the Header-ID.- Specified by:
getHeaderIdin interfaceZipExtraField- Returns:
- the value for the header id for this extrafield
-
getLocalFileDataData
public byte[] getLocalFileDataData()
Gets the actual data to put into local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataDatain interfaceZipExtraField- Returns:
- get the data
-
getLocalFileDataLength
public ZipShort getLocalFileDataLength()
Gets the length of the extra field in the local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataLengthin interfaceZipExtraField- Returns:
- a
ZipShortfor the length of the data of this extra field
-
getModifyFileTime
public java.nio.file.attribute.FileTime getModifyFileTime()
Gets the modify time as aFileTimeof this ZIP entry, or null if no such timestamp exists in the ZIP entry.- Returns:
- modify time as a
FileTimeor null. - Since:
- 1.23
-
getModifyTime
public ZipEightByteInteger getModifyTime()
Gets the "File last modification time" of this ZIP entry as a ZipEightByteInteger object, orZipEightByteInteger.ZEROif no such timestamp exists in the ZIP entry.- Returns:
- File last modification time
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
parseFromCentralDirectoryData
public void parseFromCentralDirectoryData(byte[] buffer, int offset, int length) throws java.util.zip.ZipExceptionDoesn't do anything special since this class always uses the same parsing logic for both central directory and local file data.- Specified by:
parseFromCentralDirectoryDatain interfaceZipExtraField- Parameters:
buffer- the buffer to read data fromoffset- offset into buffer to read datalength- the length of data- Throws:
java.util.zip.ZipException- on error
-
parseFromLocalFileData
public void parseFromLocalFileData(byte[] data, int offset, int length) throws java.util.zip.ZipExceptionPopulate data from this array as if it was in local file data.- Specified by:
parseFromLocalFileDatain interfaceZipExtraField- Parameters:
data- an array of bytesoffset- the start offsetlength- the number of bytes in the array from offset- Throws:
java.util.zip.ZipException- on error
-
readTimeAttr
private void readTimeAttr(byte[] data, int offset, int length)
-
reset
private void reset()
Reset state back to newly constructed state. Helps us make sure parse() calls always generate clean results.
-
setAccessFileTime
public void setAccessFileTime(java.nio.file.attribute.FileTime time)
Sets the access time.- Parameters:
time- access time as aFileTime- Since:
- 1.23
-
setAccessTime
public void setAccessTime(ZipEightByteInteger t)
Sets the File last access time of this ZIP entry using a ZipEightByteInteger object.- Parameters:
t- ZipEightByteInteger of the access time
-
setCreateFileTime
public void setCreateFileTime(java.nio.file.attribute.FileTime time)
Sets the create time.- Parameters:
time- create time as aFileTime- Since:
- 1.23
-
setCreateTime
public void setCreateTime(ZipEightByteInteger t)
Sets the File creation time of this ZIP entry using a ZipEightByteInteger object.- Parameters:
t- ZipEightByteInteger of the create time
-
setModifyFileTime
public void setModifyFileTime(java.nio.file.attribute.FileTime time)
Sets the modify time.- Parameters:
time- modify time as aFileTime- Since:
- 1.23
-
setModifyTime
public void setModifyTime(ZipEightByteInteger t)
Sets the File last modification time of this ZIP entry using a ZipEightByteInteger object.- Parameters:
t- ZipEightByteInteger of the modify time
-
toString
public java.lang.String toString()
Returns a String representation of this class useful for debugging purposes.- Overrides:
toStringin classjava.lang.Object- Returns:
- A String representation of this class useful for debugging purposes.
-
-