/** * Get the record size being used by this stream's TarBuffer. * * @return The TarBuffer record size. */ public int getRecordSize() { return this.buffer.getRecordSize(); }
/** * Sets the debugging flag. * * @param debug True to turn on debugging. */ public void setDebug(boolean debug) { this.debug = debug; this.buffer.setDebug(debug); }
/** * Closes this stream. Calls the TarBuffer's close() method. * @throws IOException on error */ public void close() throws IOException { this.buffer.close(); }
private void paxHeaders() throws IOException { Map<String, String> headers = parsePaxHeaders(this); getNextEntry(); // Get the actual file entry applyPaxHeadersToCurrentEntry(headers); }
/** * Write an EOF (end of archive) record to the tar archive. * An EOF record consists of a record of all zeros. */ private void writeEOFRecord() throws IOException { for (int i = 0; i < this.recordBuf.length; ++i) { this.recordBuf[i] = 0; } this.buffer.writeRecord(this.recordBuf); } }
/** * Constructor for TarInputStream. * @param is the input stream to use * @param blockSize the block size to use * @param recordSize the record size to use */ public TarInputStream(InputStream is, int blockSize, int recordSize) { super(is); this.buffer = new TarBuffer(is, blockSize, recordSize); this.readBuf = null; this.oneBuf = new byte[1]; this.debug = false; this.hasHitEOF = false; }
/** * Writes bytes to the current tar archive entry. * * This method simply calls write(byte[], int, int). * * @param wBuf The buffer to write to the archive. * @throws IOException on error */ @Override public void write(byte[] wBuf) throws IOException { write(wBuf, 0, wBuf.length); }
/** * Convenience method to set this entry's group and user ids. * * @param userId This entry's new user id. * @param groupId This entry's new group id. */ public void setIds(int userId, int groupId) { setUserId(userId); setGroupId(groupId); }
/** * Set this entry's user id. * * @param userId This entry's new user id. */ public void setUserId(int userId) { setUserId((long) userId); }
private int writeEntryHeaderField(long value, byte[] outbuf, int offset, int length, boolean starMode) { if (!starMode && (value < 0 || value >= (1L << (3 * (length - 1))))) { // value doesn't fit into field when written as octal // number, will be written to PAX header or causes an // error return TarUtils.formatLongOctalBytes(0, outbuf, offset, length); } return TarUtils.formatLongOctalOrBinaryBytes(value, outbuf, offset, length); }
/** * Set this entry's name. * * @param name This entry's new name. */ public void setName(String name) { this.name = normalizeFileName(name, false); }
/** * Construct an entry from an archive's header bytes. File is set * to null. * * @param headerBuf The header bytes from a tar archive entry. * @throws IOException on unknown format */ public TarArchiveSparseEntry(byte[] headerBuf) throws IOException { int offset = 0; offset += SPARSELEN_GNU_SPARSE; isExtended = TarUtils.parseBoolean(headerBuf, offset); }
/** * Get the record size being used by this stream's TarBuffer. * * @return The TarBuffer record size. */ public int getRecordSize() { return this.buffer.getRecordSize(); }
/** * Sets the debugging flag in this stream's TarBuffer. * * @param debug True to turn on debugging. */ public void setBufferDebug(boolean debug) { this.buffer.setDebug(debug); }
/** * Closes this stream. Calls the TarBuffer's close() method. * @throws IOException on error */ @Override public void close() throws IOException { buffer.close(); }
/** * Write an EOF (end of archive) record to the tar archive. * An EOF record consists of a record of all zeros. */ private void writeEOFRecord() throws IOException { for (int i = 0; i < recordBuf.length; ++i) { recordBuf[i] = 0; } buffer.writeRecord(recordBuf); }
/** * Constructor for TarInputStream. * @param os the output stream to use * @param blockSize the block size to use * @param recordSize the record size to use */ public TarOutputStream(OutputStream os, int blockSize, int recordSize) { super(os); this.buffer = new TarBuffer(os, blockSize, recordSize); this.debug = false; this.assemLen = 0; this.assemBuf = new byte[recordSize]; this.recordBuf = new byte[recordSize]; this.oneBuf = new byte[1]; }
/** * Get the record size being used by this stream's TarBuffer. * * @return The TarBuffer record size. */ public int getRecordSize() { return buffer.getRecordSize(); }
/** * Sets the debugging flag. * * @param debug True to turn on debugging. */ public void setDebug(boolean debug) { this.debug = debug; buffer.setDebug(debug); }
/** * Get the record size being used by this stream's TarBuffer. * * @return The TarBuffer record size. */ public int getRecordSize() { return buffer.getRecordSize(); }