You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2005/10/19 20:40:05 UTC
svn commit: r326640 -
/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/CompressedResource.java
Author: bodewig
Date: Wed Oct 19 11:40:02 2005
New Revision: 326640
URL: http://svn.apache.org/viewcvs?rev=326640&view=rev
Log:
better return the correct size
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/CompressedResource.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/CompressedResource.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/CompressedResource.java?rev=326640&r1=326639&r2=326640&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/CompressedResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/CompressedResource.java Wed Oct 19 11:40:02 2005
@@ -25,12 +25,14 @@
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.util.FileUtils;
/**
* A compressed resource.
*
- * <p>Wraps around another resource, delegates all queries to that
- * other resource but uncompresses/compresses streams on the fly.</p>
+ * <p>Wraps around another resource, delegates all queries (except
+ * getSize) to that other resource but uncompresses/compresses streams
+ * on the fly.</p>
*
* @since Ant 1.7
*/
@@ -124,7 +126,26 @@
* compatibility with java.io.File), or UNKNOWN_SIZE if not known.
*/
public long getSize() {
- return getResource().getSize();
+ if (isExists()) {
+ InputStream in = null;
+ try {
+ in = getInputStream();
+ byte[] buf = new byte[8192];
+ int size = 0;
+ int readNow;
+ while ((readNow = in.read(buf, 0, buf.length)) > 0) {
+ size += readNow;
+ }
+ return size;
+ } catch (IOException ex) {
+ throw new BuildException("caught exception while reading "
+ + getName(), ex);
+ } finally {
+ FileUtils.close(in);
+ }
+ } else {
+ return 0;
+ }
}
public void setSize(long size) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org