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 CRC32
private final Deflater
private final RandomAccessFile
(package private) final byte[]
private final CountingOutputStream
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
beginObject
(int objectType, long length) void
close()
private int
encodeTypeSize
(int type, long rawLength) (package private) byte[]
(package private) long
(package private) byte[]
inflate
(long filePos, int len) (package private) void
seek
(long offset) private int
void
write
(byte[] data, int off, int len) void
write
(int b) Methods inherited from class java.io.OutputStream
flush, 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:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
finishPack
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
inflate
- Throws:
IOException
DataFormatException
-
setInput
- Throws:
IOException
-