Class 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
    • Constructor Summary

      Constructors 
      Constructor Description
      X000A_NTFS()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.nio.file.attribute.FileTime getAccessFileTime()
      Gets the access time as a FileTime of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
      java.util.Date getAccessJavaTime()
      Gets the access time as a java.util.Date of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
      ZipEightByteInteger getAccessTime()
      Gets the "File last access time" of this ZIP entry as a ZipEightByteInteger object, or ZipEightByteInteger.ZERO if 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.
      ZipShort getCentralDirectoryLength()
      Gets the length of the extra field in the local file data - without Header-ID or length specifier.
      java.nio.file.attribute.FileTime getCreateFileTime()
      Gets the create time as a FileTime of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
      java.util.Date getCreateJavaTime()
      Gets the create time as a java.util.Date of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
      ZipEightByteInteger getCreateTime()
      Gets the "File creation time" of this ZIP entry as a ZipEightByteInteger object, or ZipEightByteInteger.ZERO if no such timestamp exists in the ZIP entry.
      ZipShort getHeaderId()
      Gets the Header-ID.
      byte[] getLocalFileDataData()
      Gets the actual data to put into local file data - without Header-ID or length specifier.
      ZipShort getLocalFileDataLength()
      Gets the length of the extra field in the local file data - without Header-ID or length specifier.
      java.nio.file.attribute.FileTime getModifyFileTime()
      Gets the modify time as a FileTime of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
      java.util.Date getModifyJavaTime()
      Gets the modify time as a java.util.Date of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
      ZipEightByteInteger getModifyTime()
      Gets the "File last modification time" of this ZIP entry as a ZipEightByteInteger object, or ZipEightByteInteger.ZERO if no such timestamp exists in the ZIP entry.
      int hashCode()  
      void parseFromCentralDirectoryData​(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.
      void parseFromLocalFileData​(byte[] data, int offset, int length)
      Populate data from this array as if it was in local file data.
      void setAccessFileTime​(java.nio.file.attribute.FileTime time)
      Sets the access time.
      void setAccessJavaTime​(java.util.Date d)
      Sets the access time as a java.util.Date of this ZIP entry.
      void setAccessTime​(ZipEightByteInteger t)
      Sets the File last access time of this ZIP entry using a ZipEightByteInteger object.
      void setCreateFileTime​(java.nio.file.attribute.FileTime time)
      Sets the create time.
      void setCreateJavaTime​(java.util.Date d)
      Sets the create time as a java.util.Date of this ZIP entry.
      void setCreateTime​(ZipEightByteInteger t)
      Sets the File creation time of this ZIP entry using a ZipEightByteInteger object.
      void setModifyFileTime​(java.nio.file.attribute.FileTime time)
      Sets the modify time.
      void setModifyJavaTime​(java.util.Date d)
      Sets the modify time as a java.util.Date of this ZIP entry.
      void setModifyTime​(ZipEightByteInteger t)
      Sets the File last modification time of this ZIP entry using a ZipEightByteInteger object.
      java.lang.String toString()
      Returns a String representation of this class useful for debugging purposes.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • HEADER_ID

        public static final ZipShort HEADER_ID
        The header ID for this extra field.
        Since:
        1.23
    • Constructor Detail

      • X000A_NTFS

        public X000A_NTFS()
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • getAccessFileTime

        public java.nio.file.attribute.FileTime getAccessFileTime()
        Gets the access time as a FileTime of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
        Returns:
        access time as a FileTime or null.
        Since:
        1.23
      • getAccessJavaTime

        public java.util.Date getAccessJavaTime()
        Gets 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.
      • getAccessTime

        public ZipEightByteInteger getAccessTime()
        Gets the "File last access time" of this ZIP entry as a ZipEightByteInteger object, or ZipEightByteInteger.ZERO if 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:
        getCentralDirectoryData in interface ZipExtraField
        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:
        getCentralDirectoryLength in interface ZipExtraField
        Returns:
        a ZipShort for the length of the data of this extra field
      • getCreateFileTime

        public java.nio.file.attribute.FileTime getCreateFileTime()
        Gets the create time as a FileTime of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
        Returns:
        create time as a FileTime or null.
        Since:
        1.23
      • getCreateJavaTime

        public java.util.Date getCreateJavaTime()
        Gets the create time as 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.
      • getCreateTime

        public ZipEightByteInteger getCreateTime()
        Gets the "File creation time" of this ZIP entry as a ZipEightByteInteger object, or ZipEightByteInteger.ZERO if no such timestamp exists in the ZIP entry.
        Returns:
        File creation time
      • getHeaderId

        public ZipShort getHeaderId()
        Gets the Header-ID.
        Specified by:
        getHeaderId in interface ZipExtraField
        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:
        getLocalFileDataData in interface ZipExtraField
        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:
        getLocalFileDataLength in interface ZipExtraField
        Returns:
        a ZipShort for the length of the data of this extra field
      • getModifyFileTime

        public java.nio.file.attribute.FileTime getModifyFileTime()
        Gets the modify time as a FileTime of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
        Returns:
        modify time as a FileTime or null.
        Since:
        1.23
      • getModifyJavaTime

        public java.util.Date getModifyJavaTime()
        Gets 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.
      • getModifyTime

        public ZipEightByteInteger getModifyTime()
        Gets the "File last modification time" of this ZIP entry as a ZipEightByteInteger object, or ZipEightByteInteger.ZERO if no such timestamp exists in the ZIP entry.
        Returns:
        File last modification time
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • parseFromCentralDirectoryData

        public void parseFromCentralDirectoryData​(byte[] buffer,
                                                  int offset,
                                                  int length)
                                           throws java.util.zip.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:
        parseFromCentralDirectoryData in interface ZipExtraField
        Parameters:
        buffer - the buffer to read data from
        offset - offset into buffer to read data
        length - 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.ZipException
        Populate data from this array as if it was in local file data.
        Specified by:
        parseFromLocalFileData in interface ZipExtraField
        Parameters:
        data - an array of bytes
        offset - the start offset
        length - the number of bytes in the array from offset
        Throws:
        java.util.zip.ZipException - on error
      • setAccessFileTime

        public void setAccessFileTime​(java.nio.file.attribute.FileTime time)
        Sets the access time.
        Parameters:
        time - access time as a FileTime
        Since:
        1.23
      • setAccessJavaTime

        public void setAccessJavaTime​(java.util.Date d)
        Sets the access time as a java.util.Date of this ZIP entry.
        Parameters:
        d - access time as java.util.Date
      • 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 a FileTime
        Since:
        1.23
      • setCreateJavaTime

        public void setCreateJavaTime​(java.util.Date d)

        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
      • 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 a FileTime
        Since:
        1.23
      • setModifyJavaTime

        public void setModifyJavaTime​(java.util.Date d)
        Sets the modify time as a java.util.Date of this ZIP entry.
        Parameters:
        d - modify time as java.util.Date
      • 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:
        toString in class java.lang.Object
        Returns:
        A String representation of this class useful for debugging purposes.