bodewig 2005/03/21 02:12:04
Modified: . Tag: ANT_16_BRANCH WHATSNEW
src/main/org/apache/tools/tar Tag: ANT_16_BRANCH
TarInputStream.java
Log:
merge
Revision Changes Path
No revision
No revision
1.503.2.204 +3 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.503.2.203
retrieving revision 1.503.2.204
diff -u -r1.503.2.203 -r1.503.2.204
--- WHATSNEW 17 Mar 2005 10:18:43 -0000 1.503.2.203
+++ WHATSNEW 21 Mar 2005 10:12:03 -0000 1.503.2.204
@@ -270,6 +270,9 @@
* Improved handling of paths on cygwin
Bugzilla Report 31245
+* TarInputStream#read() wasn't implemented correctly. Bugzilla Report
+ 34097.
+
Changes from Ant 1.6.1 to Ant 1.6.2
===================================
No revision
No revision
1.12.2.5 +35 -23 ant/src/main/org/apache/tools/tar/TarInputStream.java
Index: TarInputStream.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/tar/TarInputStream.java,v
retrieving revision 1.12.2.4
retrieving revision 1.12.2.5
diff -u -r1.12.2.4 -r1.12.2.5
--- TarInputStream.java 9 Mar 2004 17:02:00 -0000 1.12.2.4
+++ TarInputStream.java 21 Mar 2005 10:12:04 -0000 1.12.2.5
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2004 The Apache Software Foundation
+ * Copyright 2000-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,20 +40,41 @@
protected boolean hasHitEOF;
protected int entrySize;
protected int entryOffset;
- protected byte[] oneBuf;
protected byte[] readBuf;
protected TarBuffer buffer;
protected TarEntry currEntry;
private boolean v7Format;
+ /**
+ * This contents of this array is not used at all in this class,
+ * it is only here to avoid repreated object creation during calls
+ * to the no-arg read method.
+ */
+ protected byte[] oneBuf;
+
+ /**
+ * Constructor for TarInputStream.
+ * @param is the input stream to use
+ */
public TarInputStream(InputStream is) {
this(is, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE);
}
+ /**
+ * Constructor for TarInputStream.
+ * @param is the input stream to use
+ * @param blockSize the block size to use
+ */
public TarInputStream(InputStream is, int blockSize) {
this(is, blockSize, TarBuffer.DEFAULT_RCDSIZE);
}
+ /**
+ * 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);
@@ -77,6 +98,7 @@
/**
* Closes this stream. Calls the TarBuffer's close() method.
+ * @throws IOException on error
*/
public void close() throws IOException {
this.buffer.close();
@@ -100,6 +122,7 @@
*
*
* @return The number of available bytes for the current entry.
+ * @throws IOException for signature
*/
public int available() throws IOException {
return this.entrySize - this.entryOffset;
@@ -112,6 +135,8 @@
* to skip extends beyond that point.
*
* @param numToSkip The number of bytes to skip.
+ * @return the number actually skipped
+ * @throws IOException on error
*/
public long skip(long numToSkip) throws IOException {
// REVIEW
@@ -165,6 +190,7 @@
* been reached.
*
* @return The next TarEntry in the archive, or null.
+ * @throws IOException on error
*/
public TarEntry getNextEntry() throws IOException {
if (this.hasHitEOF) {
@@ -230,10 +256,10 @@
if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) {
// read in the name
StringBuffer longName = new StringBuffer();
- byte[] buffer = new byte[256];
+ byte[] buf = new byte[256];
int length = 0;
- while ((length = read(buffer)) >= 0) {
- longName.append(new String(buffer, 0, length));
+ while ((length = read(buf)) >= 0) {
+ longName.append(new String(buf, 0, length));
}
getNextEntry();
@@ -254,27 +280,11 @@
* This method simply calls read( byte[], int, int ).
*
* @return The byte read, or -1 at EOF.
+ * @throws IOException on error
*/
public int read() throws IOException {
int num = this.read(this.oneBuf, 0, 1);
-
- if (num == -1) {
- return num;
- } else {
- return (int) this.oneBuf[0];
- }
- }
-
- /**
- * Reads bytes from the current tar archive entry.
- *
- * This method simply calls read( byte[], int, int ).
- *
- * @param buf The buffer into which to place bytes read.
- * @return The number of bytes read, or -1 at EOF.
- */
- public int read(byte[] buf) throws IOException {
- return this.read(buf, 0, buf.length);
+ return num == -1 ? -1 : ((int) this.oneBuf[0]) & 0xFF;
}
/**
@@ -288,6 +298,7 @@
* @param offset The offset at which to place bytes read.
* @param numToRead The number of bytes to read.
* @return The number of bytes read, or -1 at EOF.
+ * @throws IOException on error
*/
public int read(byte[] buf, int offset, int numToRead) throws IOException {
int totalRead = 0;
@@ -361,6 +372,7 @@
* an output stream.
*
* @param out The OutputStream into which to write the entry's data.
+ * @throws IOException on error
*/
public void copyEntryContents(OutputStream out) throws IOException {
byte[] buf = new byte[32 * 1024];
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
|