git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@597087 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -171,7 +171,7 @@ public class TarBuffer { | |||
| * @return true if the record data is an End of Archive | |||
| */ | |||
| public boolean isEOFRecord(byte[] record) { | |||
| for (int i = 0, sz = this.getRecordSize(); i < sz; ++i) { | |||
| for (int i = 0, sz = getRecordSize(); i < sz; ++i) { | |||
| if (record[i] != 0) { | |||
| return false; | |||
| } | |||
| @@ -185,22 +185,22 @@ public class TarBuffer { | |||
| * @throws IOException on error | |||
| */ | |||
| public void skipRecord() throws IOException { | |||
| if (this.debug) { | |||
| System.err.println("SkipRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx); | |||
| if (debug) { | |||
| System.err.println("SkipRecord: recIdx = " + currRecIdx | |||
| + " blkIdx = " + currBlkIdx); | |||
| } | |||
| if (this.inStream == null) { | |||
| if (inStream == null) { | |||
| throw new IOException("reading (via skip) from an output buffer"); | |||
| } | |||
| if (this.currRecIdx >= this.recsPerBlock) { | |||
| if (!this.readBlock()) { | |||
| if (currRecIdx >= recsPerBlock) { | |||
| if (!readBlock()) { | |||
| return; // UNDONE | |||
| } | |||
| } | |||
| this.currRecIdx++; | |||
| currRecIdx++; | |||
| } | |||
| /** | |||
| @@ -210,28 +210,28 @@ public class TarBuffer { | |||
| * @throws IOException on error | |||
| */ | |||
| public byte[] readRecord() throws IOException { | |||
| if (this.debug) { | |||
| System.err.println("ReadRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx); | |||
| if (debug) { | |||
| System.err.println("ReadRecord: recIdx = " + currRecIdx | |||
| + " blkIdx = " + currBlkIdx); | |||
| } | |||
| if (this.inStream == null) { | |||
| if (inStream == null) { | |||
| throw new IOException("reading from an output buffer"); | |||
| } | |||
| if (this.currRecIdx >= this.recsPerBlock) { | |||
| if (!this.readBlock()) { | |||
| if (currRecIdx >= recsPerBlock) { | |||
| if (!readBlock()) { | |||
| return null; | |||
| } | |||
| } | |||
| byte[] result = new byte[this.recordSize]; | |||
| byte[] result = new byte[recordSize]; | |||
| System.arraycopy(this.blockBuffer, | |||
| (this.currRecIdx * this.recordSize), result, 0, | |||
| this.recordSize); | |||
| System.arraycopy(blockBuffer, | |||
| (currRecIdx * recordSize), result, 0, | |||
| recordSize); | |||
| this.currRecIdx++; | |||
| currRecIdx++; | |||
| return result; | |||
| } | |||
| @@ -240,21 +240,21 @@ public class TarBuffer { | |||
| * @return false if End-Of-File, else true | |||
| */ | |||
| private boolean readBlock() throws IOException { | |||
| if (this.debug) { | |||
| System.err.println("ReadBlock: blkIdx = " + this.currBlkIdx); | |||
| if (debug) { | |||
| System.err.println("ReadBlock: blkIdx = " + currBlkIdx); | |||
| } | |||
| if (this.inStream == null) { | |||
| if (inStream == null) { | |||
| throw new IOException("reading from an output buffer"); | |||
| } | |||
| this.currRecIdx = 0; | |||
| currRecIdx = 0; | |||
| int offset = 0; | |||
| int bytesNeeded = this.blockSize; | |||
| int bytesNeeded = blockSize; | |||
| while (bytesNeeded > 0) { | |||
| long numBytes = this.inStream.read(this.blockBuffer, offset, | |||
| long numBytes = inStream.read(blockBuffer, offset, | |||
| bytesNeeded); | |||
| // | |||
| @@ -291,16 +291,16 @@ public class TarBuffer { | |||
| offset += numBytes; | |||
| bytesNeeded -= numBytes; | |||
| if (numBytes != this.blockSize) { | |||
| if (this.debug) { | |||
| if (numBytes != blockSize) { | |||
| if (debug) { | |||
| System.err.println("ReadBlock: INCOMPLETE READ " | |||
| + numBytes + " of " + this.blockSize | |||
| + numBytes + " of " + blockSize | |||
| + " bytes read."); | |||
| } | |||
| } | |||
| } | |||
| this.currBlkIdx++; | |||
| currBlkIdx++; | |||
| return true; | |||
| } | |||
| @@ -311,7 +311,7 @@ public class TarBuffer { | |||
| * @return The current zero based block number. | |||
| */ | |||
| public int getCurrentBlockNum() { | |||
| return this.currBlkIdx; | |||
| return currBlkIdx; | |||
| } | |||
| /** | |||
| @@ -321,7 +321,7 @@ public class TarBuffer { | |||
| * @return The current zero based record number. | |||
| */ | |||
| public int getCurrentRecordNum() { | |||
| return this.currRecIdx - 1; | |||
| return currRecIdx - 1; | |||
| } | |||
| /** | |||
| @@ -331,31 +331,31 @@ public class TarBuffer { | |||
| * @throws IOException on error | |||
| */ | |||
| public void writeRecord(byte[] record) throws IOException { | |||
| if (this.debug) { | |||
| System.err.println("WriteRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx); | |||
| if (debug) { | |||
| System.err.println("WriteRecord: recIdx = " + currRecIdx | |||
| + " blkIdx = " + currBlkIdx); | |||
| } | |||
| if (this.outStream == null) { | |||
| if (outStream == null) { | |||
| throw new IOException("writing to an input buffer"); | |||
| } | |||
| if (record.length != this.recordSize) { | |||
| if (record.length != recordSize) { | |||
| throw new IOException("record to write has length '" | |||
| + record.length | |||
| + "' which is not the record size of '" | |||
| + this.recordSize + "'"); | |||
| + recordSize + "'"); | |||
| } | |||
| if (this.currRecIdx >= this.recsPerBlock) { | |||
| this.writeBlock(); | |||
| if (currRecIdx >= recsPerBlock) { | |||
| writeBlock(); | |||
| } | |||
| System.arraycopy(record, 0, this.blockBuffer, | |||
| (this.currRecIdx * this.recordSize), | |||
| this.recordSize); | |||
| System.arraycopy(record, 0, blockBuffer, | |||
| (currRecIdx * recordSize), | |||
| recordSize); | |||
| this.currRecIdx++; | |||
| currRecIdx++; | |||
| } | |||
| /** | |||
| @@ -368,66 +368,66 @@ public class TarBuffer { | |||
| * @throws IOException on error | |||
| */ | |||
| public void writeRecord(byte[] buf, int offset) throws IOException { | |||
| if (this.debug) { | |||
| System.err.println("WriteRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx); | |||
| if (debug) { | |||
| System.err.println("WriteRecord: recIdx = " + currRecIdx | |||
| + " blkIdx = " + currBlkIdx); | |||
| } | |||
| if (this.outStream == null) { | |||
| if (outStream == null) { | |||
| throw new IOException("writing to an input buffer"); | |||
| } | |||
| if ((offset + this.recordSize) > buf.length) { | |||
| if ((offset + recordSize) > buf.length) { | |||
| throw new IOException("record has length '" + buf.length | |||
| + "' with offset '" + offset | |||
| + "' which is less than the record size of '" | |||
| + this.recordSize + "'"); | |||
| + recordSize + "'"); | |||
| } | |||
| if (this.currRecIdx >= this.recsPerBlock) { | |||
| this.writeBlock(); | |||
| if (currRecIdx >= recsPerBlock) { | |||
| writeBlock(); | |||
| } | |||
| System.arraycopy(buf, offset, this.blockBuffer, | |||
| (this.currRecIdx * this.recordSize), | |||
| this.recordSize); | |||
| System.arraycopy(buf, offset, blockBuffer, | |||
| (currRecIdx * recordSize), | |||
| recordSize); | |||
| this.currRecIdx++; | |||
| currRecIdx++; | |||
| } | |||
| /** | |||
| * Write a TarBuffer block to the archive. | |||
| */ | |||
| private void writeBlock() throws IOException { | |||
| if (this.debug) { | |||
| System.err.println("WriteBlock: blkIdx = " + this.currBlkIdx); | |||
| if (debug) { | |||
| System.err.println("WriteBlock: blkIdx = " + currBlkIdx); | |||
| } | |||
| if (this.outStream == null) { | |||
| if (outStream == null) { | |||
| throw new IOException("writing to an input buffer"); | |||
| } | |||
| this.outStream.write(this.blockBuffer, 0, this.blockSize); | |||
| this.outStream.flush(); | |||
| outStream.write(blockBuffer, 0, blockSize); | |||
| outStream.flush(); | |||
| this.currRecIdx = 0; | |||
| this.currBlkIdx++; | |||
| currRecIdx = 0; | |||
| currBlkIdx++; | |||
| } | |||
| /** | |||
| * Flush the current data block if it has any data in it. | |||
| */ | |||
| private void flushBlock() throws IOException { | |||
| if (this.debug) { | |||
| if (debug) { | |||
| System.err.println("TarBuffer.flushBlock() called."); | |||
| } | |||
| if (this.outStream == null) { | |||
| if (outStream == null) { | |||
| throw new IOException("writing to an input buffer"); | |||
| } | |||
| if (this.currRecIdx > 0) { | |||
| this.writeBlock(); | |||
| if (currRecIdx > 0) { | |||
| writeBlock(); | |||
| } | |||
| } | |||
| @@ -437,24 +437,24 @@ public class TarBuffer { | |||
| * @throws IOException on error | |||
| */ | |||
| public void close() throws IOException { | |||
| if (this.debug) { | |||
| if (debug) { | |||
| System.err.println("TarBuffer.closeBuffer()."); | |||
| } | |||
| if (this.outStream != null) { | |||
| this.flushBlock(); | |||
| if (outStream != null) { | |||
| flushBlock(); | |||
| if (this.outStream != System.out | |||
| && this.outStream != System.err) { | |||
| this.outStream.close(); | |||
| if (outStream != System.out | |||
| && outStream != System.err) { | |||
| outStream.close(); | |||
| this.outStream = null; | |||
| outStream = null; | |||
| } | |||
| } else if (this.inStream != null) { | |||
| if (this.inStream != System.in) { | |||
| this.inStream.close(); | |||
| } else if (inStream != null) { | |||
| if (inStream != System.in) { | |||
| inStream.close(); | |||
| this.inStream = null; | |||
| inStream = null; | |||
| } | |||
| } | |||
| } | |||
| @@ -99,7 +99,7 @@ public class TarInputStream extends FilterInputStream { | |||
| */ | |||
| public void setDebug(boolean debug) { | |||
| this.debug = debug; | |||
| this.buffer.setDebug(debug); | |||
| buffer.setDebug(debug); | |||
| } | |||
| /** | |||
| @@ -107,7 +107,7 @@ public class TarInputStream extends FilterInputStream { | |||
| * @throws IOException on error | |||
| */ | |||
| public void close() throws IOException { | |||
| this.buffer.close(); | |||
| buffer.close(); | |||
| } | |||
| /** | |||
| @@ -116,7 +116,7 @@ public class TarInputStream extends FilterInputStream { | |||
| * @return The TarBuffer record size. | |||
| */ | |||
| public int getRecordSize() { | |||
| return this.buffer.getRecordSize(); | |||
| return buffer.getRecordSize(); | |||
| } | |||
| /** | |||
| @@ -132,10 +132,10 @@ public class TarInputStream extends FilterInputStream { | |||
| * @throws IOException for signature | |||
| */ | |||
| public int available() throws IOException { | |||
| if (this.entrySize - this.entryOffset > Integer.MAX_VALUE) { | |||
| if (entrySize - entryOffset > Integer.MAX_VALUE) { | |||
| return Integer.MAX_VALUE; | |||
| } | |||
| return (int) (this.entrySize - this.entryOffset); | |||
| return (int) (entrySize - entryOffset); | |||
| } | |||
| /** | |||
| @@ -157,7 +157,7 @@ public class TarInputStream extends FilterInputStream { | |||
| long skip = numToSkip; | |||
| while (skip > 0) { | |||
| int realSkip = (int) (skip > skipBuf.length ? skipBuf.length : skip); | |||
| int numRead = this.read(skipBuf, 0, realSkip); | |||
| int numRead = read(skipBuf, 0, realSkip); | |||
| if (numRead == -1) { | |||
| break; | |||
| } | |||
| @@ -203,60 +203,60 @@ public class TarInputStream extends FilterInputStream { | |||
| * @throws IOException on error | |||
| */ | |||
| public TarEntry getNextEntry() throws IOException { | |||
| if (this.hasHitEOF) { | |||
| if (hasHitEOF) { | |||
| return null; | |||
| } | |||
| if (this.currEntry != null) { | |||
| long numToSkip = this.entrySize - this.entryOffset; | |||
| if (currEntry != null) { | |||
| long numToSkip = entrySize - entryOffset; | |||
| if (this.debug) { | |||
| if (debug) { | |||
| System.err.println("TarInputStream: SKIP currENTRY '" | |||
| + this.currEntry.getName() + "' SZ " | |||
| + this.entrySize + " OFF " | |||
| + this.entryOffset + " skipping " | |||
| + currEntry.getName() + "' SZ " | |||
| + entrySize + " OFF " | |||
| + entryOffset + " skipping " | |||
| + numToSkip + " bytes"); | |||
| } | |||
| if (numToSkip > 0) { | |||
| this.skip(numToSkip); | |||
| skip(numToSkip); | |||
| } | |||
| this.readBuf = null; | |||
| readBuf = null; | |||
| } | |||
| byte[] headerBuf = this.buffer.readRecord(); | |||
| byte[] headerBuf = buffer.readRecord(); | |||
| if (headerBuf == null) { | |||
| if (this.debug) { | |||
| if (debug) { | |||
| System.err.println("READ NULL RECORD"); | |||
| } | |||
| this.hasHitEOF = true; | |||
| } else if (this.buffer.isEOFRecord(headerBuf)) { | |||
| if (this.debug) { | |||
| hasHitEOF = true; | |||
| } else if (buffer.isEOFRecord(headerBuf)) { | |||
| if (debug) { | |||
| System.err.println("READ EOF RECORD"); | |||
| } | |||
| this.hasHitEOF = true; | |||
| hasHitEOF = true; | |||
| } | |||
| if (this.hasHitEOF) { | |||
| this.currEntry = null; | |||
| if (hasHitEOF) { | |||
| currEntry = null; | |||
| } else { | |||
| this.currEntry = new TarEntry(headerBuf); | |||
| currEntry = new TarEntry(headerBuf); | |||
| if (this.debug) { | |||
| if (debug) { | |||
| System.err.println("TarInputStream: SET CURRENTRY '" | |||
| + this.currEntry.getName() | |||
| + currEntry.getName() | |||
| + "' size = " | |||
| + this.currEntry.getSize()); | |||
| + currEntry.getSize()); | |||
| } | |||
| this.entryOffset = 0; | |||
| entryOffset = 0; | |||
| this.entrySize = this.currEntry.getSize(); | |||
| entrySize = currEntry.getSize(); | |||
| } | |||
| if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) { | |||
| if (currEntry != null && currEntry.isGNULongNameEntry()) { | |||
| // read in the name | |||
| StringBuffer longName = new StringBuffer(); | |||
| byte[] buf = new byte[SMALL_BUFFER_SIZE]; | |||
| @@ -265,7 +265,7 @@ public class TarInputStream extends FilterInputStream { | |||
| longName.append(new String(buf, 0, length)); | |||
| } | |||
| getNextEntry(); | |||
| if (this.currEntry == null) { | |||
| if (currEntry == null) { | |||
| // Bugzilla: 40334 | |||
| // Malformed tar file - long entry name not followed by entry | |||
| return null; | |||
| @@ -275,10 +275,10 @@ public class TarInputStream extends FilterInputStream { | |||
| && longName.charAt(longName.length() - 1) == 0) { | |||
| longName.deleteCharAt(longName.length() - 1); | |||
| } | |||
| this.currEntry.setName(longName.toString()); | |||
| currEntry.setName(longName.toString()); | |||
| } | |||
| return this.currEntry; | |||
| return currEntry; | |||
| } | |||
| /** | |||
| @@ -290,8 +290,8 @@ public class TarInputStream extends FilterInputStream { | |||
| * @throws IOException on error | |||
| */ | |||
| public int read() throws IOException { | |||
| int num = this.read(this.oneBuf, 0, 1); | |||
| return num == -1 ? -1 : ((int) this.oneBuf[0]) & BYTE_MASK; | |||
| int num = read(oneBuf, 0, 1); | |||
| return num == -1 ? -1 : ((int) oneBuf[0]) & BYTE_MASK; | |||
| } | |||
| /** | |||
| @@ -310,29 +310,29 @@ public class TarInputStream extends FilterInputStream { | |||
| public int read(byte[] buf, int offset, int numToRead) throws IOException { | |||
| int totalRead = 0; | |||
| if (this.entryOffset >= this.entrySize) { | |||
| if (entryOffset >= entrySize) { | |||
| return -1; | |||
| } | |||
| if ((numToRead + this.entryOffset) > this.entrySize) { | |||
| numToRead = (int) (this.entrySize - this.entryOffset); | |||
| if ((numToRead + entryOffset) > entrySize) { | |||
| numToRead = (int) (entrySize - entryOffset); | |||
| } | |||
| if (this.readBuf != null) { | |||
| int sz = (numToRead > this.readBuf.length) ? this.readBuf.length | |||
| if (readBuf != null) { | |||
| int sz = (numToRead > readBuf.length) ? readBuf.length | |||
| : numToRead; | |||
| System.arraycopy(this.readBuf, 0, buf, offset, sz); | |||
| System.arraycopy(readBuf, 0, buf, offset, sz); | |||
| if (sz >= this.readBuf.length) { | |||
| this.readBuf = null; | |||
| if (sz >= readBuf.length) { | |||
| readBuf = null; | |||
| } else { | |||
| int newLen = this.readBuf.length - sz; | |||
| int newLen = readBuf.length - sz; | |||
| byte[] newBuf = new byte[newLen]; | |||
| System.arraycopy(this.readBuf, sz, newBuf, 0, newLen); | |||
| System.arraycopy(readBuf, sz, newBuf, 0, newLen); | |||
| this.readBuf = newBuf; | |||
| readBuf = newBuf; | |||
| } | |||
| totalRead += sz; | |||
| @@ -341,7 +341,7 @@ public class TarInputStream extends FilterInputStream { | |||
| } | |||
| while (numToRead > 0) { | |||
| byte[] rec = this.buffer.readRecord(); | |||
| byte[] rec = buffer.readRecord(); | |||
| if (rec == null) { | |||
| // Unexpected EOF! | |||
| @@ -355,9 +355,9 @@ public class TarInputStream extends FilterInputStream { | |||
| if (recLen > sz) { | |||
| System.arraycopy(rec, 0, buf, offset, sz); | |||
| this.readBuf = new byte[recLen - sz]; | |||
| readBuf = new byte[recLen - sz]; | |||
| System.arraycopy(rec, sz, this.readBuf, 0, recLen - sz); | |||
| System.arraycopy(rec, sz, readBuf, 0, recLen - sz); | |||
| } else { | |||
| sz = recLen; | |||
| @@ -369,7 +369,7 @@ public class TarInputStream extends FilterInputStream { | |||
| offset += sz; | |||
| } | |||
| this.entryOffset += totalRead; | |||
| entryOffset += totalRead; | |||
| return totalRead; | |||
| } | |||
| @@ -385,7 +385,7 @@ public class TarInputStream extends FilterInputStream { | |||
| byte[] buf = new byte[LARGE_BUFFER_SIZE]; | |||
| while (true) { | |||
| int numRead = this.read(buf, 0, buf.length); | |||
| int numRead = read(buf, 0, buf.length); | |||
| if (numRead == -1) { | |||
| break; | |||
| @@ -119,7 +119,7 @@ public class TarOutputStream extends FilterOutputStream { | |||
| * @param debug True to turn on debugging. | |||
| */ | |||
| public void setBufferDebug(boolean debug) { | |||
| this.buffer.setDebug(debug); | |||
| buffer.setDebug(debug); | |||
| } | |||
| /** | |||
| @@ -130,8 +130,8 @@ public class TarOutputStream extends FilterOutputStream { | |||
| public void finish() throws IOException { | |||
| // See Bugzilla 28776 for a discussion on this | |||
| // http://issues.apache.org/bugzilla/show_bug.cgi?id=28776 | |||
| this.writeEOFRecord(); | |||
| this.writeEOFRecord(); | |||
| writeEOFRecord(); | |||
| writeEOFRecord(); | |||
| } | |||
| /** | |||
| @@ -142,8 +142,8 @@ public class TarOutputStream extends FilterOutputStream { | |||
| */ | |||
| public void close() throws IOException { | |||
| if (!closed) { | |||
| this.finish(); | |||
| this.buffer.close(); | |||
| finish(); | |||
| buffer.close(); | |||
| out.close(); | |||
| closed = true; | |||
| } | |||
| @@ -155,7 +155,7 @@ public class TarOutputStream extends FilterOutputStream { | |||
| * @return The TarBuffer record size. | |||
| */ | |||
| public int getRecordSize() { | |||
| return this.buffer.getRecordSize(); | |||
| return buffer.getRecordSize(); | |||
| } | |||
| /** | |||
| @@ -191,15 +191,15 @@ public class TarOutputStream extends FilterOutputStream { | |||
| } | |||
| } | |||
| entry.writeEntryHeader(this.recordBuf); | |||
| this.buffer.writeRecord(this.recordBuf); | |||
| entry.writeEntryHeader(recordBuf); | |||
| buffer.writeRecord(recordBuf); | |||
| this.currBytes = 0; | |||
| currBytes = 0; | |||
| if (entry.isDirectory()) { | |||
| this.currSize = 0; | |||
| currSize = 0; | |||
| } else { | |||
| this.currSize = entry.getSize(); | |||
| currSize = entry.getSize(); | |||
| } | |||
| currName = entry.getName(); | |||
| } | |||
| @@ -215,21 +215,21 @@ public class TarOutputStream extends FilterOutputStream { | |||
| * @throws IOException on error | |||
| */ | |||
| public void closeEntry() throws IOException { | |||
| if (this.assemLen > 0) { | |||
| for (int i = this.assemLen; i < this.assemBuf.length; ++i) { | |||
| this.assemBuf[i] = 0; | |||
| if (assemLen > 0) { | |||
| for (int i = assemLen; i < assemBuf.length; ++i) { | |||
| assemBuf[i] = 0; | |||
| } | |||
| this.buffer.writeRecord(this.assemBuf); | |||
| buffer.writeRecord(assemBuf); | |||
| this.currBytes += this.assemLen; | |||
| this.assemLen = 0; | |||
| currBytes += assemLen; | |||
| assemLen = 0; | |||
| } | |||
| if (this.currBytes < this.currSize) { | |||
| if (currBytes < currSize) { | |||
| throw new IOException("entry '" + currName + "' closed at '" | |||
| + this.currBytes | |||
| + "' before the '" + this.currSize | |||
| + currBytes | |||
| + "' before the '" + currSize | |||
| + "' bytes specified in the header were written"); | |||
| } | |||
| } | |||
| @@ -243,9 +243,9 @@ public class TarOutputStream extends FilterOutputStream { | |||
| * @throws IOException on error | |||
| */ | |||
| public void write(int b) throws IOException { | |||
| this.oneBuf[0] = (byte) b; | |||
| oneBuf[0] = (byte) b; | |||
| this.write(this.oneBuf, 0, 1); | |||
| write(oneBuf, 0, 1); | |||
| } | |||
| /** | |||
| @@ -257,7 +257,7 @@ public class TarOutputStream extends FilterOutputStream { | |||
| * @throws IOException on error | |||
| */ | |||
| public void write(byte[] wBuf) throws IOException { | |||
| this.write(wBuf, 0, wBuf.length); | |||
| write(wBuf, 0, wBuf.length); | |||
| } | |||
| /** | |||
| @@ -275,10 +275,10 @@ public class TarOutputStream extends FilterOutputStream { | |||
| * @throws IOException on error | |||
| */ | |||
| public void write(byte[] wBuf, int wOffset, int numToWrite) throws IOException { | |||
| if ((this.currBytes + numToWrite) > this.currSize) { | |||
| if ((currBytes + numToWrite) > currSize) { | |||
| throw new IOException("request to write '" + numToWrite | |||
| + "' bytes exceeds size in header of '" | |||
| + this.currSize + "' bytes for entry '" | |||
| + currSize + "' bytes for entry '" | |||
| + currName + "'"); | |||
| // | |||
| @@ -290,26 +290,26 @@ public class TarOutputStream extends FilterOutputStream { | |||
| // | |||
| } | |||
| if (this.assemLen > 0) { | |||
| if ((this.assemLen + numToWrite) >= this.recordBuf.length) { | |||
| int aLen = this.recordBuf.length - this.assemLen; | |||
| if (assemLen > 0) { | |||
| if ((assemLen + numToWrite) >= recordBuf.length) { | |||
| int aLen = recordBuf.length - assemLen; | |||
| System.arraycopy(this.assemBuf, 0, this.recordBuf, 0, | |||
| this.assemLen); | |||
| System.arraycopy(wBuf, wOffset, this.recordBuf, | |||
| this.assemLen, aLen); | |||
| this.buffer.writeRecord(this.recordBuf); | |||
| System.arraycopy(assemBuf, 0, recordBuf, 0, | |||
| assemLen); | |||
| System.arraycopy(wBuf, wOffset, recordBuf, | |||
| assemLen, aLen); | |||
| buffer.writeRecord(recordBuf); | |||
| this.currBytes += this.recordBuf.length; | |||
| currBytes += recordBuf.length; | |||
| wOffset += aLen; | |||
| numToWrite -= aLen; | |||
| this.assemLen = 0; | |||
| assemLen = 0; | |||
| } else { | |||
| System.arraycopy(wBuf, wOffset, this.assemBuf, this.assemLen, | |||
| System.arraycopy(wBuf, wOffset, assemBuf, assemLen, | |||
| numToWrite); | |||
| wOffset += numToWrite; | |||
| this.assemLen += numToWrite; | |||
| assemLen += numToWrite; | |||
| numToWrite -= numToWrite; | |||
| } | |||
| } | |||
| @@ -320,20 +320,20 @@ public class TarOutputStream extends FilterOutputStream { | |||
| // o No bytes to write (numToWrite == 0) | |||
| // | |||
| while (numToWrite > 0) { | |||
| if (numToWrite < this.recordBuf.length) { | |||
| System.arraycopy(wBuf, wOffset, this.assemBuf, this.assemLen, | |||
| if (numToWrite < recordBuf.length) { | |||
| System.arraycopy(wBuf, wOffset, assemBuf, assemLen, | |||
| numToWrite); | |||
| this.assemLen += numToWrite; | |||
| assemLen += numToWrite; | |||
| break; | |||
| } | |||
| this.buffer.writeRecord(wBuf, wOffset); | |||
| buffer.writeRecord(wBuf, wOffset); | |||
| int num = this.recordBuf.length; | |||
| int num = recordBuf.length; | |||
| this.currBytes += num; | |||
| currBytes += num; | |||
| numToWrite -= num; | |||
| wOffset += num; | |||
| } | |||
| @@ -344,11 +344,11 @@ public class TarOutputStream extends FilterOutputStream { | |||
| * 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; | |||
| for (int i = 0; i < recordBuf.length; ++i) { | |||
| recordBuf[i] = 0; | |||
| } | |||
| this.buffer.writeRecord(this.recordBuf); | |||
| buffer.writeRecord(recordBuf); | |||
| } | |||
| } | |||