Class ArArchiveEntry

  • All Implemented Interfaces:
    ArchiveEntry

    public class ArArchiveEntry
    extends java.lang.Object
    implements ArchiveEntry
    Represents an archive entry in the "ar" format. Each AR archive starts with "!<arch>" followed by a LF. After these 8 bytes the archive entries are listed. The format of an entry header is as it follows:
     START BYTE   END BYTE    NAME                    FORMAT      LENGTH
     0            15          File name               ASCII       16
     16           27          Modification timestamp  Decimal     12
     28           33          Owner ID                Decimal     6
     34           39          Group ID                Decimal     6
     40           47          File mode               Octal       8
     48           57          File size (bytes)       Decimal     10
     58           59          File magic              \140\012    2
     
    This specifies that an ar archive entry header contains 60 bytes. Due to the limitation of the file name length to 16 bytes GNU and BSD has their own variants of this format. Currently Commons Compress can read but not write the GNU variant. It fully supports the BSD variant.
    See Also:
    ar man page
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HEADER
      The header for each entry
      static java.lang.String TRAILER
      The trailer for each entry
    • Constructor Summary

      Constructors 
      Constructor Description
      ArArchiveEntry​(java.io.File inputFile, java.lang.String entryName)
      Creates a new instance using the attributes of the given file
      ArArchiveEntry​(java.lang.String name, long length)
      Create a new instance using a couple of default values.
      ArArchiveEntry​(java.lang.String name, long length, int userId, int groupId, int mode, long lastModified)
      Create a new instance.
      ArArchiveEntry​(java.nio.file.Path inputPath, java.lang.String entryName, java.nio.file.LinkOption... options)
      Creates a new instance using the attributes of the given file
    • Field Detail

      • HEADER

        public static final java.lang.String HEADER
        The header for each entry
        See Also:
        Constant Field Values
      • TRAILER

        public static final java.lang.String TRAILER
        The trailer for each entry
        See Also:
        Constant Field Values
    • Constructor Detail

      • ArArchiveEntry

        public ArArchiveEntry​(java.lang.String name,
                              long length)
        Create a new instance using a couple of default values.

        Sets userId and groupId to 0, the octal file mode to 644 and the last modified time to the current time.

        Parameters:
        name - name of the entry
        length - length of the entry in bytes
      • ArArchiveEntry

        public ArArchiveEntry​(java.lang.String name,
                              long length,
                              int userId,
                              int groupId,
                              int mode,
                              long lastModified)
        Create a new instance.
        Parameters:
        name - name of the entry
        length - length of the entry in bytes
        userId - numeric user id
        groupId - numeric group id
        mode - file mode
        lastModified - last modified time in seconds since the epoch
      • ArArchiveEntry

        public ArArchiveEntry​(java.io.File inputFile,
                              java.lang.String entryName)
        Creates a new instance using the attributes of the given file
        Parameters:
        inputFile - the file to create an entry from
        entryName - the name of the entry
      • ArArchiveEntry

        public ArArchiveEntry​(java.nio.file.Path inputPath,
                              java.lang.String entryName,
                              java.nio.file.LinkOption... options)
                       throws java.io.IOException
        Creates a new instance using the attributes of the given file
        Parameters:
        inputPath - the file to create an entry from
        entryName - the name of the entry
        options - options indicating how symbolic links are handled.
        Throws:
        java.io.IOException - if an I/O error occurs.
        Since:
        1.21
    • Method Detail

      • getSize

        public long getSize()
        Description copied from interface: ArchiveEntry
        Gets the uncompressed size of this entry. May be -1 (SIZE_UNKNOWN) if the size is unknown
        Specified by:
        getSize in interface ArchiveEntry
        Returns:
        the uncompressed size of this entry.
      • getName

        public java.lang.String getName()
        Description copied from interface: ArchiveEntry
        Gets the name of the entry in this archive. May refer to a file or directory or other item.

        This method returns the raw name as it is stored inside of the archive.

        Specified by:
        getName in interface ArchiveEntry
        Returns:
        The name of this entry in the archive.
      • getUserId

        public int getUserId()
      • getGroupId

        public int getGroupId()
      • getMode

        public int getMode()
      • getLastModified

        public long getLastModified()
        Last modified time in seconds since the epoch.
        Returns:
        the last modified date
      • getLastModifiedDate

        public java.util.Date getLastModifiedDate()
        Description copied from interface: ArchiveEntry
        Gets the last modified date of this entry.
        Specified by:
        getLastModifiedDate in interface ArchiveEntry
        Returns:
        the last modified date of this entry.
      • getLength

        public long getLength()
      • isDirectory

        public boolean isDirectory()
        Description copied from interface: ArchiveEntry
        Returns true if this entry refers to a directory.
        Specified by:
        isDirectory in interface ArchiveEntry
        Returns:
        true if this entry refers to a directory.
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object