use of java.util.zip.ZipException in project che by eclipse.
the class JavaModelManager method verifyArchiveContent.
public void verifyArchiveContent(IPath path) throws CoreException {
if (isInvalidArchive(path)) {
throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException()));
}
ZipFile file = getZipFile(path);
closeZipFile(file);
}
use of java.util.zip.ZipException in project buck by facebook.
the class OverwritingZipOutputStream method actuallyPutNextEntry.
@Override
protected void actuallyPutNextEntry(ZipEntry entry) throws IOException {
// We calculate the actual offset when closing the stream, so 0 is fine.
currentEntry = new EntryAccounting(clock, entry, /* currentOffset */
0);
long md5 = Hashing.md5().hashUnencodedChars(entry.getName()).asLong();
String name = String.valueOf(md5);
File file = new File(scratchDir, name);
entries.put(file, currentEntry);
if (file.exists() && !file.delete()) {
throw new ZipException("Unable to delete existing file: " + entry.getName());
}
currentOutput = new BufferedOutputStream(new FileOutputStream(file));
}
use of java.util.zip.ZipException in project buck by facebook.
the class JarDirectoryStepHelper method copyZipEntriesToJar.
/**
* @param inputFile is assumed to be a zip
* @param outputFile the path where output is being written to
* @param jar is the stream to write to
* @param alreadyAddedEntries is used to avoid duplicate entries.
*/
private static void copyZipEntriesToJar(Path inputFile, Path outputFile, final CustomZipOutputStream jar, Set<String> alreadyAddedEntries, JavacEventSink eventSink, Iterable<Pattern> blacklist) throws IOException {
try (ZipFile zip = new ZipFile(inputFile.toFile())) {
for (Enumeration<? extends ZipEntry> entries = zip.entries(); entries.hasMoreElements(); ) {
ZipEntry entry = entries.nextElement();
String entryName = entry.getName();
// We already read the manifest. No need to read it again
if (JarFile.MANIFEST_NAME.equals(entryName)) {
continue;
}
// Check if the entry belongs to the blacklist and it should be excluded from the Jar.
if (shouldEntryBeRemovedFromJar(eventSink, entryName, blacklist)) {
continue;
}
// duplicate class files.
if (!isDuplicateAllowed(entryName) && !alreadyAddedEntries.add(entryName)) {
// Duplicate entries. Skip.
eventSink.reportEvent(determineSeverity(entry), "Duplicate found when adding '%s' to '%s' from '%s'", entryName, outputFile.toAbsolutePath(), inputFile.toAbsolutePath());
continue;
}
ZipEntry newEntry = new ZipEntry(entry);
// See https://github.com/spearce/buck/commit/8338c1c3d4a546f577eed0c9941d9f1c2ba0a1b7.
if (entry.getMethod() == ZipEntry.DEFLATED) {
newEntry.setCompressedSize(-1);
}
jar.putNextEntry(newEntry);
try (InputStream inputStream = zip.getInputStream(entry)) {
ByteStreams.copy(inputStream, jar);
}
jar.closeEntry();
}
} catch (ZipException e) {
throw new IOException("Failed to process zip file " + inputFile + ": " + e.getMessage(), e);
}
}
use of java.util.zip.ZipException in project jetty.project by eclipse.
the class CompressExtension method outgoingFrame.
@Override
public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode) {
if (flusher.isFailed()) {
notifyCallbackFailure(callback, new ZipException());
return;
}
FrameEntry entry = new FrameEntry(frame, callback, batchMode);
if (LOG.isDebugEnabled())
LOG.debug("Queuing {}", entry);
offerEntry(entry);
flusher.iterate();
}
use of java.util.zip.ZipException in project j2objc by google.
the class AbstractZipFileTest method testConstructorFailsWhenReadingEmptyZipArchive.
/**
* RI does not allow reading of an empty zip using a {@link ZipFile}.
*/
public void testConstructorFailsWhenReadingEmptyZipArchive() throws IOException {
File resources = Support_Resources.createTempFolder();
File emptyZip = Support_Resources.copyFile(resources, "java/util/zip", "EmptyArchive.zip");
try {
// The following should fail with an exception but if it doesn't then we need to clean
// up the resource so we need a reference to it.
ZipFile zipFile = new ZipFile(emptyZip);
// Clean up the resource.
try {
zipFile.close();
} catch (Exception e) {
// Ignore
}
fail();
} catch (ZipException expected) {
// expected
}
}
Aggregations