More fixes in zip entries for path

This commit is contained in:
2026-04-18 20:41:03 +02:00
parent 3cc928ebc8
commit 5924ca5647

View File

@@ -72,12 +72,24 @@ public final class ZipEntryPath implements Path {
@Override @Override
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {
if (this.zipFilePath.exists()) {
ZipFile zipFile = new ZipFile(this.zipFilePath.absolutePath.toFile()); ZipFile zipFile = new ZipFile(this.zipFilePath.absolutePath.toFile());
return new ZipEntryInputStream(zipFile, ZipEntry zipEntry = zipFile.getEntry(this.entryName);
zipFile.getInputStream(zipFile.getEntry(this.entryName))); if (zipEntry != null) {
return new ZipEntryInputStream(zipFile, zipFile.getInputStream(zipEntry));
} else {
throw new IOException("Zip entry does not exist.");
}
} else {
throw new IOException("Zip file does not exist.");
}
} }
private void fetchEntryData() { private void fetchEntryData() {
if (!this.zipFilePath.exists()) {
return;
}
try (ZipFile zipFile = new ZipFile(this.zipFilePath.absolutePath.toFile())) { try (ZipFile zipFile = new ZipFile(this.zipFilePath.absolutePath.toFile())) {
ZipEntry zipEntry = zipFile.getEntry(this.entryName); ZipEntry zipEntry = zipFile.getEntry(this.entryName);
this.exists = zipEntry != null; this.exists = zipEntry != null;