Top Description Fields Constructors Methods
org.apache.commons.compress.archivers.dump

public Class DumpArchiveInputStream

extends ArchiveInputStream<DumpArchiveEntry>
Class Inheritance
Imports
java.io.EOFException, .IOException, .InputStream, java.util.Arrays, .BitSet, .HashMap, .Map, .PriorityQueue, .Queue, .Stack, org.apache.commons.compress.archivers.ArchiveException, .ArchiveInputStream, org.apache.commons.compress.archivers.zip.ZipEncoding, .ZipEncodingHelper, org.apache.commons.compress.utils.IOUtils

The DumpArchiveInputStream reads a UNIX dump archive as an InputStream. Methods are provided to position at each successive entry in the archive, and the read each entry as a normal input stream using read().

There doesn't seem to exist a hint on the encoding of string values in any piece documentation. Given the main purpose of dump/restore is backing up a system it seems very likely the format uses the current default encoding of the system.

Since
1.3

Field Summary

Modifier and TypeField and Description
private DumpArchiveEntry
private byte[]
private static final String
private long
private long
private long
private boolean
private boolean
private final Map<Integer, Dirent>
names

Map of ino -> dirent entry.

private static final String
private final Map<Integer, DumpArchiveEntry>
pending

Map of ino -> (directory) entry when we're missing one or more elements in the path.

private final Queue<DumpArchiveEntry>
queue

Queue of (directory) entries where we now have the full path.

protected TapeInputStream
private final byte[]
private int
private int
private final DumpArchiveSummary
private final ZipEncoding
zipEncoding

The encoding to use for file names and labels.

Constructor Summary

AccessConstructor and Description
public
DumpArchiveInputStream(final InputStream
stream to read from
is
)

Constructor using the platform's default encoding for file names.

public
DumpArchiveInputStream(final InputStream
stream to read from
is
,
final String
the encoding to use for file names, use null for the platform's default encoding
encoding
)

Constructs a new instance.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes the stream for this entry.
public long
getBytesRead()

Overrides org.apache.commons.compress.archivers.ArchiveInputStream.getBytesRead.

Gets the current number of bytes read from this stream.
public int
getCount()

Overrides org.apache.commons.compress.archivers.ArchiveInputStream.getCount.

Deprecated
Gets the current number of bytes read from this stream.
public DumpArchiveEntry

Returns:

the next entry
getNextDumpEntry
()

Deprecated Use getNextEntry().
Reads the next entry.
public DumpArchiveEntry
getNextEntry()

Implements abstract org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Gets the next Archive Entry in this Stream.
private String

Returns:

full path for specified archive entry, or null if there's a gap.
getPath
(final DumpArchiveEntry entry)

Gets full path for specified archive entry, or null if there's a gap.

public DumpArchiveSummary

Returns:

the summary
getSummary
()

Gets the archive summary information.

public static boolean

Returns:

whether the buffer seems to contain dump data
matches
(final byte[]
data to match
buffer
,
final int
length of data
length
)

Look at the first few bytes of the file to decide if it's a dump archive.

public int

Returns:

The number of bytes read, or -1 at EOF.
read
(final byte[]
The buffer into which to place bytes read.
buf
,
int
The offset at which to place bytes read.
off
,
int
The number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads bytes from the current dump archive entry.
private void
readBITS()

Read BITS segment.

private void
readCLRI()

Read CLRI (deleted inode) segment.

private void
readDirectoryEntry(DumpArchiveEntry entry)

Read directory entry.

Inherited from org.apache.commons.compress.archivers.ArchiveInputStream:
canReadEntryDatacountcountgetCharsetpushedBackBytesread

Field Detail

activeback to summary
private DumpArchiveEntry active
blockBufferback to summary
private byte[] blockBuffer
CURRENT_PATH_SEGMENTback to summary
private static final String CURRENT_PATH_SEGMENT
entryOffsetback to summary
private long entryOffset
entrySizeback to summary
private long entrySize
fileposback to summary
private long filepos
hasHitEOFback to summary
private boolean hasHitEOF
isClosedback to summary
private boolean isClosed
namesback to summary
private final Map<Integer, Dirent> names

Map of ino -> dirent entry. We can use this to reconstruct full paths.

PARENT_PATH_SEGMENTback to summary
private static final String PARENT_PATH_SEGMENT
pendingback to summary
private final Map<Integer, DumpArchiveEntry> pending

Map of ino -> (directory) entry when we're missing one or more elements in the path.

queueback to summary
private final Queue<DumpArchiveEntry> queue

Queue of (directory) entries where we now have the full path.

rawback to summary
protected TapeInputStream raw
readBufback to summary
private final byte[] readBuf
readIdxback to summary
private int readIdx
recordOffsetback to summary
private int recordOffset
summaryback to summary
private final DumpArchiveSummary summary
zipEncodingback to summary
private final ZipEncoding zipEncoding

The encoding to use for file names and labels.

Constructor Detail

DumpArchiveInputStreamback to summary
public DumpArchiveInputStream(final InputStream is) throws ArchiveException

Constructor using the platform's default encoding for file names.

Parameters
is:InputStream

stream to read from

Exceptions
ArchiveException:
on error
DumpArchiveInputStreamback to summary
public DumpArchiveInputStream(final InputStream is, final String encoding) throws ArchiveException

Constructs a new instance.

Parameters
is:InputStream

stream to read from

encoding:String

the encoding to use for file names, use null for the platform's default encoding

Exceptions
ArchiveException:
on error
Since
1.6

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes the stream for this entry.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.FilterInputStream.close.

if an I/O error occurs.

getBytesReadback to summary
public long getBytesRead()

Overrides org.apache.commons.compress.archivers.ArchiveInputStream.getBytesRead.

Doc from org.apache.commons.compress.archivers.ArchiveInputStream.getBytesRead.

Gets the current number of bytes read from this stream.

Returns:long

the number of read bytes

Annotations
@Override
getCountback to summary
public int getCount()

Overrides org.apache.commons.compress.archivers.ArchiveInputStream.getCount.

Doc from org.apache.commons.compress.archivers.ArchiveInputStream.getCount.

Deprecated

Gets the current number of bytes read from this stream.

Returns:int

the number of read bytes

Annotations
@Deprecated
@Override
getNextDumpEntryback to summary
public DumpArchiveEntry getNextDumpEntry() throws IOException

Deprecated

Use getNextEntry().

Reads the next entry.

Returns:DumpArchiveEntry

the next entry

Annotations
@Deprecated
Exceptions
IOException:
on error
getNextEntryback to summary
public DumpArchiveEntry getNextEntry() throws IOException

Implements abstract org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Doc from org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Gets the next Archive Entry in this Stream.

Returns:DumpArchiveEntry

the next entry, or null if there are no more entries

Annotations
@Override
Exceptions
IOException:
if the next entry could not be read
getPathback to summary
private String getPath(final DumpArchiveEntry entry) throws DumpArchiveException

Gets full path for specified archive entry, or null if there's a gap.

Returns:String

full path for specified archive entry, or null if there's a gap.

Exceptions
DumpArchiveException:
Infinite loop detected in directory entries.
getSummaryback to summary
public DumpArchiveSummary getSummary()

Gets the archive summary information.

Returns:DumpArchiveSummary

the summary

matchesback to summary
public static boolean matches(final byte[] buffer, final int length)

Look at the first few bytes of the file to decide if it's a dump archive. With 32 bytes we can look at the magic value, with a full 1k we can verify the checksum.

Parameters
buffer:byte[]

data to match

length:int

length of data

Returns:boolean

whether the buffer seems to contain dump data

readback to summary
public int read(final byte[] buf, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Reads bytes from the current dump archive entry. This method is aware of the boundaries of the current entry in the archive and will deal with them as if they were this stream's start and EOF.

Parameters
buf:byte[]

The buffer into which to place bytes read.

off:int

The offset at which to place bytes read.

len:int

The number of bytes to read.

Returns:int

The number of bytes read, or -1 at EOF.

Annotations
@Override
Exceptions
IOException:
on error
readBITSback to summary
private void readBITS() throws IOException

Read BITS segment.

readCLRIback to summary
private void readCLRI() throws IOException

Read CLRI (deleted inode) segment.

readDirectoryEntryback to summary
private void readDirectoryEntry(DumpArchiveEntry entry) throws IOException

Read directory entry.