Class PackInserter.PackStream
java.lang.Object
java.io.OutputStream
org.eclipse.jgit.internal.storage.file.PackInserter.PackStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Enclosing class:
- PackInserter
Stream that writes to a pack file.
Backed by two views of the same open file descriptor: a random-access file, and an output stream. Seeking in the file causes subsequent writes to the output stream to occur wherever the file pointer is pointing, so we need to take care to always seek to the end of the file before writing a new object.
Callers should always use seek(long) to seek, rather than reaching
into the file member. As long as this contract is followed, calls to write(byte[], int, int) are guaranteed to write at the end of the file,
even if there have been intermediate seeks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean(package private) final DeflaterOutputStream(package private) final CRC32private final Deflaterprivate final RandomAccessFile(package private) final byte[]private final CountingOutputStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidbeginObject(int objectType, long length) voidclose()private intencodeTypeSize(int type, long rawLength) (package private) byte[](package private) long(package private) byte[]inflate(long filePos, int len) (package private) voidseek(long offset) private intvoidwrite(byte[] data, int off, int len) voidwrite(int b) Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Field Details
-
hdrBuf
final byte[] hdrBuf -
crc32
-
compress
-
file
-
out
-
deflater
-
atEnd
private boolean atEnd
-
-
Constructor Details
-
PackStream
PackStream(File pack) throws IOException - Throws:
IOException
-
-
Method Details
-
getOffset
long getOffset() -
seek
- Throws:
IOException
-
beginObject
- Throws:
IOException
-
encodeTypeSize
private int encodeTypeSize(int type, long rawLength) -
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
finishPack
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
inflate
- Throws:
IOExceptionDataFormatException
-
setInput
- Throws:
IOException
-