@Override public void putEntry(FileLike fileLike) throws IOException { String name = fileLike.getRelativePath(); // Tracks unique entry names and avoids duplicates. This is, believe it or not, how // proguard seems to handle merging multiple -injars into a single -outjar. if (!containsEntry(fileLike)) { entryNames.add(name); outStream.putNextEntry(new ZipEntry(name)); try (InputStream in = fileLike.getInput()) { ByteStreams.copy(in, outStream); } // Make sure FileLike#getSize didn't lie (or we forgot to call canPutEntry). DalvikStatsTool.Stats stats = dalvikStatsCache.getStats(fileLike); Preconditions.checkState( !isEntryTooBig(fileLike), "Putting entry %s (%s) exceeded maximum size of %s", name, stats.estimatedLinearAllocSize, linearAllocLimit); currentLinearAllocSize += stats.estimatedLinearAllocSize; currentMethodReferences.addAll(stats.methodReferences); String report = String.format( "%d %d %s\n", stats.estimatedLinearAllocSize, stats.methodReferences.size(), name); Files.append(report, reportFile, Charsets.UTF_8); } }
@Override public boolean containsEntry(FileLike fileLike) { return entryNames.contains(fileLike.getRelativePath()); }