* added helper function for testing 7z JBinding native code with a simple version call
This commit is contained in:
parent
94b87b0c3a
commit
2a64e1fe99
|
@ -6,6 +6,7 @@ import net.sf.sevenzipjbinding.IArchiveOpenCallback;
|
|||
import net.sf.sevenzipjbinding.IInArchive;
|
||||
import net.sf.sevenzipjbinding.IInStream;
|
||||
import net.sf.sevenzipjbinding.SevenZip;
|
||||
import net.sf.sevenzipjbinding.SevenZipException;
|
||||
import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
|
@ -37,15 +38,16 @@ public class SevenZipLoader {
|
|||
}
|
||||
}
|
||||
|
||||
public static IInArchive open(IInStream stream, IArchiveOpenCallback callback) throws Exception {
|
||||
// initialize 7-Zip-JBinding
|
||||
public static String getNativeVersion() throws SevenZipNativeInitializationException {
|
||||
requireNativeLibraries();
|
||||
|
||||
if (callback == null) {
|
||||
return SevenZip.openInArchive(null, stream);
|
||||
} else {
|
||||
return SevenZip.openInArchive(null, stream, callback);
|
||||
}
|
||||
return SevenZip.getSevenZipVersion().version;
|
||||
}
|
||||
|
||||
public static IInArchive open(IInStream stream, IArchiveOpenCallback callback) throws SevenZipException, SevenZipNativeInitializationException {
|
||||
requireNativeLibraries();
|
||||
|
||||
return (callback == null) ? SevenZip.openInArchive(null, stream) : SevenZip.openInArchive(null, stream, callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.io.File;
|
|||
import java.io.FileFilter;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
@ -29,17 +28,14 @@ public class SevenZipNativeBindings implements ArchiveExtractor, Closeable {
|
|||
throw new FileNotFoundException(file.getAbsolutePath());
|
||||
}
|
||||
|
||||
try {
|
||||
openVolume = new ArchiveOpenVolumeCallback();
|
||||
if (!Archive.hasMultiPartIndex(file)) {
|
||||
// single volume archives and multi-volume rar archives
|
||||
inArchive = SevenZipLoader.open(openVolume.getStream(file.getAbsolutePath()), openVolume);
|
||||
} else {
|
||||
// raw multi-volume archives
|
||||
inArchive = SevenZipLoader.open(new net.sf.sevenzipjbinding.impl.VolumedArchiveInStream(file.getAbsolutePath(), openVolume), null);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
throw (Exception) e.getTargetException();
|
||||
openVolume = new ArchiveOpenVolumeCallback();
|
||||
|
||||
if (!Archive.hasMultiPartIndex(file)) {
|
||||
// single volume archives and multi-volume rar archives
|
||||
inArchive = SevenZipLoader.open(openVolume.getStream(file.getAbsolutePath()), openVolume);
|
||||
} else {
|
||||
// raw multi-volume archives
|
||||
inArchive = SevenZipLoader.open(new net.sf.sevenzipjbinding.impl.VolumedArchiveInStream(file.getAbsolutePath(), openVolume), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue