Class CentralDirectoryHeader

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class CentralDirectoryHeader
    extends java.lang.Object
    implements java.lang.Cloneable
    The Central Directory Header contains information about files stored in the zip. Instances of this class contain information for files that already are in the zip and, for which the data was read from the Central Directory. But some instances of this class are used for new files. Because instances of this class can refer to files not yet on the zip, some of the fields may not be filled in, or may be filled in with default values.

    Because compression decision is done lazily, some data is stored with futures.

    • Method Detail

      • getName

        public java.lang.String getName()
        Obtains the name of the file.
        Returns:
        the name
      • getUncompressedSize

        public long getUncompressedSize()
        Obtains the size of the uncompressed file.
        Returns:
        the size of the file
      • getCrc32

        public long getCrc32()
        Obtains the CRC32 of the data.
        Returns:
        the CRC32, 0 if not yet computed
      • getMadeBy

        public long getMadeBy()
        Obtains the code of the program that made the zip.
        Returns:
        the code
      • getGpBit

        public com.android.tools.build.apkzlib.zip.GPFlags getGpBit()
        Obtains the general-purpose bit flag.
        Returns:
        the bit flag
      • getLastModTime

        public long getLastModTime()
        Obtains the last modification time of the entry.
        Returns:
        the last modification time in MS-DOS format (see MsDosDateTimeUtils.packTime(long))
      • getLastModDate

        public long getLastModDate()
        Obtains the last modification date of the entry.
        Returns:
        the last modification date in MS-DOS format (see MsDosDateTimeUtils.packDate(long))
      • getExtraField

        public ExtraField getExtraField()
        Obtains the data in the extra field.
        Returns:
        the data (returns an empty array if there is none)
      • setExtraField

        public void setExtraField​(ExtraField extraField)
        Sets the data in the extra field.
        Parameters:
        extraField - the data to set
      • getComment

        public byte[] getComment()
        Obtains the entry's comment.
        Returns:
        the comment (returns an empty array if there is no comment)
      • getInternalAttributes

        public long getInternalAttributes()
        Obtains the entry's internal attributes.
        Returns:
        the entry's internal attributes
      • getExternalAttributes

        public long getExternalAttributes()
        Obtains the entry's external attributes.
        Returns:
        the entry's external attributes
      • getOffset

        public long getOffset()
        Obtains the offset in the zip file where this entry's data is.
        Returns:
        the offset or -1 if the file has no data in the zip and, therefore, data is stored in memory
      • getEncodedFileName

        public byte[] getEncodedFileName()
        Obtains the encoded file name.
        Returns:
        the encoded file name
      • clone

        protected CentralDirectoryHeader clone()
                                        throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • getCompressionInfo

        public java.util.concurrent.Future<CentralDirectoryHeaderCompressInfo> getCompressionInfo()
        Obtains the future with the compression information.
        Returns:
        the information
      • getCompressionInfoWithWait

        public CentralDirectoryHeaderCompressInfo getCompressionInfoWithWait()
                                                                      throws java.io.IOException
        Equivalent to getCompressionInfo().get() but masking the possible exceptions and guaranteeing non-null return.
        Returns:
        the result of the future
        Throws:
        java.io.IOException - failed to get the information