~ubuntu-branches/ubuntu/maverick/ant/maverick

« back to all changes in this revision

Viewing changes to src/main/org/apache/tools/tar/TarInputStream.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-09-30 14:47:45 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080930144745-0x8uzivd9t15dua3
Tags: 1.7.1-0ubuntu1
* New upstream version (bug fix release).
  - mainly a bugfix release.
  - has extended support for Java6 features.
  - <script> now has support for JavaFX.
  - release notes: http://apache.linux-mirror.org/ant/README.html
* Remove debian/patches/05_ant-bug433444.patch. Obsoleted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 *
37
37
 */
38
38
public class TarInputStream extends FilterInputStream {
 
39
    private static final int SMALL_BUFFER_SIZE = 256;
 
40
    private static final int BUFFER_SIZE = 8 * 1024;
 
41
    private static final int LARGE_BUFFER_SIZE = 32 * 1024;
 
42
    private static final int BYTE_MASK = 0xFF;
39
43
 
40
44
    // CheckStyle:VisibilityModifier OFF - bc
41
45
    protected boolean debug;
149
153
        // This is horribly inefficient, but it ensures that we
150
154
        // properly skip over bytes via the TarBuffer...
151
155
        //
152
 
        byte[] skipBuf = new byte[8 * 1024];
 
156
        byte[] skipBuf = new byte[BUFFER_SIZE];
153
157
        long skip = numToSkip;
154
158
        while (skip > 0) {
155
159
            int realSkip = (int) (skip > skipBuf.length ? skipBuf.length : skip);
255
259
        if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) {
256
260
            // read in the name
257
261
            StringBuffer longName = new StringBuffer();
258
 
            byte[] buf = new byte[256];
 
262
            byte[] buf = new byte[SMALL_BUFFER_SIZE];
259
263
            int length = 0;
260
264
            while ((length = read(buf)) >= 0) {
261
265
                longName.append(new String(buf, 0, length));
287
291
     */
288
292
    public int read() throws IOException {
289
293
        int num = this.read(this.oneBuf, 0, 1);
290
 
        return num == -1 ? -1 : ((int) this.oneBuf[0]) & 0xFF;
 
294
        return num == -1 ? -1 : ((int) this.oneBuf[0]) & BYTE_MASK;
291
295
    }
292
296
 
293
297
    /**
378
382
     * @throws IOException on error
379
383
     */
380
384
    public void copyEntryContents(OutputStream out) throws IOException {
381
 
        byte[] buf = new byte[32 * 1024];
 
385
        byte[] buf = new byte[LARGE_BUFFER_SIZE];
382
386
 
383
387
        while (true) {
384
388
            int numRead = this.read(buf, 0, buf.length);