* update to 7-Zip-JBinding 9.20-2.00beta
This commit is contained in:
parent
89597bb989
commit
3a02d6e16f
|
@ -6,7 +6,6 @@
|
|||
<classpathentry kind="lib" path="lib/ivy/bundle/args4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/bundle/json-simple.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jars/jacksum.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jars/sevenzipjbinding.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jars/simmetrics.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jars/xmlrpc.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/ehcache.jar"/>
|
||||
|
@ -30,5 +29,6 @@
|
|||
<classpathentry kind="lib" path="lib/ivy/jar/junrar.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/commons-vfs2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/commons-logging.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/sevenzipjbinding.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
<exclude name="META-INF/services/org.codehaus.groovy.runtime.ExtensionModule" />
|
||||
</zipfileset>
|
||||
|
||||
<zipfileset src="${dir.lib}/jars/sevenzipjbinding.jar">
|
||||
<zipfileset src="${dir.lib}/ivy/jar/sevenzipjbinding.jar">
|
||||
<include name="net/sf/sevenzipjbinding/**" />
|
||||
</zipfileset>
|
||||
|
||||
|
|
1
ivy.xml
1
ivy.xml
|
@ -21,6 +21,7 @@
|
|||
<dependency org="org.apache.commons" name="commons-vfs2" rev="2.0" />
|
||||
<dependency org="com.github.junrar" name="junrar" rev="0.7" />
|
||||
<dependency org="com.fifesoft" name="rsyntaxtextarea" rev="2.5.8" />
|
||||
<dependency org="net.sf.sevenzipjbinding" name="sevenzipjbinding" rev="9.20-2.00beta" />
|
||||
|
||||
<!-- FileBot Scripting -->
|
||||
<dependency org="org.apache.ant" name="ant" rev="1.9.4" />
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -75,7 +75,7 @@ public class Archive implements Closeable {
|
|||
return extensions;
|
||||
}
|
||||
|
||||
private static final Pattern multiPartIndex = Pattern.compile("[.][0-9]{3}+$");
|
||||
private static final Pattern multiPartIndex = Pattern.compile("[.][0-9]{3}$");
|
||||
|
||||
public static boolean hasMultiPartIndex(File file) {
|
||||
return multiPartIndex.matcher(file.getName()).find();
|
||||
|
|
|
@ -10,20 +10,20 @@ import net.sf.sevenzipjbinding.ExtractAskMode;
|
|||
import net.sf.sevenzipjbinding.ExtractOperationResult;
|
||||
import net.sf.sevenzipjbinding.IArchiveExtractCallback;
|
||||
import net.sf.sevenzipjbinding.ISequentialOutStream;
|
||||
import net.sf.sevenzipjbinding.ISevenZipInArchive;
|
||||
import net.sf.sevenzipjbinding.IInArchive;
|
||||
import net.sf.sevenzipjbinding.PropID;
|
||||
import net.sf.sevenzipjbinding.SevenZipException;
|
||||
|
||||
|
||||
class ExtractCallback implements IArchiveExtractCallback {
|
||||
|
||||
private ISevenZipInArchive inArchive;
|
||||
private IInArchive inArchive;
|
||||
private ExtractOutProvider extractOut;
|
||||
|
||||
private ExtractOutStream output = null;
|
||||
|
||||
|
||||
public ExtractCallback(ISevenZipInArchive inArchive, ExtractOutProvider extractOut) {
|
||||
public ExtractCallback(IInArchive inArchive, ExtractOutProvider extractOut) {
|
||||
this.inArchive = inArchive;
|
||||
this.extractOut = extractOut;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
|
||||
package net.filebot.archive;
|
||||
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.sevenzipjbinding.IArchiveOpenCallback;
|
||||
import net.sf.sevenzipjbinding.IInArchive;
|
||||
import net.sf.sevenzipjbinding.IInStream;
|
||||
import net.sf.sevenzipjbinding.ISevenZipInArchive;
|
||||
import net.sf.sevenzipjbinding.SevenZip;
|
||||
import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
|
||||
|
||||
public class SevenZipLoader {
|
||||
|
||||
private static boolean nativeLibrariesLoaded = false;
|
||||
|
||||
|
||||
private static synchronized void requireNativeLibraries() throws SevenZipNativeInitializationException {
|
||||
if (nativeLibrariesLoaded) {
|
||||
return;
|
||||
|
@ -26,14 +22,14 @@ public class SevenZipLoader {
|
|||
// initialize 7z-JBinding native libs
|
||||
try {
|
||||
try {
|
||||
if (Platform.isWindows()) {
|
||||
System.loadLibrary(Platform.is64Bit() ? "libgcc_s_sjlj-1" : "mingwm10");
|
||||
if (Platform.isWindows() && Platform.is64Bit()) {
|
||||
System.loadLibrary("libgcc_s_seh-1");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(SevenZipLoader.class.getName()).warning("Failed to preload library: " + e);
|
||||
}
|
||||
|
||||
System.loadLibrary("7-Zip-JBinding");
|
||||
System.loadLibrary("lib7-Zip-JBinding");
|
||||
SevenZip.initLoadedLibraries(); // NATIVE LIBS MUST BE LOADED WITH SYSTEM CLASSLOADER
|
||||
nativeLibrariesLoaded = true;
|
||||
} catch (Throwable e) {
|
||||
|
@ -41,8 +37,7 @@ public class SevenZipLoader {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static ISevenZipInArchive open(IInStream stream, IArchiveOpenCallback callback) throws Exception {
|
||||
public static IInArchive open(IInStream stream, IArchiveOpenCallback callback) throws Exception {
|
||||
// initialize 7-Zip-JBinding
|
||||
requireNativeLibraries();
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@ import java.util.Map;
|
|||
import net.filebot.vfs.FileInfo;
|
||||
import net.filebot.vfs.SimpleFileInfo;
|
||||
import net.sf.sevenzipjbinding.ArchiveFormat;
|
||||
import net.sf.sevenzipjbinding.ISevenZipInArchive;
|
||||
import net.sf.sevenzipjbinding.IInArchive;
|
||||
import net.sf.sevenzipjbinding.PropID;
|
||||
import net.sf.sevenzipjbinding.SevenZipException;
|
||||
|
||||
public class SevenZipNativeBindings implements ArchiveExtractor, Closeable {
|
||||
|
||||
private ISevenZipInArchive inArchive;
|
||||
private IInArchive inArchive;
|
||||
private ArchiveOpenVolumeCallback openVolume;
|
||||
|
||||
public SevenZipNativeBindings(File file) throws Exception {
|
||||
|
@ -36,7 +36,7 @@ public class SevenZipNativeBindings implements ArchiveExtractor, Closeable {
|
|||
inArchive = SevenZipLoader.open(openVolume.getStream(file.getAbsolutePath()), openVolume);
|
||||
} else {
|
||||
// raw multi-volume archives
|
||||
inArchive = SevenZipLoader.open(new VolumedArchiveInStream(file.getAbsolutePath(), openVolume), null);
|
||||
inArchive = SevenZipLoader.open(new net.sf.sevenzipjbinding.impl.VolumedArchiveInStream(file.getAbsolutePath(), openVolume), null);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
throw (Exception) e.getTargetException();
|
||||
|
|
|
@ -1,184 +0,0 @@
|
|||
|
||||
package net.filebot.archive;
|
||||
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.sevenzipjbinding.IArchiveOpenVolumeCallback;
|
||||
import net.sf.sevenzipjbinding.IInStream;
|
||||
import net.sf.sevenzipjbinding.PropID;
|
||||
import net.sf.sevenzipjbinding.SevenZipException;
|
||||
|
||||
|
||||
public class VolumedArchiveInStream implements IInStream {
|
||||
|
||||
private static final String FIRST_VOLUME_POSTFIX = ".001";
|
||||
|
||||
private long absoluteOffset;
|
||||
private long absoluteLength = -1;
|
||||
|
||||
private int currentIndex = -1;
|
||||
private IInStream currentInStream;
|
||||
private long currentVolumeOffset;
|
||||
private long currentVolumeLength;
|
||||
private List<Long> volumePositions = new ArrayList<Long>();
|
||||
|
||||
private final IArchiveOpenVolumeCallback archiveOpenVolumeCallback;
|
||||
private String cuttedVolumeFilename;
|
||||
|
||||
|
||||
public VolumedArchiveInStream(IArchiveOpenVolumeCallback archiveOpenVolumeCallback) throws SevenZipException {
|
||||
this((String) archiveOpenVolumeCallback.getProperty(PropID.NAME), archiveOpenVolumeCallback);
|
||||
}
|
||||
|
||||
|
||||
public VolumedArchiveInStream(String firstVolumeFilename, IArchiveOpenVolumeCallback archiveOpenVolumeCallback) throws SevenZipException {
|
||||
this.archiveOpenVolumeCallback = archiveOpenVolumeCallback;
|
||||
volumePositions.add(Long.valueOf(0));
|
||||
|
||||
if (!firstVolumeFilename.endsWith(FIRST_VOLUME_POSTFIX)) {
|
||||
throw new SevenZipException("The first volume filename '" + firstVolumeFilename + "' don't ends with the postfix: '" + FIRST_VOLUME_POSTFIX + "'. Can't proceed");
|
||||
|
||||
}
|
||||
|
||||
cuttedVolumeFilename = firstVolumeFilename.substring(0, firstVolumeFilename.length() - 3);
|
||||
openVolume(1, true);
|
||||
}
|
||||
|
||||
|
||||
private void openVolume(int index, boolean seekToBegin) throws SevenZipException {
|
||||
if (currentIndex == index) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = volumePositions.size(); i < index && absoluteLength == -1; i++) {
|
||||
openVolume(i, false);
|
||||
}
|
||||
|
||||
if (absoluteLength != -1 && volumePositions.size() <= index) {
|
||||
return;
|
||||
}
|
||||
|
||||
String volumeFilename = cuttedVolumeFilename + MessageFormat.format("{0,number,000}", Integer.valueOf(index));
|
||||
|
||||
// Get new IInStream
|
||||
IInStream newInStream = archiveOpenVolumeCallback.getStream(volumeFilename);
|
||||
|
||||
if (newInStream == null) {
|
||||
absoluteLength = volumePositions.get(volumePositions.size() - 1).longValue();
|
||||
return;
|
||||
}
|
||||
|
||||
currentInStream = newInStream;
|
||||
|
||||
if (volumePositions.size() == index) {
|
||||
// Determine volume size
|
||||
currentVolumeLength = currentInStream.seek(0, SEEK_END);
|
||||
if (currentVolumeLength == 0) {
|
||||
throw new RuntimeException("Volume " + index + " is empty");
|
||||
}
|
||||
volumePositions.add(Long.valueOf(volumePositions.get(index - 1).longValue() + currentVolumeLength));
|
||||
|
||||
if (seekToBegin) {
|
||||
currentInStream.seek(0, SEEK_SET);
|
||||
}
|
||||
} else {
|
||||
currentVolumeLength = volumePositions.get(index).longValue() - volumePositions.get(index - 1).longValue();
|
||||
}
|
||||
|
||||
if (seekToBegin) {
|
||||
currentVolumeOffset = 0;
|
||||
absoluteOffset = volumePositions.get(index - 1).longValue();
|
||||
}
|
||||
|
||||
currentIndex = index;
|
||||
}
|
||||
|
||||
|
||||
private void openVolumeToAbsoluteOffset() throws SevenZipException {
|
||||
int index = volumePositions.size() - 1;
|
||||
if (absoluteLength != -1 && absoluteOffset >= absoluteLength) {
|
||||
return;
|
||||
}
|
||||
while (volumePositions.get(index).longValue() > absoluteOffset) {
|
||||
index--;
|
||||
}
|
||||
|
||||
if (index < volumePositions.size() - 1) {
|
||||
openVolume(index + 1, false);
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
index++;
|
||||
openVolume(index, false);
|
||||
} while ((absoluteLength == -1 || absoluteOffset < absoluteLength) && volumePositions.get(index).longValue() <= absoluteOffset);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long seek(long offset, int seekOrigin) throws SevenZipException {
|
||||
long newOffset;
|
||||
boolean proceedWithSeek = false;
|
||||
switch (seekOrigin) {
|
||||
case SEEK_SET:
|
||||
newOffset = offset;
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
newOffset = absoluteOffset + offset;
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
if (absoluteLength == -1) {
|
||||
openVolume(Integer.MAX_VALUE, false);
|
||||
proceedWithSeek = true;
|
||||
}
|
||||
newOffset = absoluteLength + offset;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Seek: unknown origin: " + seekOrigin);
|
||||
}
|
||||
|
||||
if (newOffset == absoluteOffset && !proceedWithSeek) {
|
||||
return newOffset;
|
||||
}
|
||||
absoluteOffset = newOffset;
|
||||
|
||||
openVolumeToAbsoluteOffset();
|
||||
|
||||
if (absoluteLength != -1 && absoluteLength <= absoluteOffset) {
|
||||
absoluteOffset = absoluteLength;
|
||||
return absoluteLength;
|
||||
}
|
||||
|
||||
currentVolumeOffset = absoluteOffset - volumePositions.get(currentIndex - 1).longValue();
|
||||
currentInStream.seek(currentVolumeOffset, SEEK_SET);
|
||||
|
||||
return newOffset;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int read(byte[] data) throws SevenZipException {
|
||||
if (absoluteLength != -1 && absoluteOffset >= absoluteLength) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int read = currentInStream.read(data);
|
||||
|
||||
absoluteOffset += read;
|
||||
currentVolumeOffset += read;
|
||||
|
||||
if (currentVolumeOffset >= currentVolumeLength) {
|
||||
openVolume(currentIndex + 1, true);
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue