public class ArArchiveInputStream extends ArchiveInputStream
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
BSD_LONGNAME_PATTERN |
(package private) static java.lang.String |
BSD_LONGNAME_PREFIX |
private static int |
BSD_LONGNAME_PREFIX_LEN |
private boolean |
closed |
private ArArchiveEntry |
currentEntry |
private long |
entryOffset |
private byte[] |
fileModeBuf |
private static java.lang.String |
GNU_LONGNAME_PATTERN |
private static java.lang.String |
GNU_STRING_TABLE_NAME |
private byte[] |
idBuf |
private java.io.InputStream |
input |
private byte[] |
lastModifiedBuf |
private byte[] |
lengthBuf |
private byte[] |
nameBuf |
private byte[] |
namebuffer |
private long |
offset |
Constructor and Description |
---|
ArArchiveInputStream(java.io.InputStream pInput)
Constructs an Ar input stream with the referenced stream
|
Modifier and Type | Method and Description |
---|---|
private int |
asInt(byte[] byteArray) |
private int |
asInt(byte[] byteArray,
boolean treatBlankAsZero) |
private int |
asInt(byte[] byteArray,
int base) |
private int |
asInt(byte[] byteArray,
int base,
boolean treatBlankAsZero) |
private long |
asLong(byte[] byteArray) |
void |
close() |
private java.lang.String |
getBSDLongName(java.lang.String bsdLongName)
Reads the real name from the current stream assuming the very
first bytes to be read are the real file name.
|
private java.lang.String |
getExtendedName(int offset)
Get an extended name from the GNU extended name buffer.
|
ArArchiveEntry |
getNextArEntry()
Returns the next AR entry in this stream.
|
ArchiveEntry |
getNextEntry()
Returns the next Archive Entry in this Stream.
|
private static boolean |
isBSDLongName(java.lang.String name)
Does the name look like it is a long name (or a name containing
spaces) as encoded by BSD ar?
|
private boolean |
isGNULongName(java.lang.String name)
Does the name look like it is a long name (or a name containing
spaces) as encoded by SVR4/GNU ar?
|
private static boolean |
isGNUStringTable(java.lang.String name)
Is this the name of the "Archive String Table" as used by
SVR4/GNU to store long file names?
|
static boolean |
matches(byte[] signature,
int length)
Checks if the signature matches ASCII "!<arch>" followed by a single LF
control character
|
int |
read(byte[] b,
int off,
int len) |
private ArArchiveEntry |
readGNUStringTable(byte[] length)
Reads the GNU archive String Table.
|
canReadEntryData, count, count, getBytesRead, getCount, pushedBackBytes, read
private final java.io.InputStream input
private long offset
private boolean closed
private ArArchiveEntry currentEntry
private byte[] namebuffer
private long entryOffset
private final byte[] nameBuf
private final byte[] lastModifiedBuf
private final byte[] idBuf
private final byte[] fileModeBuf
private final byte[] lengthBuf
static final java.lang.String BSD_LONGNAME_PREFIX
private static final int BSD_LONGNAME_PREFIX_LEN
private static final java.lang.String BSD_LONGNAME_PATTERN
private static final java.lang.String GNU_STRING_TABLE_NAME
private static final java.lang.String GNU_LONGNAME_PATTERN
public ArArchiveInputStream(java.io.InputStream pInput)
pInput
- the ar input streampublic ArArchiveEntry getNextArEntry() throws java.io.IOException
java.io.IOException
- if the entry could not be readprivate java.lang.String getExtendedName(int offset) throws java.io.IOException
offset
- pointer to entry within the bufferjava.io.IOException
- if name not found or buffer not set upprivate long asLong(byte[] byteArray)
private int asInt(byte[] byteArray)
private int asInt(byte[] byteArray, boolean treatBlankAsZero)
private int asInt(byte[] byteArray, int base)
private int asInt(byte[] byteArray, int base, boolean treatBlankAsZero)
public ArchiveEntry getNextEntry() throws java.io.IOException
ArchiveInputStream
getNextEntry
in class ArchiveInputStream
null
if there are no more entriesjava.io.IOException
- if the next entry could not be readpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public static boolean matches(byte[] signature, int length)
signature
- the bytes to checklength
- the number of bytes to checkprivate static boolean isBSDLongName(java.lang.String name)
From the FreeBSD ar(5) man page:
BSD In the BSD variant, names that are shorter than 16 characters and without embedded spaces are stored directly in this field. If a name has an embedded space, or if it is longer than 16 characters, then the string "#1/" followed by the decimal represen- tation of the length of the file name is placed in this field. The actual file name is stored immedi- ately after the archive header. The content of the archive member follows the file name. The ar_size field of the header (see below) will then hold the sum of the size of the file name and the size of the member.
private java.lang.String getBSDLongName(java.lang.String bsdLongName) throws java.io.IOException
java.io.IOException
isBSDLongName(java.lang.String)
private static boolean isGNUStringTable(java.lang.String name)
GNU ar stores multiple extended filenames in the data section of a file with the name "//", this record is referred to by future headers.
A header references an extended filename by storing a "/" followed by a decimal offset to the start of the filename in the extended filename data section.
The format of the "//" file itself is simply a list of the long filenames, each separated by one or more LF characters. Note that the decimal offsets are number of characters, not line or string number within the "//" file.
private ArArchiveEntry readGNUStringTable(byte[] length) throws java.io.IOException
java.io.IOException
isGNUStringTable(java.lang.String)
private boolean isGNULongName(java.lang.String name)
isGNUStringTable(java.lang.String)