Class X000A_NTFS
java.lang.Object
org.apache.commons.compress.archivers.zip.X000A_NTFS
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprivate ZipEightByteIntegerprivate ZipEightByteIntegerprivate static final longprivate static final ZipShortprivate ZipEightByteIntegerprivate static final ZipShortprivate static final ZipShortFields inherited from interface org.apache.commons.compress.archivers.zip.ZipExtraField
EXTRAFIELD_HEADER_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ZipEightByteIntegerbooleanReturns the access time as a java.util.Date of this zip entry, or null if no such timestamp exists in the zip entry.Returns the "File last access time" of this zip entry as a ZipEightByteInteger object, orZipEightByteInteger.ZEROif no such timestamp exists in the zip entry.byte[]The actual data to put into central directory data - without Header-ID or length specifier.Length of the extra field in the local file data - without Header-ID or length specifier.Returns the create time as a a java.util.Date of this zip entry, or null if no such timestamp exists in the zip entry.Returns the "File creation time" of this zip entry as a ZipEightByteInteger object, orZipEightByteInteger.ZEROif no such timestamp exists in the zip entry.The Header-ID.byte[]The actual data to put into local file data - without Header-ID or length specifier.Length of the extra field in the local file data - without Header-ID or length specifier.Returns the modify time as a java.util.Date of this zip entry, or null if no such timestamp exists in the zip entry.Returns 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.voidSets the access time as a java.util.Date of this zip entry.voidSets the File last access time of this zip entry using a ZipEightByteInteger object.voidSets the create time as a java.util.Date of this zip entry.voidSets the File creation time of this zip entry using a ZipEightByteInteger object.voidSets the modify time as a java.util.Date of this zip entry.voidSets the File last modification time of this zip entry using a ZipEightByteInteger object.toString()Returns a String representation of this class useful for debugging purposes.private static Date
-
Field Details
-
HEADER_ID
-
TIME_ATTR_TAG
-
TIME_ATTR_SIZE
-
modifyTime
-
accessTime
-
createTime
-
EPOCH_OFFSET
private static final long EPOCH_OFFSET- See Also:
-
-
Constructor Details
-
X000A_NTFS
public X000A_NTFS()
-
-
Method Details
-
getHeaderId
The Header-ID.- Specified by:
getHeaderIdin interfaceZipExtraField- Returns:
- the value for the header id for this extrafield
-
getLocalFileDataLength
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
-
getCentralDirectoryLength
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
-
getLocalFileDataData
public byte[] getLocalFileDataData()The actual data to put into local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataDatain interfaceZipExtraField- Returns:
- get the data
-
getCentralDirectoryData
public byte[] getCentralDirectoryData()The actual data to put into central directory data - without Header-ID or length specifier.- Specified by:
getCentralDirectoryDatain interfaceZipExtraField- Returns:
- the central directory data
-
parseFromLocalFileData
Populate 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:
ZipException- on error
-
parseFromCentralDirectoryData
public void parseFromCentralDirectoryData(byte[] buffer, int offset, int length) throws ZipException Doesn'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:
ZipException- on error
-
getModifyTime
Returns 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
-
getAccessTime
Returns 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
-
getCreateTime
Returns 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
-
getModifyJavaTime
Returns the modify time as a java.util.Date of this zip entry, or null if no such timestamp exists in the zip entry.- Returns:
- modify time as java.util.Date or null.
-
getAccessJavaTime
Returns the access time as a java.util.Date of this zip entry, or null if no such timestamp exists in the zip entry.- Returns:
- access time as java.util.Date or null.
-
getCreateJavaTime
Returns the create time as a a java.util.Date of this zip entry, or null if no such timestamp exists in the zip entry.- Returns:
- create time as java.util.Date or null.
-
setModifyTime
Sets the File last modification time of this zip entry using a ZipEightByteInteger object.- Parameters:
t- ZipEightByteInteger of the modify time
-
setAccessTime
Sets the File last access time of this zip entry using a ZipEightByteInteger object.- Parameters:
t- ZipEightByteInteger of the access time
-
setCreateTime
Sets the File creation time of this zip entry using a ZipEightByteInteger object.- Parameters:
t- ZipEightByteInteger of the create time
-
setModifyJavaTime
Sets the modify time as a java.util.Date of this zip entry.- Parameters:
d- modify time as java.util.Date
-
setAccessJavaTime
Sets the access time as a java.util.Date of this zip entry.- Parameters:
d- access time as java.util.Date
-
setCreateJavaTime
Sets the create time as a java.util.Date of this zip entry. Supplied value is truncated to per-second precision (milliseconds zeroed-out).
Note: the setters for flags and timestamps are decoupled. Even if the timestamp is not-null, it will only be written out if the corresponding bit in the flags is also set.
- Parameters:
d- create time as java.util.Date
-
toString
Returns a String representation of this class useful for debugging purposes. -
equals
-
hashCode
public int hashCode() -
reset
private void reset()Reset state back to newly constructed state. Helps us make sure parse() calls always generate clean results. -
readTimeAttr
private void readTimeAttr(byte[] data, int offset, int length) -
dateToZip
-
zipToDate
-