use of com.facebook.buck.zip.CustomZipOutputStream in project buck by facebook.
the class CachingBuildEngineTest method writeEntriesToZip.
private static void writeEntriesToZip(Path file, ImmutableMap<Path, String> entries) throws IOException {
try (CustomZipOutputStream zip = ZipOutputStreams.newOutputStream(file)) {
for (Map.Entry<Path, String> mapEntry : entries.entrySet()) {
CustomZipEntry entry = new CustomZipEntry(mapEntry.getKey());
// We want deterministic ZIPs, so avoid mtimes. -1 is timzeone independent, 0 is not.
entry.setTime(ZipConstants.getFakeTime());
// We set the external attributes to this magic value which seems to match the attributes
// of entries created by {@link InMemoryArtifactCache}.
entry.setExternalAttributes(33188L << 16);
zip.putNextEntry(entry);
zip.write(mapEntry.getValue().getBytes());
zip.closeEntry();
}
}
}
use of com.facebook.buck.zip.CustomZipOutputStream in project buck by facebook.
the class PrebuiltJarSymbolsFinderTest method createFinderForFileWithEntries.
private PrebuiltJarSymbolsFinder createFinderForFileWithEntries(String jarFileName, Iterable<String> entries) throws IOException {
Clock clock = new FakeClock(1);
Path jarFile = tmp.newFile(jarFileName);
try (OutputStream stream = new BufferedOutputStream(java.nio.file.Files.newOutputStream(jarFile));
CustomZipOutputStream out = ZipOutputStreams.newOutputStream(stream, ZipOutputStreams.HandleDuplicates.THROW_EXCEPTION, clock)) {
for (String entry : entries) {
out.putNextEntry(new ZipEntry(entry));
}
}
ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
SourcePath sourcePath = new PathSourcePath(filesystem, Paths.get(jarFileName));
return new PrebuiltJarSymbolsFinder(sourcePath);
}
Aggregations