Archive(File dir, int rev, InputStream is, URL source) throws IOException { BufferedInputStream bis = new BufferedInputStream(is, 8192); JarInputStream ji = null; boolean doUnpack = false;     if(source != null && "reference".equals(source.getProtocol())) { bReference = true; }  if (unpack) { bis.mark(8192); ji = new JarInputStream(bis); manifest = ji.getManifest(); if (manifest != null) { if (checkManifest()) { doUnpack = true; } else { try { bis.reset(); } catch (IOException fail) { doUnpack = true; } } } else {   try { bis.reset(); } catch (IOException fail) { doUnpack = true; } } } file = new FileTree(dir, ARCHIVE + rev); if (doUnpack) { File f = new File(file, "META-INF"); f.mkdirs(); BufferedOutputStream o = new BufferedOutputStream(new FileOutputStream(new File(f, "MANIFEST.MF"))); try { manifest.write(o); } finally { o.close(); } ZipEntry ze; while ((ze = ji.getNextJarEntry()) != null) { if (!ze.isDirectory()) { if(isSkipped(ze.getName())) {  } else { StringTokenizer st = new StringTokenizer(ze.getName(), "/"); f = new File(file, st.nextToken()); while (st.hasMoreTokens()) { f.mkdir(); f = new File(f, st.nextToken()); } loadFile(f, ji, true); } } } jar = null; } else {   if(source != null && bReference && "file".equals(source.getProtocol())) { refFile = new File(source.getFile()); jar = new ZipFile(refFile); } else { loadFile(file, bis, true); jar = new ZipFile(file); } if (manifest == null) { manifest = getManifest(); checkManifest(); } }
Archive(File dir, int rev, InputStream is) throws IOException { this(dir, rev, is, null);
  Archive(File dir, int rev, InputStream is, URL source) throws IOException {    BufferedInputStream bis = new BufferedInputStream(is, 8192);    JarInputStream ji = null;    boolean doUnpack = false;    // Handle reference: URLs by overriding global flag    if(source != null && "reference".equals(source.getProtocol())) {      bReference = true;    }    if (unpack) {      bis.mark(8192);      ji = new JarInputStream(bis);      manifest = ji.getManifest();      if (manifest != null) {	if (checkManifest()) {	  doUnpack = true;	} else {	  try {	    bis.reset();	  } catch (IOException fail) {	    doUnpack = true;	  }	}      } else {	// The manifest is probably not first in the file. We do not	// unpack to minimize disk footprint. Should we warn?	try {	  bis.reset();	} catch (IOException fail) {	  doUnpack = true;	}      }    }    file = new FileTree(dir, ARCHIVE + rev);    if (doUnpack) {      File f = new File(file, "META-INF");      f.mkdirs();      BufferedOutputStream o = new BufferedOutputStream(new FileOutputStream(new File(f, "MANIFEST.MF")));      try {	manifest.write(o);      } finally {	o.close();      }      ZipEntry ze;      while ((ze = ji.getNextJarEntry()) != null) {	if (!ze.isDirectory()) {	  if(isSkipped(ze.getName())) {	    // Optional files are not copied to disk	  } else {	    StringTokenizer st = new StringTokenizer(ze.getName(), "/");	    f = new File(file, st.nextToken());	    while (st.hasMoreTokens()) {	      f.mkdir();	      f = new File(f, st.nextToken());	    }	    loadFile(f, ji, true);	  }	}      }      jar = null;    } else {      // Only copy to storage when applicable, otherwise      // use reference      if(source != null && bReference && "file".equals(source.getProtocol())) {	refFile = new File(source.getFile());	jar = new ZipFile(refFile);      } else {	loadFile(file, bis, true);	jar = new ZipFile(file);      }      if (manifest == null) {	manifest = getManifest();	checkManifest();      }    }  }