protected void packBundle(ZipOutputStream output, Bundle bundle) throws IOException { BundleFile bundleFile = bundle.getBundleFile(); Filter filter = filters.get(bundle.getBundleID()); List<String> pathes = bundleFile.getEntryPaths("/"); for (String path : pathes) { packBundle(output, bundle, path, filter); } }
protected void packBundle(ZipOutputStream output, Bundle bundle, String path, Filter filter) throws IOException { if (filter != null && !filter.accept(path)) { log(Level.FINE, "exclude {0}/{1}", new Object[] {bundle.getBundleID(), path}); return; } BundleFile bundleFile = bundle.getBundleFile(); if (bundleFile.isDirectory(path)) { List<String> entries = bundleFile.getEntryPaths(path); for (String entry : entries) { packBundle(output, bundle, entry, filter); } return; } // pack the JAR/ZIP BundleEntry bundleEntry = bundleFile.getEntry(path); if (path.endsWith(".jar") || path.endsWith(".zip")) { File tempZipFile = createTempFile(bundleEntry); try { ZipFile zipFile = new ZipFile(tempZipFile); try { packZip(output, bundleEntry, zipFile, filter); } finally { zipFile.close(); } } finally { tempZipFile.delete(); } return; } // pack the normal entry if (existingEntries.contains(path)) { log(Level.WARNING, "duplicate {0}/{1}", new Object[] {bundle.getBundleID(), path}); return; } existingEntries.add(path); InputStream input = bundleEntry.getInputStream(); try { ZipEntry zipEntry = new ZipEntry(bundleEntry.getName()); zipEntry.setTime(bundleEntry.getTime()); zipEntry.setSize(bundleEntry.getSize()); output.putNextEntry(zipEntry); try { copyStream(input, output); } finally { output.closeEntry(); } } finally { input.close(); } }