/* * Decompiled with CFR 0.152. */ package com.ice.tar; import com.ice.tar.InvalidHeaderException; import com.ice.tar.TarEntry; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.GZIPInputStream; /* * Illegal identifiers - consider using --renameillegalidents true */ public class FastTarStream { private boolean debug; private boolean hasHitEOF; private TarEntry currEntry; private InputStream inStream; private int recordSize; public void setDebug(boolean bl) { this.debug = bl; } public TarEntry getNextEntry() throws IOException { int n; int n2; if (this.hasHitEOF) { return null; } if (this.currEntry != null && this.currEntry.getSize() > 0L && (n2 = ((int)this.currEntry.getSize() + (this.recordSize - 1)) / this.recordSize) > 0) { this.inStream.skip(n2 * this.recordSize); } byte[] byArray = new byte[this.recordSize]; int n3 = 0; int n4 = this.recordSize; while (n4 > 0) { n = this.inStream.read(byArray, n3, n4); if (n == -1) { this.hasHitEOF = true; break; } n3 += n; n4 -= n; } if (!this.hasHitEOF) { this.hasHitEOF = true; n4 = 0; while (n4 < byArray.length) { if (byArray[n4] != 0) { this.hasHitEOF = false; break; } ++n4; } } if (this.hasHitEOF) { this.currEntry = null; } else { try { this.currEntry = new TarEntry(byArray); if (this.debug) { byte[] byArray2 = new byte[byArray.length]; n = 0; while (n < byArray.length) { byArray2[n] = byArray[n] == 0 ? 20 : byArray[n]; ++n; } String string = new String(byArray2); System.out.println("\n" + string); } if (byArray[257] != 117 || byArray[258] != 115 || byArray[259] != 116 || byArray[260] != 97 || byArray[261] != 114) { throw new InvalidHeaderException("header magic is not'ustar', but '" + byArray[257] + byArray[258] + byArray[259] + byArray[260] + byArray[261] + "', or (dec) " + byArray[257] + ", " + byArray[258] + ", " + byArray[259] + ", " + byArray[260] + ", " + byArray[261]); } } catch (InvalidHeaderException invalidHeaderException) { this.currEntry = null; throw invalidHeaderException; } } return this.currEntry; } public static void main(String[] stringArray) { boolean bl = false; InputStream inputStream = null; try { TarEntry tarEntry; int n = 0; if (stringArray.length > 0) { if (stringArray[n].equals("-d")) { bl = true; ++n; } inputStream = stringArray[n].endsWith(".gz") || stringArray[n].endsWith(".tgz") ? new GZIPInputStream(new FileInputStream(stringArray[n])) : new FileInputStream(stringArray[n]); } else { inputStream = System.in; } FastTarStream fastTarStream = new FastTarStream(inputStream); fastTarStream.setDebug(bl); int n2 = 56; int n3 = 9; int n4 = 8; StringBuffer stringBuffer = new StringBuffer(128); while ((tarEntry = fastTarStream.getNextEntry()) != null) { if (tarEntry.isDirectory()) { System.out.print("D "); stringBuffer.setLength(0); stringBuffer.append(tarEntry.getName()); stringBuffer.setLength(stringBuffer.length() - 1); if (stringBuffer.length() > n2) { stringBuffer.setLength(n2); } while (stringBuffer.length() < n2) { stringBuffer.append('_'); } stringBuffer.append('_'); System.out.print(stringBuffer.toString()); stringBuffer.setLength(0); while (stringBuffer.length() < n3) { stringBuffer.insert(0, '_'); } stringBuffer.append(' '); System.out.print(stringBuffer.toString()); stringBuffer.setLength(0); stringBuffer.append(tarEntry.getUserName()); if (stringBuffer.length() > n4) { stringBuffer.setLength(n4); } while (stringBuffer.length() < n4) { stringBuffer.append(' '); } System.out.print(stringBuffer.toString()); } else { System.out.print("F "); stringBuffer.setLength(0); stringBuffer.append(tarEntry.getName()); if (stringBuffer.length() > n2) { stringBuffer.setLength(n2); } while (stringBuffer.length() < n2) { stringBuffer.append(' '); } stringBuffer.append(' '); System.out.print(stringBuffer.toString()); stringBuffer.setLength(0); stringBuffer.append(tarEntry.getSize()); if (stringBuffer.length() > n3) { stringBuffer.setLength(n3); } while (stringBuffer.length() < n3) { stringBuffer.insert(0, ' '); } stringBuffer.append(' '); System.out.print(stringBuffer.toString()); stringBuffer.setLength(0); stringBuffer.append(tarEntry.getUserName()); if (stringBuffer.length() > n4) { stringBuffer.setLength(n4); } while (stringBuffer.length() < n4) { stringBuffer.append(' '); } System.out.print(stringBuffer.toString()); } System.out.println(""); } } catch (IOException iOException) { iOException.printStackTrace(System.err); } } private final /* synthetic */ void this() { this.debug = false; this.hasHitEOF = false; this.currEntry = null; this.inStream = null; this.recordSize = 512; } public FastTarStream(InputStream inputStream) { this(inputStream, 512); } public FastTarStream(InputStream inputStream, int n) { this.this(); this.inStream = inputStream; this.hasHitEOF = false; this.currEntry = null; this.recordSize = n; } }