commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r768163 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ./ ar/ cpio/ tar/ zip/
Date Fri, 24 Apr 2009 06:30:17 GMT
Author: grobmeier
Date: Fri Apr 24 06:30:17 2009
New Revision: 768163

URL: http://svn.apache.org/viewvc?rev=768163&view=rev
Log:
added byte counter

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java?rev=768163&r1=768162&r2=768163&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java
Fri Apr 24 06:30:17 2009
@@ -52,6 +52,8 @@
     private final byte[] oneByte = new byte[1];
     static final int BYTE_MASK = 0xFF;
 
+    /** holds the number of bytes read in this stream */
+    private int bytesRead = 0;
     // Methods specific to ArchiveOutputStream
     
     /**
@@ -110,4 +112,23 @@
         write(oneByte, 0, 1);
     }
 
+    /**
+     * Increments the counter of already read bytes.
+     * Doesn't increment if the EOF has been hit (read == -1)
+     * 
+     * @param read the number of bytes read
+     */
+    protected void count(int read) {
+        if(read != -1) {
+            bytesRead = bytesRead + read;
+        }
+    }
+    
+    /**
+     * Returns the current number of bytes read from this stream.
+     * @return the number of read bytes
+     */
+    public int getCount() {
+        return bytesRead;
+    }
 }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java?rev=768163&r1=768162&r2=768163&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
Fri Apr 24 06:30:17 2009
@@ -149,6 +149,7 @@
 
     public void write(byte[] b, int off, int len) throws IOException {
         out.write(b, off, len);
+        count(len);
         entryOffset += len;
     }
 

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=768163&r1=768162&r2=768163&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
Fri Apr 24 06:30:17 2009
@@ -297,6 +297,7 @@
                 this.crc += b[pos] & 0xFF;
             }
         }
+        count(len);
     }
 
     /**

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=768163&r1=768162&r2=768163&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
Fri Apr 24 06:30:17 2009
@@ -297,6 +297,8 @@
             numToWrite -= num;
             wOffset += num;
         }
+        
+        count(numToWrite);
     }
 
     /**

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=768163&r1=768162&r2=768163&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Fri Apr 24 06:30:17 2009
@@ -518,6 +518,7 @@
             written += length;
         }
         crc.update(b, offset, length);
+        count(length);
     }
 
     /**



Mime
View raw message