Class ArArchiveEntry
java.lang.Object
org.apache.commons.compress.archivers.ar.ArArchiveEntry
- All Implemented Interfaces:
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final intstatic final StringThe header for each entryprivate final longprivate final longprivate final intprivate final StringSVR4/GNU adds a trailing / to names; BSD does not.static final StringThe trailer for each entry0x60 0x0Aprivate final intFields inherited from interface org.apache.commons.compress.archivers.ArchiveEntry
SIZE_UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionArArchiveEntry(File inputFile, String entryName) Creates a new instance using the attributes of the given fileArArchiveEntry(String name, long length) Constructs a new instance using a couple of default values.ArArchiveEntry(String name, long length, int userId, int groupId, int mode, long lastModified) Constructs a new instance.ArArchiveEntry(Path inputPath, String entryName, LinkOption... options) Creates a new instance using the attributes of the given file -
Method Summary
Modifier and TypeMethodDescriptionbooleanintGets the group ID.longGets the last modified time in seconds since the epoch.Gets the last modified date of this entry.longGets the length.intgetMode()Gets the mode.getName()Gets the name of the entry in this archive.longgetSize()Gets the uncompressed size of this entry.intGets the user ID.inthashCode()booleanTests whether this entry refers to a directory (true).Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.compress.archivers.ArchiveEntry
resolveIn
-
Field Details
-
HEADER
The header for each entry- See Also:
-
TRAILER
The trailer for each entry0x60 0x0A- See Also:
-
DEFAULT_MODE
private static final int DEFAULT_MODE- See Also:
-
name
SVR4/GNU adds a trailing / to names; BSD does not. They also vary in how names longer than 16 characters are represented. (Not yet fully supported by this implementation) -
userId
private final int userId -
groupId
private final int groupId -
mode
private final int mode -
lastModified
private final long lastModified -
length
private final long length
-
-
Constructor Details
-
ArArchiveEntry
Creates a new instance using the attributes of the given file- Parameters:
inputFile- the file to create an entry fromentryName- the name of the entry
-
ArArchiveEntry
Creates a new instance using the attributes of the given file- Parameters:
inputPath- the file to create an entry fromentryName- the name of the entryoptions- options indicating how symbolic links are handled.- Throws:
IOException- if an I/O error occurs.- Since:
- 1.21
-
ArArchiveEntry
Constructs 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 entrylength- length of the entry in bytes
-
ArArchiveEntry
public ArArchiveEntry(String name, long length, int userId, int groupId, int mode, long lastModified) Constructs a new instance.- Parameters:
name- name of the entrylength- length of the entry in bytesuserId- numeric user idgroupId- numeric group idmode- file modelastModified- last modified time in seconds since the epoch
-
-
Method Details
-
equals
-
getGroupId
public int getGroupId()Gets the group ID.- Returns:
- the group ID.
-
getLastModified
public long getLastModified()Gets the last modified time in seconds since the epoch.- Returns:
- the last modified date.
-
getLastModifiedDate
Description copied from interface:ArchiveEntryGets the last modified date of this entry.- Specified by:
getLastModifiedDatein interfaceArchiveEntry- Returns:
- the last modified date of this entry.
-
getLength
public long getLength()Gets the length.- Returns:
- the length.
-
getMode
public int getMode()Gets the mode.- Returns:
- the mode.
-
getName
Description copied from interface:ArchiveEntryGets 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:
getNamein interfaceArchiveEntry- Returns:
- The name of this entry in the archive.
-
getSize
public long getSize()Description copied from interface:ArchiveEntryGets the uncompressed size of this entry. May be -1 (SIZE_UNKNOWN) if the size is unknown- Specified by:
getSizein interfaceArchiveEntry- Returns:
- the uncompressed size of this entry.
-
getUserId
public int getUserId()Gets the user ID.- Returns:
- the user ID.
-
hashCode
public int hashCode() -
isDirectory
public boolean isDirectory()Description copied from interface:ArchiveEntryTests whether this entry refers to a directory (true).- Specified by:
isDirectoryin interfaceArchiveEntry- Returns:
- true if this entry refers to a directory.
-