Exception is properly created by jni wrapper.

No need to do the check in java code.
This commit is contained in:
Matthieu Gautier 2023-06-30 11:20:10 +02:00
parent 36ad3c0331
commit 33152da9b4

View File

@ -31,26 +31,17 @@ public class Archive
public Archive(String filename) throws ZimFileFormatException public Archive(String filename) throws ZimFileFormatException
{ {
setNativeArchive(filename); setNativeArchive(filename);
if (nativeHandle == 0) {
throw new ZimFileFormatException("Cannot open zimfile "+filename);
}
} }
public Archive(FileDescriptor fd) throws ZimFileFormatException public Archive(FileDescriptor fd) throws ZimFileFormatException
{ {
setNativeArchiveByFD(fd); setNativeArchiveByFD(fd);
if (nativeHandle == 0) {
throw new ZimFileFormatException("Cannot open zimfile by fd "+fd.toString());
}
} }
public Archive(FileDescriptor fd, long offset, long size) public Archive(FileDescriptor fd, long offset, long size)
throws ZimFileFormatException throws ZimFileFormatException
{ {
setNativeArchiveEmbedded(fd, offset, size); setNativeArchiveEmbedded(fd, offset, size);
if (nativeHandle == 0) {
throw new ZimFileFormatException(String.format("Cannot open embedded zimfile (fd=%s, offset=%d, size=%d)", fd, offset, size));
}
} }
public native String getFilename(); public native String getFilename();