Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
moving the J7Zip-modified source and Maven build to libbuild from main pom. Using source included in j7zip-modified.jar. This combines all external lib preparation in the libbuild main pom.
reger96b8d9b09e2b
diff --git a/libbuild/J7Zip-modified/pom.xml b/libbuild/J7Zip-modified/pom.xmlnew file mode 100644index 000000000..84f850369--- /dev/null+++ b/libbuild/J7Zip-modified/pom.xml@@ -0,0 +1,32 @@+<?xml version="1.0" encoding="UTF-8"?>+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">+ <modelVersion>4.0.0</modelVersion>++ <parent>+ <groupId>net.yacy</groupId>+ <artifactId>extlib</artifactId>+ <version>1.0</version>+ </parent>++ <groupId>net.yacy.extlib</groupId>+ <artifactId>J7Zip-modified</artifactId>+ <packaging>jar</packaging>+ <version>1.02</version>+ <description>J7Zip library for YaCy sevenzipParser (not available in external maven repository)</description>++ <licenses>+ <license>+ <name>GNU Lesser General Public License 2.1</name>+ <url>http://www.gnu.org/licenses/lgpl-2.1.txt</url>+ </license>+ </licenses>++ <properties>+ <maven.compiler.source>1.7</maven.compiler.source>+ <maven.compiler.target>1.7</maven.compiler.target>+ </properties>++ <build>+ <sourceDirectory>src</sourceDirectory>+ </build>+</project>\ No newline at end of filediff --git a/libbuild/J7Zip-modified/src/Common/BoolVector.java b/libbuild/J7Zip-modified/src/Common/BoolVector.javanew file mode 100644index 000000000..903c1b24e--- /dev/null+++ b/libbuild/J7Zip-modified/src/Common/BoolVector.java@@ -0,0 +1,101 @@+package Common;++import java.util.Collection;+import java.util.Iterator;++public class BoolVector {++ protected boolean[] data;+ int capacityIncr = 10;+ int elt = 0;++ public BoolVector() {+ this.data = new boolean[10];+ }++ public BoolVector(int size) {+ this.data = new boolean[size];+ }++ public int size() {+ return elt;+ }++ public void ensureAdditionalCapacity(int addCapacity) {+ ensureCapacity(data.length + addCapacity);+ }++ private void ensureCapacity(int minCapacity) {+ int oldCapacity = data.length;+ if (minCapacity > oldCapacity) {+ boolean [] oldData = data;+ int newCapacity = oldCapacity + capacityIncr;+ if (newCapacity < minCapacity) {+ newCapacity = minCapacity;+ }+ data = new boolean[newCapacity];+ System.arraycopy(oldData, 0, data, 0, elt);+ }+ }++ public boolean get(int index) {+ if (index >= elt)+ throw new ArrayIndexOutOfBoundsException(index);++ return data[index];+ }++ public void Reserve(int s) {+ ensureCapacity(s);+ }++ public void add(boolean b) {+ ensureCapacity(elt + 1);+ data[elt++] = b;+ }++ public void addAll(Collection c) {+ ensureCapacity(elt + c.size());+ Iterator it = c.iterator();+ while (it.hasNext())+ data[elt++] = ((Boolean)it.next()).booleanValue();+ }++ public void addAll(Boolean[] b) {+ ensureCapacity(elt + b.length);+ for (int i=0; i<b.length; i++)+ data[elt++] = ((Boolean)b[i]).booleanValue();+ }++ public void set(int index, boolean value) {+ if (index >= data.length)+ throw new ArrayIndexOutOfBoundsException(index);+ data[index] = value;+ elt = index + 1;+ }++ public void setRange(int start, boolean value) {+ setRange(start, data.length - start, value);+ }++ public void setRange(int start, int length, boolean value) {+ if (start + length > data.length)+ throw new ArrayIndexOutOfBoundsException("start = " + start + ", length = " + length);+ for (int i=0; i<length; i++)+ data[start + i] = value;+ elt = start + length;+ }++ public void setBoolVector(BoolVector v) {+ this.data = v.data;+ this.elt = v.elt;+ }++ public void clear() {+ elt = 0;+ }++ public boolean isEmpty() {+ return elt == 0;+ }+}diff --git a/libbuild/J7Zip-modified/src/Common/CRC.java b/libbuild/J7Zip-modified/src/Common/CRC.javanew file mode 100644index 000000000..ff38ad431--- /dev/null+++ b/libbuild/J7Zip-modified/src/Common/CRC.java@@ -0,0 +1,71 @@+package Common;++public class CRC {+ public static final int[] Table = new int[256];++ static {+ for (int i = 0; i < 256; i++) {+ int r = i;+ for (int j = 0; j < 8; j++) {+ if ((r & 1) != 0)+ r = (r >>> 1) ^ 0xEDB88320;+ else+ r >>>= 1;+ }+ Table[i] = r;+ }+ }++ int _value = -1;++ public void Init() {+ _value = -1;+ }++ public void UpdateByte(int b) {+ _value = Table[(_value ^ b) & 0xFF] ^ (_value >>> 8);+ }++ public void UpdateUInt32(int v) {+ for (int i = 0; i < 4; i++)+ UpdateByte((v >> (8 * i)) & 0xFF );+ }++ public void UpdateUInt64(long v) {+ for (int i = 0; i < 8; i++)+ UpdateByte((int)((v >> (8 * i))) & 0xFF);+ }++ public int GetDigest() {+ return _value ^ (-1);+ }++ public void Update(byte[] data, int size) {+ for (int i = 0; i < size; i++)+ _value = Table[(_value ^ data[i]) & 0xFF] ^ (_value >>> 8);+ }++ public void Update(byte[] data) {+ for (int i = 0; i < data.length; i++)+ _value = Table[(_value ^ data[i]) & 0xFF] ^ (_value >>> 8);+ }++ public void Update(byte[] data, int offset, int size) {+ for (int i = 0; i < size; i++)+ _value = Table[(_value ^ data[offset + i]) & 0xFF] ^ (_value >>> 8);+ }++ public static int CalculateDigest(byte [] data, int size) {+ CRC crc = new CRC();+ crc.Update(data, size);+ return crc.GetDigest();+ }++ public static boolean VerifyDigest(int digest, byte [] data, int size) {+ return (CalculateDigest(data, size) == digest);+ }++ public String toString() {+ return Integer.toHexString(GetDigest());+ }+}diff --git a/libbuild/J7Zip-modified/src/Common/IntVector.java b/libbuild/J7Zip-modified/src/Common/IntVector.javanew file mode 100644index 000000000..8d69c88d6--- /dev/null+++ b/libbuild/J7Zip-modified/src/Common/IntVector.java@@ -0,0 +1,129 @@+package Common;++import java.util.Collection;+import java.util.Iterator;++public class IntVector {+ protected int[] data = new int[10];+ int capacityIncr = 10;+ int elt = 0;++ public IntVector() {+ }++ public IntVector(int size) {+ this.data = new int[size];+ }++ public int size() {+ return elt;+ }++ public void ensureAdditionalCapacity(int addCapacity) {+ ensureCapacity(data.length + addCapacity);+ }++ private void ensureCapacity(int minCapacity) {+ int oldCapacity = data.length;+ if (minCapacity > oldCapacity) {+ int [] oldData = data;+ int newCapacity = oldCapacity + capacityIncr;+ if (newCapacity < minCapacity) {+ newCapacity = minCapacity;+ }+ data = new int[newCapacity];+ System.arraycopy(oldData, 0, data, 0, elt);+ }+ }++ public int get(int index) {+ if (index >= elt)+ throw new ArrayIndexOutOfBoundsException(index);++ return data[index];+ }++ public void Reserve(int s) {+ ensureCapacity(s);+ }++ public void add(int b) {+ ensureCapacity(elt + 1);+ data[elt++] = b;+ }++ public void addAll(Collection c) {+ ensureCapacity(elt + c.size());+ Iterator it = c.iterator();+ while (it.hasNext())+ data[elt++] = ((Integer)it.next()).intValue();+ }++ public void addAll(Integer[] b) {+ ensureCapacity(elt + b.length);+ for (int i=0; i<b.length; i++)+ data[elt++] = ((Integer)b[i]).intValue();+ }++ public void set(int index, int value) {+ if (index >= data.length)+ throw new ArrayIndexOutOfBoundsException(index);+ data[index] = value;+ elt = index + 1;+ }++ public void setRange(int start, int value) {+ setRange(start, data.length - start, value);+ }++ public void setRange(int start, int length, int value) {+ if (start + length > data.length)+ throw new ArrayIndexOutOfBoundsException("start = " + start + ", length = " + length);+ for (int i=0; i<length; i++)+ data[start + i] = value;+ elt = start + length;+ }++ public void clear() {+ elt = 0;+ }++ public boolean isEmpty() {+ return elt == 0;+ }++ public int Back() {+ if (elt < 1)+ throw new ArrayIndexOutOfBoundsException(0);++ return data[elt-1];+ }++ public int Front() {+ if (elt < 1)+ throw new ArrayIndexOutOfBoundsException(0);++ return data[0];+ }++ public void DeleteBack() {+ // Delete(_size - 1);+ remove(elt-1);+ }++ public int remove(int index) {+ if (index >= elt)+ throw new ArrayIndexOutOfBoundsException(index);+ int oldValue = data[index];++ int numMoved = elt - index - 1;+ Integer n = new Integer(elt);+ if (numMoved > 0)+ System.arraycopy(n, index+1, n, index,numMoved);+ elt = n.intValue();+ // data[--elt] = null; // Let gc do its work++ return oldValue;+ }++}diff --git a/libbuild/J7Zip-modified/src/Common/LimitedSequentialInStream.java b/libbuild/J7Zip-modified/src/Common/LimitedSequentialInStream.javanew file mode 100644index 000000000..54492a662--- /dev/null+++ b/libbuild/J7Zip-modified/src/Common/LimitedSequentialInStream.java@@ -0,0 +1,54 @@+package Common;++import java.io.InputStream;++public class LimitedSequentialInStream extends InputStream {+ final InputStream _stream; // ISequentialInStream+ final long _size;+ long _pos;+ boolean _wasFinished;++ public LimitedSequentialInStream(InputStream stream, long streamSize) {+ _stream = stream;+ _size = streamSize;+ _pos = 0;+ _wasFinished = false;+ }++ /*+ public void SetStream(InputStream stream) { // ISequentialInStream+ _stream = stream;+ }++ public void Init(long streamSize) {+ _size = streamSize;+ _pos = 0;+ _wasFinished = false;+ }*/++ public int read() throws java.io.IOException {+ int ret = _stream.read();+ if (ret == -1) _wasFinished = true;+ return ret;+ }++ public int read(byte [] data,int off, int size) throws java.io.IOException {+ long sizeToRead2 = (_size - _pos);+ if (size < sizeToRead2) sizeToRead2 = size;++ int sizeToRead = (int)sizeToRead2;++ if (sizeToRead > 0) {+ int realProcessedSize = _stream.read(data, off, sizeToRead);+ if (realProcessedSize == -1) {+ _wasFinished = true;+ return -1;+ }+ _pos += realProcessedSize;+ return realProcessedSize;+ }++ return -1; // EOF+ }+}+diff --git a/libbuild/J7Zip-modified/src/Common/LockedInStream.java b/libbuild/J7Zip-modified/src/Common/LockedInStream.javanew file mode 100644index 000000000..76eeec588--- /dev/null+++ b/libbuild/J7Zip-modified/src/Common/LockedInStream.java@@ -0,0 +1,38 @@+package Common;++import java.io.IOException;+import SevenZip.IInStream;++public class LockedInStream {++ final IInStream _stream;++ public LockedInStream(IInStream stream) {+ this._stream = stream;+ }+ /*+ public void Init(IInStream stream) {+ _stream = stream;+ }*/++ /* really too slow, don't use !+ public synchronized int read(long startPos) throws java.io.IOException+ {+ // NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);+ _stream.Seek(startPos, IInStream.STREAM_SEEK_SET);+ return _stream.read();+ }+ */++ public synchronized int read(long startPos, byte [] data, int size) throws IOException {+ // NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);+ _stream.Seek(startPos, IInStream.STREAM_SEEK_SET);+ return _stream.read(data,0, size);+ }++ public synchronized int read(long startPos, byte [] data, int off, int size) throws IOException {+ // NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);+ _stream.Seek(startPos, IInStream.STREAM_SEEK_SET);+ return _stream.read(data,off, size);+ }+}diff --git a/libbuild/J7Zip-modified/src/Common/LockedSequentialInStreamImp.java b/libbuild/J7Zip-modified/src/Common/LockedSequentialInStreamImp.javanew file mode 100644index 000000000..e0689f739--- /dev/null+++ b/libbuild/J7Zip-modified/src/Common/LockedSequentialInStreamImp.java@@ -0,0 +1,41 @@+package Common;++import java.io.InputStream;++public class LockedSequentialInStreamImp extends InputStream {+ final LockedInStream _lockedInStream;+ long _pos;++ public LockedSequentialInStreamImp(LockedInStream lockedInStream, long startPos) {+ _lockedInStream = lockedInStream;+ _pos = startPos;+ }++ /*+ public void Init(LockedInStream lockedInStream, long startPos) {+ _lockedInStream = lockedInStream;+ _pos = startPos;+ }*/++ public int read() throws java.io.IOException {+ throw new java.io.IOException("LockedSequentialInStreamImp : read() not implemented");+ /*+ int ret = _lockedInStream.read(_pos);+ if (ret == -1) return -1; // EOF++ _pos += 1;++ return ret;+ */+ }++ public int read(byte [] data, int off, int size) throws java.io.IOException {+ int realProcessedSize = _lockedInStream.read(_pos, data,off, size);+ if (realProcessedSize == -1) return -1; // EOF++ _pos += realProcessedSize;++ return realProcessedSize;+ }++}diff --git a/libbuild/J7Zip-modified/src/Common/LongVector.java b/libbuild/J7Zip-modified/src/Common/LongVector.javanew file mode 100644index 000000000..cb2b29f1e--- /dev/null+++ b/libbuild/J7Zip-modified/src/Common/LongVector.java@@ -0,0 +1,126 @@+package Common;++import java.util.Collection;+import java.util.Iterator;++public class LongVector {+ protected long[] data = new long[10];+ int capacityIncr = 10;+ int elt = 0;++ public LongVector() {+ }++ public int size() {+ return elt;+ }++ public void ensureAdditionalCapacity(int addCapacity) {+ ensureCapacity(data.length + addCapacity);+ }++ private void ensureCapacity(int minCapacity) {+ int oldCapacity = data.length;+ if (minCapacity > oldCapacity) {+ long [] oldData = data;+ int newCapacity = oldCapacity + capacityIncr;+ if (newCapacity < minCapacity) {+ newCapacity = minCapacity;+ }+ data = new long[newCapacity];+ System.arraycopy(oldData, 0, data, 0, elt);+ }+ }++ public long get(int index) {+ if (index >= elt)+ throw new ArrayIndexOutOfBoundsException(index);++ return data[index];+ }++ public void Reserve(int s) {+ ensureCapacity(s);+ }++ public void add(long b) {+ ensureCapacity(elt + 1);+ data[elt++] = b;+ }++ public void addAll(Collection c) {+ ensureCapacity(elt + c.size());+ Iterator it = c.iterator();+ while (it.hasNext())+ data[elt++] = ((Long)it.next()).longValue();+ }++ public void addAll(Long[] b) {+ ensureCapacity(elt + b.length);+ for (int i=0; i<b.length; i++)+ data[elt++] = ((Long)b[i]).longValue();+ }++ public void set(int index, long value) {+ if (index >= data.length)+ throw new ArrayIndexOutOfBoundsException(index);+ data[index] = value;+ elt = index + 1;+ }++ public void setRange(int start, long value) {+ setRange(start, data.length - start, value);+ }++ public void setRange(int start, int length, long value) {+ if (start + length > data.length)+ throw new ArrayIndexOutOfBoundsException("start = " + start + ", length = " + length);+ for (int i=0; i<length; i++)+ data[start + i] = value;+ elt = start + length;+ }++ public void clear() {+ elt = 0;+ }++ public boolean isEmpty() {+ return elt == 0;+ }++ public long Back() {+ if (elt < 1)+ throw new ArrayIndexOutOfBoundsException(0);++ return data[elt-1];+ }++ public long Front() {+ if (elt < 1)+ throw new ArrayIndexOutOfBoundsException(0);++ return data[0];+ }++ public void DeleteBack() {+ // Delete(_size - 1);+ remove(elt-1);+ }++ // TODO+ public long remove(int index) {+ if (index >= elt)+ throw new ArrayIndexOutOfBoundsException(index);+ long oldValue = data[index];++ int numMoved = elt - index - 1;+ Integer n = new Integer(elt);+ if (numMoved > 0)+ System.arraycopy(n, index+1, n, index,numMoved);+ elt = n.intValue();+ // data[--elt] = null; // Let gc do its work++ return oldValue;+ }++}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/BindInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/BindInfo.javanew file mode 100644index 000000000..36c449952--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/BindInfo.java@@ -0,0 +1,104 @@+package SevenZip.Archive.Common;++import java.util.Vector;++import Common.IntVector;++public class BindInfo {++ public Vector Coders = new Vector();+ public Vector BindPairs = new Vector();+ public IntVector InStreams = new IntVector();+ public IntVector OutStreams = new IntVector();++ public void Clear() {+ Coders.clear();+ BindPairs.clear();+ InStreams.clear();+ OutStreams.clear();+ }++ public int FindBinderForInStream(int inStream) {+ for (int i = 0; i < BindPairs.size(); i++)+ if (((BindPair)BindPairs.get(i)).InIndex == inStream)+ return i;+ return -1;+ }++ public int FindBinderForOutStream(int outStream) // const+ {+ for (int i = 0; i < BindPairs.size(); i++)+ if (((BindPair)BindPairs.get(i)).OutIndex == outStream)+ return i;+ return -1;+ }++ public int GetCoderInStreamIndex(int coderIndex) // const+ {+ int streamIndex = 0;+ for (int i = 0; i < coderIndex; i++)+ streamIndex += ((CoderStreamsInfo)Coders.get(i)).NumInStreams;+ return streamIndex;+ }++ public int GetCoderOutStreamIndex(int coderIndex) // const+ {+ int streamIndex = 0;+ for (int i = 0; i < coderIndex; i++)+ streamIndex += ((CoderStreamsInfo)Coders.get(i)).NumOutStreams;+ return streamIndex;+ }++ /**+ * @param streamIndex+ * @return int[2], where the element at index 0 specifies the coder index number and+ * the element at index 1 is the stream index corresponding to the found coder index.+ * <p>Returns <code>null</code> if no InStream for <code>streamIndex</code> could be+ * found.</p>+ */+ public int[] FindInStream(int streamIndex) {+ for (int i=0; i<Coders.size(); i++) {+ int curSize = ((CoderStreamsInfo)Coders.get(i)).NumInStreams;+ if (streamIndex < curSize) {+ return new int[] { i, streamIndex };+ }+ streamIndex -= curSize;+ }+ return null;+ }++ /**+ * @param streamIndex+ * @return int[2], where the element at index 0 specifies the coder index number and+ * the element at index 1 is the stream index corresponding to the found coder index.+ * <p>Returns <code>null</code> if no OutStream for <code>streamIndex</code> could be+ * found.</p>+ */+ public int[] FindOutStream(int streamIndex) {+ for (int i=0; i<Coders.size(); i++) {+ int curSize = ((CoderStreamsInfo)Coders.get(i)).NumOutStreams;+ if (streamIndex < curSize)+ return new int[] { i, streamIndex };+ streamIndex -= curSize;+ }+ return null;+ }++ public boolean equals(Object obj) {+ if (obj instanceof BindInfo) {+ BindInfo arg = (BindInfo)obj;+ if (this.Coders.size() != arg.Coders.size()) return false;+ if (this.BindPairs.size() != arg.BindPairs.size()) return false;+ if (this.InStreams.size() != arg.InStreams.size()) return false;+ if (this.OutStreams.size() != arg.OutStreams.size()) return false;+ int i;+ for (i = 0; i < this.Coders.size(); i++)+ if (!this.Coders.get(i).equals(arg.Coders.get(i))) return false;+ for (i = 0; i < this.BindPairs.size(); i++)+ if (!this.BindPairs.get(i).equals(arg.BindPairs.get(i))) return false;+ return true;+ }+ return super.equals(obj);+ }+}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/BindPair.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/BindPair.javanew file mode 100644index 000000000..cfb6a7498--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/BindPair.java@@ -0,0 +1,19 @@+package SevenZip.Archive.Common;++public class BindPair {+ public int InIndex;+ public int OutIndex;++ public BindPair() {+ InIndex = 0;+ OutIndex = 0;+ }++ public boolean equals(Object obj) {+ if (obj instanceof BindPair) {+ BindPair arg = (BindPair)obj;+ return (this.InIndex == arg.InIndex) && (this.OutIndex == arg.OutIndex);+ }+ return super.equals(obj);+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderInfo.javanew file mode 100644index 000000000..8b1186367--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderInfo.java@@ -0,0 +1,51 @@+package SevenZip.Archive.Common;++import SevenZip.ICompressCoder;+import SevenZip.ICompressCoder2;++import Common.LongVector;++public class CoderInfo {+ ICompressCoder Coder;+ ICompressCoder2 Coder2;+ int NumInStreams;+ int NumOutStreams;++ LongVector InSizes = new LongVector();+ LongVector OutSizes = new LongVector();+ LongVector InSizePointers = new LongVector();+ LongVector OutSizePointers = new LongVector();++ public CoderInfo(int numInStreams, int numOutStreams) {+ NumInStreams = numInStreams;+ NumOutStreams = numOutStreams;+ InSizes.Reserve(NumInStreams);+ InSizePointers.Reserve(NumInStreams);+ OutSizePointers.Reserve(NumOutStreams);+ OutSizePointers.Reserve(NumOutStreams);+ }++ public static void SetSizes(+ LongVector srcSizes,+ LongVector sizes,+ LongVector sizePointers,+ int numItems) {+ sizes.clear();+ sizePointers.clear();+ for(int i = 0; i < numItems; i++) {+ if (srcSizes == null || srcSizes.get(i) == -1) // TBD null => -1+ {+ sizes.add(0L);+ sizePointers.add(-1);+ } else {+ sizes.add(srcSizes.get(i)); // sizes.Add(*srcSizes[i]);+ sizePointers.add(sizes.Back()); // sizePointers.Add(&sizes.Back());+ }+ }+ }++ public void SetCoderInfo(LongVector inSizes, LongVector outSizes) {+ SetSizes(inSizes, InSizes, InSizePointers, NumInStreams);+ SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderMixer2.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderMixer2.javanew file mode 100644index 000000000..e2ae4ef02--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderMixer2.java@@ -0,0 +1,12 @@+package SevenZip.Archive.Common;++import Common.LongVector;++public interface CoderMixer2 {++ void ReInit();++ // void setCoderInfos(Vector decoders, Folder folderInfo, LongVector packSizes);++ void SetCoderInfo(int coderIndex,LongVector inSizes, LongVector outSizes);+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderMixer2ST.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderMixer2ST.javanew file mode 100644index 000000000..3f71735eb--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderMixer2ST.java@@ -0,0 +1,133 @@+package SevenZip.Archive.Common;++import java.io.IOException;+import java.io.InputStream;+import java.io.OutputStream;+import java.util.Vector;++import SevenZip.ICompressCoder2;+import SevenZip.ICompressCoder;+import SevenZip.ICompressSetOutStreamSize;+import Common.LongVector;++import SevenZip.ICompressProgressInfo;++public class CoderMixer2ST implements ICompressCoder2, CoderMixer2 {++ final BindInfo bindInfo;+ Vector coders = new Vector();+ int mainCoderIndex;++ public CoderMixer2ST(BindInfo bindInfo) {+ this.bindInfo = bindInfo;+ }++ public void AddCoderCommon(boolean isMain) {+ CoderStreamsInfo csi = (CoderStreamsInfo)bindInfo.Coders.get(coders.size());+ coders.add(new STCoderInfo(csi.NumInStreams, csi.NumOutStreams, isMain));+ }++ public void AddCoder2(ICompressCoder2 coder, boolean isMain) {+ AddCoderCommon(isMain);+ ((STCoderInfo)coders.lastElement()).Coder2 = coder;+ }++ public void AddCoder(ICompressCoder coder, boolean isMain) {+ AddCoderCommon(isMain);+ ((STCoderInfo)coders.lastElement()).Coder = coder;+ }++ public void ReInit() {+ }++ public void SetCoderInfo(int coderIndex, LongVector inSizes, LongVector outSizes) {+ // _coders[coderIndex].SetCoderInfo(inSizes, outSizes);+ ((STCoderInfo)coders.get(coderIndex)).SetCoderInfo(inSizes, outSizes);+ }++ public OutputStream GetOutStream(+ Vector outStreams,+ // Object useless_outSizes, // const UInt64 **outSizes,+ int streamIndex) {+ return null;+ }++ public void Code(+ Vector inStreams,+ Object useless_inSizes, // const UInt64 ** inSizes ,+ int numInStreams,+ Vector outStreams,+ Object useless_outSizes, // const UInt64 ** /* outSizes */,+ int numOutStreams,+ ICompressProgressInfo progress) throws IOException {+ if (numInStreams != bindInfo.InStreams.size() || numOutStreams != bindInfo.OutStreams.size())+ throw new IllegalArgumentException("internal error: numInStreams != _bindInfo.InStreams.size() || numOutStreams != _bindInfo.OutStreams.size()");++ // Find main coder+ int mainCoderIndex = -1;+ for (int i=0; i<coders.size(); i++)+ if (((STCoderInfo)coders.get(i)).IsMain) {+ mainCoderIndex = i;+ break;+ }++ if (mainCoderIndex < 0)+ for (int i=0; i<coders.size(); i++)+ if (((STCoderInfo)coders.get(i)).NumInStreams > 1) {+ if (mainCoderIndex >= 0) // TODO: description, what exactly is not implemented+ throw new IOException("not implemented");+ mainCoderIndex = i;+ }++ if (mainCoderIndex < 0)+ mainCoderIndex = 0;++ // _mainCoderIndex = 0;+ // _mainCoderIndex = _coders.Size() - 1;+ CoderInfo mainCoder = (STCoderInfo)coders.get(mainCoderIndex);++ Vector seqInStreams = new Vector(); // CObjectVector< CMyComPtr<ISequentialInStream> >+ int startInIndex = bindInfo.GetCoderInStreamIndex(mainCoderIndex);+ for (int i=0; i<mainCoder.NumInStreams; i++)+ for (int j=0; j<bindInfo.InStreams.size(); j++)+ if (bindInfo.InStreams.get(j) == startInIndex + i)+ seqInStreams.add(inStreams.get(j));++ Vector seqOutStreams = new Vector(); // CObjectVector< CMyComPtr<ISequentialOutStream> >+ int startOutIndex = bindInfo.GetCoderOutStreamIndex(mainCoderIndex);+ for (int i=0; i<mainCoder.NumOutStreams; i++)+ for (int j=0; j<bindInfo.OutStreams.size(); j++)+ if (bindInfo.OutStreams.get(j) == startOutIndex + i)+ seqOutStreams.add(outStreams.get(j));++ for (int i=0; i<coders.size(); i++) {+ if (i == mainCoderIndex) continue;+ CoderInfo coder = (STCoderInfo)coders.get(i);+ ((ICompressSetOutStreamSize)coder.Coder).SetOutStreamSize(coder.OutSizePointers.Front());+ }++ if (mainCoder.Coder != null) {+ mainCoder.Coder.Code(+ (InputStream)seqInStreams.firstElement(),+ (OutputStream)seqOutStreams.firstElement(),+ mainCoder.OutSizePointers.Front(),+ progress);+ } else {+ mainCoder.Coder2.Code(+ seqInStreams,+ new Long(mainCoder.InSizePointers.Front()),+ mainCoder.NumInStreams,+ seqOutStreams,+ new Long(mainCoder.OutSizePointers.Front()),+ mainCoder.NumOutStreams,+ progress);+ }++ OutputStream stream = (OutputStream)seqOutStreams.firstElement();+ if (stream != null) stream.flush();+ }++ public void close() {++ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderStreamsInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderStreamsInfo.javanew file mode 100644index 000000000..d61716760--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/CoderStreamsInfo.java@@ -0,0 +1,19 @@+package SevenZip.Archive.Common;++public class CoderStreamsInfo {+ public int NumInStreams;+ public int NumOutStreams;++ public CoderStreamsInfo() {+ NumInStreams = 0;+ NumOutStreams = 0;+ }++ public boolean equals(Object obj) {+ if (obj instanceof CoderStreamsInfo) {+ CoderStreamsInfo arg = (CoderStreamsInfo)obj;+ return (this.NumInStreams == arg.NumInStreams) && (this.NumOutStreams != arg.NumOutStreams);+ }+ return super.equals(obj);+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/FilterCoder.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/FilterCoder.javanew file mode 100644index 000000000..46ffc188e--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/FilterCoder.java@@ -0,0 +1,147 @@+package SevenZip.Archive.Common;+++import SevenZip.HRESULT;+import java.io.IOException;+import SevenZip.ICompressCoder;+import SevenZip.ICompressSetOutStream;++/*+ // #ifdef _ST_MODE+ public ICompressSetInStream,+ public ISequentialInStream,+ public ICompressSetOutStream,+ public ISequentialOutStream,+ public IOutStreamFlush,+ // #endif+ */+public class FilterCoder extends java.io.OutputStream implements ICompressCoder , ICompressSetOutStream {++ public SevenZip.ICompressFilter Filter = null;++ java.io.OutputStream _outStream = null;+ int _bufferPos; // UInt32++ boolean _outSizeIsDefined;+ long _outSize;+ long _nowPos64;++ int Init() // HRESULT+ {+ _nowPos64 = 0;+ _outSizeIsDefined = false;+ return Filter.Init();+ }++ // ICompressCoder+ public void Code(+ java.io.InputStream inStream, // , ISequentialInStream+ java.io.OutputStream outStream, // ISequentialOutStream+ long outSize, SevenZip.ICompressProgressInfo progress) throws java.io.IOException {+ throw new java.io.IOException("Not implemented");+ }++ // java.io.OutputStream+ public void write(int b) {+ throw new UnknownError("FilterCoder write");+ }++ public void write(byte b[], int off, int size) throws IOException {+ if (b == null) {+ throw new NullPointerException();+ } else if ((off < 0) || (off > b.length) || (size < 0) ||+ ((off + size) > b.length) || ((off + size) < 0)) {+ throw new IndexOutOfBoundsException();+ } else if (size == 0) {+ return;+ }++ if (off != 0) throw new IOException("FilterCoder - off <> 0");++ byte [] cur_data = b;+ int cur_off = 0;+ while(size > 0) {+ int sizeMax = kBufferSize - _bufferPos;+ int sizeTemp = size;+ if (sizeTemp > sizeMax)+ sizeTemp = sizeMax;+ System.arraycopy(cur_data, cur_off, _buffer, _bufferPos , sizeTemp); // memmove(_buffer + _bufferPos, data, sizeTemp);+ size -= sizeTemp;+ cur_off = cur_off + sizeTemp;+ int endPos = _bufferPos + sizeTemp;+ _bufferPos = Filter.Filter(_buffer, endPos);+ if (_bufferPos == 0) {+ _bufferPos = endPos;+ break;+ }+ if (_bufferPos > endPos) {+ if (size != 0)+ throw new IOException("FilterCoder - write() : size <> 0"); // return HRESULT.E_FAIL;+ break;+ }++ WriteWithLimit(_outStream, _bufferPos);++ int i = 0;+ while(_bufferPos < endPos)+ _buffer[i++] = _buffer[_bufferPos++];+ _bufferPos = i;+ }++ // return HRESULT.S_OK;+ }++ void WriteWithLimit(java.io.OutputStream outStream, int size) throws IOException {+ if (_outSizeIsDefined) {+ long remSize = _outSize - _nowPos64;+ if (size > remSize)+ size = (int)remSize;+ }++ outStream.write(_buffer,0,size);++ _nowPos64 += size;+ }++ byte [] _buffer;++ static final int kBufferSize = 1 << 17;+ public FilterCoder() {+ _buffer = new byte[kBufferSize];+ }+++ // ICompressSetOutStream+ public int SetOutStream(java.io.OutputStream outStream) {+ _bufferPos = 0;+ _outStream = outStream;+ return Init();+ }++ public int ReleaseOutStream() throws IOException {+ if (_outStream != null) _outStream.close(); // Release()+ _outStream = null;+ return HRESULT.S_OK;+ }++ public void flush() throws IOException {+ if (_bufferPos != 0) {+ int endPos = Filter.Filter(_buffer, _bufferPos);+ if (endPos > _bufferPos) {+ for (; _bufferPos < endPos; _bufferPos++)+ _buffer[_bufferPos] = 0;+ if (Filter.Filter(_buffer, endPos) != endPos)+ throw new IOException("FilterCoder - flush() : E_FAIL"); // return HRESULT.E_FAIL;+ }+ _outStream.write(_buffer,0,_bufferPos);+ _bufferPos = 0;+ }+ _outStream.flush();+ }++ public void close() throws IOException {+ if (_outStream != null) _outStream.close(); // Release()+ _outStream = null;+ }++}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/OutStreamWithCRC.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/OutStreamWithCRC.javanew file mode 100644index 000000000..d42319bac--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/OutStreamWithCRC.java@@ -0,0 +1,55 @@+package SevenZip.Archive.Common;++import java.io.IOException;+import java.io.OutputStream;++import Common.CRC;++public class OutStreamWithCRC extends OutputStream {++ private OutputStream _stream;+ private long _size;+ private CRC _crc = new CRC();+ private boolean _calculateCrc;++ public void write(int b) throws IOException {+ throw new IOException("OutStreamWithCRC - write() not implemented");+ }++ public void write(byte [] data,int off, int size) throws IOException {+ if (_stream != null)+ _stream.write(data, off,size);+ if (_calculateCrc)+ _crc.Update(data, off, size);++ _size += size;+ }++ public void setStream(OutputStream stream) { _stream = stream; }++ public void reset() { reset(true); }++ public void reset(boolean calculateCrc) {+ _size = 0;+ _calculateCrc = calculateCrc;+ _crc.Init();+ }++ public void releaseStream() throws IOException {+ // _stream.Release();+ if (_stream != null) _stream.close();+ _stream = null;+ }++ public long getSize() {+ return _size;+ }++ public int getCRC() {+ return _crc.GetDigest();+ }++ public void resetCRC() {+ _crc.Init();+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/STCoderInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/STCoderInfo.javanew file mode 100644index 000000000..1d9ada425--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/Common/STCoderInfo.java@@ -0,0 +1,10 @@+package SevenZip.Archive.Common;++public class STCoderInfo extends CoderInfo {+ boolean IsMain;++ public STCoderInfo(int numInStreams, int numOutStreams, boolean isMain) {+ super(numInStreams, numOutStreams);+ this.IsMain = isMain;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/IArchiveExtractCallback.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/IArchiveExtractCallback.javanew file mode 100644index 000000000..43317602d--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/IArchiveExtractCallback.java@@ -0,0 +1,12 @@+package SevenZip.Archive;++import java.io.IOException;+import java.io.OutputStream;++public interface IArchiveExtractCallback extends SevenZip.IProgress {++ OutputStream GetStream(int index, int askExtractMode) throws IOException;++ void PrepareOperation(int askExtractMode);+ void SetOperationResult(int resultEOperationResult) throws IOException;+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/IInArchive.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/IInArchive.javanew file mode 100644index 000000000..e29cbad36--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/IInArchive.java@@ -0,0 +1,28 @@+package SevenZip.Archive;++import java.io.IOException;++public interface IInArchive {+ public final static int NExtract_NAskMode_kExtract = 0;+ public final static int NExtract_NAskMode_kTest = 1;+ public final static int NExtract_NAskMode_kSkip = 2;++ public final static int NExtract_NOperationResult_kOK = 0;+ public final static int NExtract_NOperationResult_kUnSupportedMethod = 1;+ public final static int NExtract_NOperationResult_kDataError = 2;+ public final static int NExtract_NOperationResult_kCRCError = 3;++ // Static-SFX (for Linux) can be big.+ public final long kMaxCheckStartPosition = 1 << 22;++ public SevenZipEntry getEntry(int index);++ public int size();++ public void close() throws IOException ;++ public void Extract(int [] indices, int numItems,+ int testModeSpec, IArchiveExtractCallback extractCallbackSpec) throws java.io.IOException;++}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/AltCoderInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/AltCoderInfo.javanew file mode 100644index 000000000..627232a07--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/AltCoderInfo.java@@ -0,0 +1,18 @@+package SevenZip.Archive.SevenZip;++import java.io.ByteArrayOutputStream;++public class AltCoderInfo {+ public MethodID MethodID;+ public ByteArrayOutputStream Properties;++ public AltCoderInfo(int size) {+ MethodID = new MethodID(null);+ Properties = new ByteArrayOutputStream(size);+ }++ public AltCoderInfo() {+ MethodID = new MethodID(null);+ Properties = new ByteArrayOutputStream();+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDB.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDB.javanew file mode 100644index 000000000..3987ddd96--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDB.java@@ -0,0 +1,725 @@+package SevenZip.Archive.SevenZip;++import java.io.ByteArrayOutputStream;+import java.io.IOException;+import java.util.ArrayList;+import java.util.Vector;++import Common.BoolVector;+import Common.CRC;+import Common.IntVector;+import Common.LongVector;++import SevenZip.IInStream;+import SevenZip.Archive.Common.BindPair;++public class ArchiveDB {++ public static final int kNumNoIndex = 0xFFFFFFFF;++ public final LongVector PackSizes = new LongVector();+ public final BoolVector PackCRCsDefined = new BoolVector();+ public final IntVector PackCRCs = new IntVector();+ public final IntVector NumUnPackStreamsVector = new IntVector();+ public final Vector Files = new Vector();+ public Vector Folders = new Vector();++ public final IntVector FolderStartPackStreamIndex = new IntVector();+ public final IntVector FolderStartFileIndex = new IntVector();+ public final IntVector FileIndexToFolderIndexMap = new IntVector();++ private final InStream inStream;+ private final InArchiveInfo ArchiveInfo = new InArchiveInfo();+ private final LongVector PackStreamStartPositions = new LongVector();++ public ArchiveDB(InStream inStream) throws IOException {+ this.inStream = inStream;+ this.ArchiveInfo.StartPosition = this.inStream.archiveBeginStreamPosition;++ byte [] btmp = new byte[2];+ int realProcessedSize = this.inStream.ReadDirect(btmp, 2);+ if (realProcessedSize != 2)+ throw new IOException("Unexpected End Of Archive"); // throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);++ this.ArchiveInfo.ArchiveVersion_Major = btmp[0];+ this.ArchiveInfo.ArchiveVersion_Minor = btmp[1];++ if (this.ArchiveInfo.ArchiveVersion_Major != Header.kMajorVersion)+ throw new IOException("Unsupported Version: " ++ this.ArchiveInfo.ArchiveVersion_Major + "." ++ this.ArchiveInfo.ArchiveVersion_Minor);++ int crcFromArchive = this.inStream.SafeReadDirectUInt32();+ long nextHeaderOffset = this.inStream.SafeReadDirectUInt64();+ long nextHeaderSize = this.inStream.SafeReadDirectUInt64();+ int nextHeaderCRC = this.inStream.SafeReadDirectUInt32();++ this.ArchiveInfo.StartPositionAfterHeader = this.inStream.position;++ CRC crc = new CRC();+ crc.UpdateUInt64(nextHeaderOffset);+ crc.UpdateUInt64(nextHeaderSize);+ crc.UpdateUInt32(nextHeaderCRC);++ if (crc.GetDigest() != crcFromArchive)+ throw new IOException("Incorrect Header, CRCs don't match: archive: " ++ Integer.toHexString(crcFromArchive) + ", calculated: " + crc); // CInArchiveException(CInArchiveException::kIncorrectHeader);++ if (nextHeaderSize == 0)+ return;++ if (nextHeaderSize >= 0xFFFFFFFFL)+ throw new IOException("second header too big: " + nextHeaderSize);++ this.inStream.position = this.inStream.stream.Seek(nextHeaderOffset,IInStream.STREAM_SEEK_CUR);++ this.readNextStreamHeaders((int)nextHeaderSize, nextHeaderCRC);+ this.readHeader();+ this.Fill();+ }++ private void readNextStreamHeaders(int nextHeaderSize, int nextHeaderCRC) throws IOException {+ byte[] buffer = new byte[nextHeaderSize];++ // SafeReadDirect(buffer2.data(), (int)nextHeaderSize);+ if (!this.inStream.SafeReadDirect(buffer, nextHeaderSize))+ throw new IOException("Unexpected End Of Archive"); // throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);++ if (!CRC.VerifyDigest(nextHeaderCRC, buffer, nextHeaderSize))+ throw new IOException("Incorrect Header, CRCs don't match"); // CInArchiveException(CInArchiveException::kIncorrectHeader);++ // TODO:+ StreamSwitch streamSwitch = new StreamSwitch();+ streamSwitch.Set(this.inStream, buffer);++ long type;+ while ((type = this.inStream.ReadID()) != Header.NID.kHeader) {+ if (type != Header.NID.kEncodedHeader)+ throw new IOException("Incorrect Header");++ Vector dataVector = this.ReadAndDecodePackedStreams(+ this.ArchiveInfo.StartPositionAfterHeader, 1);++ if (dataVector.size() == 0) {+ return;+ } else if (dataVector.size() > 1) {+ throw new IOException("Incorrect Header");+ }+ streamSwitch.Set(this.inStream, (byte[])dataVector.firstElement()); // dataVector.Front()+ }++ streamSwitch.close();+ }++ private void ReadArchiveProperties(InArchiveInfo archiveInfo) throws IOException {+ while (this.inStream.ReadID() != Header.NID.kEnd)+ this.inStream.SkeepData();+ }++ private void readHeader() throws IOException {+ long type = this.inStream.ReadID();++ if (type == Header.NID.kArchiveProperties) {+ this.ReadArchiveProperties(this.ArchiveInfo);+ type = this.inStream.ReadID();+ }++ Vector dataVector = new Vector();++ if (type == Header.NID.kAdditionalStreamsInfo) {+ dataVector.addAll(ReadAndDecodePackedStreams(+ this.ArchiveInfo.StartPositionAfterHeader, 1));+ this.ArchiveInfo.DataStartPosition2 += this.ArchiveInfo.StartPositionAfterHeader;+ type = this.inStream.ReadID();+ }++ LongVector unPackSizes = new LongVector();+ BoolVector digestsDefined = new BoolVector();+ IntVector digests = new IntVector();++ if (type == Header.NID.kMainStreamsInfo) {+ type = this.inStream.ReadID();+ assert (type == Header.NID.kPackInfo);+ this.ReadPackInfo(this.PackSizes, this.PackCRCsDefined, this.PackCRCs, 0);++ type = this.inStream.ReadID();+ assert (type == Header.NID.kUnPackInfo);+ this.Folders = ReadUnPackInfo(dataVector);++ type = this.inStream.ReadID();+ assert (type == Header.NID.kSubStreamsInfo);+ this.ReadSubStreamsInfo(this.Folders, this.NumUnPackStreamsVector, unPackSizes, digestsDefined, digests);++ type = this.inStream.ReadID();+ assert (type == Header.NID.kEnd);++ this.ArchiveInfo.DataStartPosition += this.ArchiveInfo.StartPositionAfterHeader;+ type = this.inStream.ReadID();+ } else {+ for(int i = 0; i < this.Folders.size(); i++) {+ this.NumUnPackStreamsVector.add(1);+ Folder folder = (Folder)this.Folders.get(i);+ unPackSizes.add(folder.GetUnPackSize());+ digestsDefined.add(folder.UnPackCRCDefined);+ digests.add(folder.UnPackCRC);+ }+ }++ if (type == Header.NID.kEnd)+ return;+ if (type != Header.NID.kFilesInfo)+ throw new IOException("Incorrect Header");++ this.readFileDescriptions(dataVector, unPackSizes, digests, digestsDefined);+ }++ private void readFileDescriptions(+ Vector dataVector,+ LongVector unPackSizes,+ IntVector digests,+ BoolVector digestsDefined) throws IOException {++ int numFiles = this.inStream.ReadNum();+ this.ArchiveInfo.FileInfoPopIDs.add(Header.NID.kSize);+ if (!this.PackSizes.isEmpty())+ this.ArchiveInfo.FileInfoPopIDs.add(Header.NID.kPackInfo);+ if (numFiles > 0 && !digests.isEmpty())+ this.ArchiveInfo.FileInfoPopIDs.add(Header.NID.kCRC);++ this.Files.clear();+ this.Files.ensureCapacity(numFiles);+ for (int i=0; i<numFiles; i++)+ this.Files.add(new FileItem());++ BoolVector emptyStreamVector = new BoolVector();+ emptyStreamVector.Reserve(numFiles);+ for(int i = 0; i < numFiles; i++)+ emptyStreamVector.add(false);+ BoolVector emptyFileVector = new BoolVector();+ BoolVector antiFileVector = new BoolVector();+ int numEmptyStreams = 0;++ long type;+ while ((type = this.inStream.ReadID()) != Header.NID.kEnd) {+ long size = this.inStream.ReadNumber();+ this.ArchiveInfo.FileInfoPopIDs.add(type);+ switch((int)type) {+ case Header.NID.kEmptyStream:+ emptyStreamVector.setBoolVector(this.inStream.ReadBoolVector(numFiles));+ for (int i=0; i<emptyStreamVector.size(); i++)+ if (emptyStreamVector.get(i))+ numEmptyStreams++;+ emptyFileVector.Reserve(numEmptyStreams);+ antiFileVector.Reserve(numEmptyStreams);+ for (int i = 0; i < numEmptyStreams; i++) {+ emptyFileVector.add(false);+ antiFileVector.add(false);+ }+ break;+ case Header.NID.kName: this.ReadFileNames(dataVector); break;+ case Header.NID.kWinAttributes: this.ReadFileAttributes(dataVector); break;+ case Header.NID.kStartPos: this.ReadFileStartPositions(dataVector); break;+ case Header.NID.kEmptyFile: emptyFileVector.setBoolVector(this.inStream.ReadBoolVector(numEmptyStreams)); break;+ case Header.NID.kAnti: antiFileVector.setBoolVector(this.inStream.ReadBoolVector(numEmptyStreams)); break;+ case Header.NID.kCreationTime:+ case Header.NID.kLastWriteTime:+ case Header.NID.kLastAccessTime: this.ReadTime(dataVector, type); break;+ default:+ this.ArchiveInfo.FileInfoPopIDs.DeleteBack();+ this.inStream.SkeepData(size);+ break;+ }+ }++ int emptyFileIndex = 0;+ int sizeIndex = 0;+ for(int i = 0; i < numFiles; i++) {+ FileItem file = (FileItem)this.Files.get(i);+ file.HasStream = !emptyStreamVector.get(i);+ if(file.HasStream) {+ file.IsDirectory = false;+ file.IsAnti = false;+ file.UnPackSize = unPackSizes.get(sizeIndex);+ file.FileCRC = digests.get(sizeIndex);+ file.IsFileCRCDefined = digestsDefined.get(sizeIndex);+ sizeIndex++;+ } else {+ file.IsDirectory = !emptyFileVector.get(emptyFileIndex);+ file.IsAnti = antiFileVector.get(emptyFileIndex);+ emptyFileIndex++;+ file.UnPackSize = 0;+ file.IsFileCRCDefined = false;+ }+ }+ }++ private void ReadSubStreamsInfo(+ Vector folders,+ IntVector numUnPackStreamsInFolders,+ LongVector unPackSizes,+ BoolVector digestsDefined,+ IntVector digests) throws IOException {+ numUnPackStreamsInFolders.clear();+ numUnPackStreamsInFolders.Reserve(folders.size());+ long type;++ while ((type = this.inStream.ReadID()) != Header.NID.kCRC &&+ type != Header.NID.kSize &&+ type != Header.NID.kEnd) {+ if (type == Header.NID.kNumUnPackStream) {+ for(int i = 0; i < folders.size(); i++) {+ int value = this.inStream.ReadNum();+ numUnPackStreamsInFolders.add(value);+ }+ continue;+ }+ this.inStream.SkeepData();+ }++ if (numUnPackStreamsInFolders.isEmpty())+ for (int i=0; i<folders.size(); i++)+ numUnPackStreamsInFolders.add(1);++ final ArrayList sizes = new ArrayList();+ int numSubstreams;+ long sum, size;+ for (int i=0; i<numUnPackStreamsInFolders.size(); i++) {+ numSubstreams = numUnPackStreamsInFolders.get(i);+ if (numSubstreams < 1) continue;+ sum = 0;+ if (type == Header.NID.kSize)+ for (int j=1; j<numSubstreams; j++) {+ sum += size = this.inStream.ReadNumber();+ sizes.add(new Long(size));+ }+ sizes.add(new Long((((Folder)folders.get(i)).GetUnPackSize() - sum)));+ }+ unPackSizes.addAll(sizes);+ sizes.clear();++ if (type == Header.NID.kSize)+ type = this.inStream.ReadID();++ int numDigests = 0;+ int numDigestsTotal = 0;+ for(int i = 0; i < folders.size(); i++) {+ numSubstreams = numUnPackStreamsInFolders.get(i);+ if (numSubstreams != 1 || !((Folder)folders.get(i)).UnPackCRCDefined)+ numDigests += numSubstreams;+ numDigestsTotal += numSubstreams;+ }++ final ArrayList bsizes = new ArrayList();+ do {+ if (type == Header.NID.kCRC) {+ BoolVector digestsDefined2 = new BoolVector();+ IntVector digests2 = new IntVector();+ digests2 = this.inStream.ReadHashDigests(numDigests, digestsDefined2);+ int digestIndex = 0;++ for (int i=0; i<folders.size(); i++) {+ numSubstreams = numUnPackStreamsInFolders.get(i);+ Folder folder = (Folder)folders.get(i);+ if (numSubstreams == 1 && folder.UnPackCRCDefined) {+ bsizes.add(Boolean.TRUE);+ sizes.add(new Integer(folder.UnPackCRC));+ } else {+ for (int j=0; j<numSubstreams; j++, digestIndex++) {+ bsizes.add(new Boolean(digestsDefined2.get(digestIndex)));+ sizes.add(new Integer(digests2.get(digestIndex)));+ }+ }+ }+ digestsDefined.addAll(bsizes);+ bsizes.clear();+ digests.addAll(sizes);+ sizes.clear();+ } else {+ this.inStream.SkeepData();+ }+ } while ((type = this.inStream.ReadID()) != Header.NID.kEnd);++ if (digestsDefined.isEmpty()) {+ digests.clear();+ for (int i=0; i<numDigestsTotal; i++) {+ digestsDefined.add(false);+ digests.add(0);+ }+ }+ }++ private Vector ReadAndDecodePackedStreams(long baseOffset, int dataStartPosIndex) throws IOException {+ LongVector packSizes = new LongVector();++ BoolVector packCRCsDefined = new BoolVector();+ IntVector packCRCs = new IntVector();++ long type = this.inStream.ReadID();+ assert (type == Header.NID.kPackInfo);+ this.ReadPackInfo(packSizes, packCRCsDefined, packCRCs, dataStartPosIndex);++ type = this.inStream.ReadID();+ assert (type == Header.NID.kUnPackInfo);+ Vector folders = ReadUnPackInfo(null);++ type = this.inStream.ReadID();+ assert (type == Header.NID.kEnd);++ int packIndex = 0;+ Decoder decoder = new Decoder(false); // _ST_MODE++ Vector dataVector = new Vector();+ long dataStartPos = baseOffset + ((dataStartPosIndex == 0) ?+ this.ArchiveInfo.DataStartPosition : this.ArchiveInfo.DataStartPosition2);+ for(int i=0; i<folders.size(); i++) {+ Folder folder = (Folder)folders.get(i);+ long unPackSize = folder.GetUnPackSize();+ if (unPackSize > InStream.kNumMax || unPackSize > 0xFFFFFFFFL)+ throw new IOException("unPackSize too great: " + unPackSize);++ ByteArrayOutputStream baos = new ByteArrayOutputStream((int)unPackSize);+ decoder.Decode(+ this.inStream.stream, dataStartPos,+ packSizes, packIndex,+ folder, baos, null);+ byte[] data; // TODO: stream belassen!+ dataVector.add(data = baos.toByteArray());++ if (folder.UnPackCRCDefined)+ if (!CRC.VerifyDigest(folder.UnPackCRC, data, (int)unPackSize))+ throw new IOException("Incorrect Header, CRCs of packed folder don't match: archive: " ++ Integer.toHexString(folder.UnPackCRC) + ", calculated: " ++ Integer.toHexString(CRC.CalculateDigest(data, (int)unPackSize)) ++ ". Either is the archive corrupted or an internal error occured");++ for (int j = 0; j < folder.PackStreams.size(); j++)+ dataStartPos += packSizes.get(packIndex++);+ }++ return dataVector;+ }++ private void ReadPackInfo(+ LongVector packSizes,+ BoolVector packCRCsDefined,+ IntVector packCRCs,+ int dataStartPosIndex)+ throws IOException {+ if (dataStartPosIndex == 0) {+ this.ArchiveInfo.DataStartPosition = this.inStream.ReadNumber();+ } else {+ this.ArchiveInfo.DataStartPosition2 = this.inStream.ReadNumber();+ }+ int numPackStreams = this.inStream.ReadNum();++ this.inStream.skipToAttribute(Header.NID.kSize);++ packSizes.clear();+ packSizes.Reserve(numPackStreams);+ for(int i = 0; i < numPackStreams; i++) {+ long size = this.inStream.ReadNumber();+ packSizes.add(size);+ }++ long type;+ while ((type = this.inStream.ReadID()) != Header.NID.kEnd) {+ if (type == Header.NID.kCRC) {+ packCRCs = this.inStream.ReadHashDigests(numPackStreams, packCRCsDefined);+ continue;+ }+ this.inStream.SkeepData();+ }+ if (packCRCsDefined.isEmpty()) {+ packCRCsDefined.Reserve(numPackStreams);+ packCRCsDefined.clear();+ packCRCs.Reserve(numPackStreams);+ packCRCs.clear();+ for(int i = 0; i < numPackStreams; i++) {+ packCRCsDefined.add(false);+ packCRCs.add(0);+ }+ }+ }++ private void ReadFileNames(Vector from) throws IOException {+ StreamSwitch streamSwitch = new StreamSwitch();+ streamSwitch.Set(this.inStream, from);+ StringBuffer name = new StringBuffer(30);+ char c;+ for (int i=0; i<this.Files.size(); i++) {+ while ((c = this.inStream.ReadWideCharLE()) != '\0')+ name.append(c);+ ((FileItem)this.Files.get(i)).name = new String(name);+ name.delete(0, name.length());+ }+ streamSwitch.close();+ }++ private void ReadFileAttributes(Vector from) throws IOException {+ BoolVector boolVector = this.inStream.ReadBoolVector2(this.Files.size());+ StreamSwitch streamSwitch = new StreamSwitch();+ streamSwitch.Set(this.inStream, from);+ for (int i=0; i<this.Files.size(); i++) {+ FileItem file = (FileItem)this.Files.get(i);+ file.AreAttributesDefined = boolVector.get(i);+ if (file.AreAttributesDefined)+ file.Attributes = this.inStream.ReadUInt32();+ }+ streamSwitch.close();+ }++ private void ReadFileStartPositions(Vector from) throws IOException {+ BoolVector boolVector = this.inStream.ReadBoolVector2(this.Files.size());+ StreamSwitch streamSwitch = new StreamSwitch();+ streamSwitch.Set(this.inStream, from);+ for(int i=0; i<this.Files.size(); i++) {+ FileItem file = (FileItem)this.Files.get(i);+ file.IsStartPosDefined = boolVector.get(i);+ if (file.IsStartPosDefined)+ file.StartPos = this.inStream.ReadUInt64();+ }+ streamSwitch.close();+ }++ private void ReadTime(Vector dataVector, long type) throws IOException {+ BoolVector boolVector = this.inStream.ReadBoolVector2(this.Files.size());++ StreamSwitch streamSwitch = new StreamSwitch();+ streamSwitch.Set(this.inStream, dataVector);++ for (int i=0; i<this.Files.size(); i++) {+ FileItem file = (FileItem)this.Files.get(i);+ int low = 0;+ int high = 0;+ boolean defined = boolVector.get(i);+ if (defined) {+ low = this.inStream.ReadUInt32();+ high = this.inStream.ReadUInt32();+ }+ switch((int)type) {+ case Header.NID.kCreationTime:+ // file.IsCreationTimeDefined = defined;+ if (defined)+ file.CreationTime = InStream.FileTimeToLong(high,low);+ break;+ case Header.NID.kLastWriteTime:+ // file.IsLastWriteTimeDefined = defined;+ if (defined)+ file.LastWriteTime = InStream.FileTimeToLong(high,low);+ break;+ case Header.NID.kLastAccessTime:+ // file.IsLastAccessTimeDefined = defined;+ if (defined)+ file.LastAccessTime = InStream.FileTimeToLong(high,low);+ break;+ }+ }+ streamSwitch.close();+ }++ private Vector ReadUnPackInfo(Vector dataVector) throws IOException {+ this.inStream.skipToAttribute(Header.NID.kFolder);++ int numFolders = this.inStream.ReadNum();++ StreamSwitch streamSwitch = new StreamSwitch();+ streamSwitch.Set(this.inStream, dataVector);+ Vector folders = new Vector(numFolders);+ for (int i=0; i<numFolders; i++)+ folders.add(GetNextFolderItem());+ streamSwitch.close();++ this.inStream.skipToAttribute(Header.NID.kCodersUnPackSize);++ for (int i=0; i<numFolders; i++) {+ Folder folder = (Folder)folders.get(i);+ int numOutStreams = folder.GetNumOutStreams();+ folder.UnPackSizes.Reserve(numOutStreams);+ for (int j=0; j<numOutStreams; j++) {+ long unPackSize = this.inStream.ReadNumber();+ folder.UnPackSizes.add(unPackSize);+ }+ }++ long type;+ while ((type = this.inStream.ReadID()) != Header.NID.kEnd) {+ if (type == Header.NID.kCRC) {+ BoolVector crcsDefined = new BoolVector();+ IntVector crcs = new IntVector();+ crcs = this.inStream.ReadHashDigests(numFolders, crcsDefined);+ for (int i=0; i<numFolders; i++) {+ Folder folder = (Folder)folders.get(i);+ folder.UnPackCRCDefined = crcsDefined.get(i);+ folder.UnPackCRC = crcs.get(i);+ }+ continue;+ }+ this.inStream.SkeepData();+ }+ return folders;+ }++ private Folder GetNextFolderItem() throws IOException {+ int numCoders = this.inStream.ReadNum();++ Folder folder = new Folder();+ folder.Coders.clear();+ folder.Coders.ensureCapacity(numCoders);+ int numInStreams = 0;+ int numOutStreams = 0;+ for (int i=0; i<numCoders; i++) {+ folder.Coders.add(new CoderInfo());+ CoderInfo coder = (CoderInfo)folder.Coders.lastElement();+ int mainByte;+ do {+ AltCoderInfo altCoder = new AltCoderInfo();+ coder.AltCoders.add(altCoder);+ mainByte = this.inStream.ReadByte();+ altCoder.MethodID.IDSize = (byte)(mainByte & 0xF);+ if (!this.inStream.ReadBytes(altCoder.MethodID.ID, altCoder.MethodID.IDSize))+ throw new IOException("error reading properties for alternative decoder");++ if ((mainByte & 0x10) != 0) {+ coder.NumInStreams = this.inStream.ReadNum();+ coder.NumOutStreams = this.inStream.ReadNum();+ } else {+ coder.NumInStreams = 1;+ coder.NumOutStreams = 1;+ }+ if ((mainByte & 0x20) != 0) {+ int propertiesSize = this.inStream.ReadNum();+ if (!this.inStream.ReadBytes(altCoder.Properties, propertiesSize))+ throw new IOException("error reading properties for alternative decoder");+ }+ } while ((mainByte & 0x80) != 0);+ numInStreams += coder.NumInStreams;+ numOutStreams += coder.NumOutStreams;+ }++ // RINOK(ReadNumber(numBindPairs));+ int numBindPairs = numOutStreams - 1;+ folder.BindPairs.clear();+ folder.BindPairs.ensureCapacity(numBindPairs);+ for (int i=0; i<numBindPairs; i++) {+ BindPair bindPair = new BindPair();+ bindPair.InIndex = this.inStream.ReadNum();+ bindPair.OutIndex = this.inStream.ReadNum();+ folder.BindPairs.add(bindPair);+ }++ int numPackedStreams = numInStreams - numBindPairs;+ folder.PackStreams.Reserve(numPackedStreams);+ if (numPackedStreams == 1) {+ for (int j=0; j<numInStreams; j++)+ if (folder.FindBindPairForInStream(j) < 0) {+ folder.PackStreams.add(j);+ break;+ }+ } else {+ for (int i=0; i<numPackedStreams; i++) {+ int packStreamInfo = this.inStream.ReadNum();+ folder.PackStreams.add(packStreamInfo);+ }+ }++ return folder;+ }++ private void Fill() throws IOException {+ FillFolderStartPackStream();+ FillStartPos();+ FillFolderStartFileIndex();+ }++ private void FillFolderStartPackStream() {+ this.FolderStartPackStreamIndex.clear();+ this.FolderStartPackStreamIndex.Reserve(this.Folders.size());+ int startPos = 0;+ for(int i = 0; i < this.Folders.size(); i++) {+ this.FolderStartPackStreamIndex.add(startPos);+ startPos += ((Folder)this.Folders.get(i)).PackStreams.size();+ }+ }++ private void FillStartPos() {+ this.PackStreamStartPositions.clear();+ this.PackStreamStartPositions.Reserve(this.PackSizes.size());+ long startPos = 0;+ for(int i = 0; i < this.PackSizes.size(); i++) {+ this.PackStreamStartPositions.add(startPos);+ startPos += this.PackSizes.get(i);+ }+ }++ private void FillFolderStartFileIndex() throws IOException {+ this.FolderStartFileIndex.clear();+ this.FolderStartFileIndex.Reserve(this.Folders.size());+ this.FileIndexToFolderIndexMap.clear();+ this.FileIndexToFolderIndexMap.Reserve(this.Files.size());++ int folderIndex = 0;+ int indexInFolder = 0;+ for (int i = 0; i < this.Files.size(); i++) {+ FileItem file = (FileItem)this.Files.get(i);+ boolean emptyStream = !file.HasStream;+ if (emptyStream && indexInFolder == 0) {+ this.FileIndexToFolderIndexMap.add(kNumNoIndex);+ continue;+ }+ if (indexInFolder == 0) {+ // v3.13 incorrectly worked with empty folders+ // v4.07: Loop for skipping empty folders+ for (;;) {+ if (folderIndex >= this.Folders.size())+ throw new IOException("Incorrect Header");+ this.FolderStartFileIndex.add(i); // check it+ if (this.NumUnPackStreamsVector.get(folderIndex) != 0)+ break;+ folderIndex++;+ }+ }+ this.FileIndexToFolderIndexMap.add(folderIndex);+ if (emptyStream)+ continue;+ indexInFolder++;+ if (indexInFolder >= this.NumUnPackStreamsVector.get(folderIndex)) {+ folderIndex++;+ indexInFolder = 0;+ }+ }+ }++ /* ---------------------------------------------------------------------------------------------------+ * public methods+ * --------------------------------------------------------------------------------------------------- */++ public void clear() {+ this.ArchiveInfo.FileInfoPopIDs.clear();+ this.PackStreamStartPositions.clear();+ this.FolderStartPackStreamIndex.clear();+ this.FolderStartFileIndex.clear();+ this.FileIndexToFolderIndexMap.clear();++ this.PackSizes.clear();+ this.PackCRCsDefined.clear();+ this.PackCRCs.clear();+ this.Folders.clear();+ this.NumUnPackStreamsVector.clear();+ this.Files.clear();+ }++ public long GetFolderFullPackSize(int folderIndex) {+ int packStreamIndex = this.FolderStartPackStreamIndex.get(folderIndex);+ Folder folder = (Folder)this.Folders.get(folderIndex);+ long size = 0;+ for (int i = 0; i < folder.PackStreams.size(); i++)+ size += this.PackSizes.get(packStreamIndex + i);+ return size;+ }++ public long GetFolderStreamPos(int folderIndex, int indexInFolder) {+ return this.ArchiveInfo.DataStartPosition ++ this.PackStreamStartPositions.get(this.FolderStartPackStreamIndex.get(folderIndex) ++ indexInFolder);+ }+}\ No newline at end of filediff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDatabase.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDatabase.javanew file mode 100644index 000000000..5d8f59989--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDatabase.java@@ -0,0 +1,26 @@+package SevenZip.Archive.SevenZip;++import java.util.Vector;++import Common.BoolVector;+import Common.IntVector;+import Common.LongVector;++class ArchiveDatabase {++ public LongVector PackSizes = new LongVector();+ public BoolVector PackCRCsDefined = new BoolVector();+ public IntVector PackCRCs = new IntVector();+ public Vector Folders = new Vector();+ public IntVector NumUnPackStreamsVector = new IntVector();+ public Vector Files = new Vector();++ void Clear() {+ PackSizes.clear();+ PackCRCsDefined.clear();+ PackCRCs.clear();+ Folders.clear();+ NumUnPackStreamsVector.clear();+ Files.clear();+ }+}\ No newline at end of filediff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDatabaseEx.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDatabaseEx.javanew file mode 100644index 000000000..c2d16b3a1--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDatabaseEx.java@@ -0,0 +1,107 @@+package SevenZip.Archive.SevenZip;++import Common.IntVector;+import Common.LongVector;++public class ArchiveDatabaseEx extends ArchiveDatabase {+ public IntVector FolderStartPackStreamIndex = new IntVector();+ public IntVector FolderStartFileIndex = new IntVector();+ public IntVector FileIndexToFolderIndexMap = new IntVector();++ InArchiveInfo ArchiveInfo = new InArchiveInfo();+ LongVector PackStreamStartPositions = new LongVector();++ public ArchiveDatabaseEx() {+ super();++ }++ void Clear() {+ ArchiveInfo.Clear();+ PackStreamStartPositions.clear();+ FolderStartPackStreamIndex.clear();+ FolderStartFileIndex.clear();+ FileIndexToFolderIndexMap.clear();+ super.Clear();+ }++ void FillFolderStartPackStream() {+ FolderStartPackStreamIndex.clear();+ FolderStartPackStreamIndex.Reserve(Folders.size());+ int startPos = 0;+ for(int i = 0; i < Folders.size(); i++) {+ FolderStartPackStreamIndex.add(startPos);+ startPos += ((Folder)Folders.get(i)).PackStreams.size();+ }+ }++ void FillStartPos() {+ PackStreamStartPositions.clear();+ PackStreamStartPositions.Reserve(PackSizes.size());+ long startPos = 0;+ for(int i = 0; i < PackSizes.size(); i++) {+ PackStreamStartPositions.add(startPos);+ startPos += PackSizes.get(i);+ }+ }++ public void Fill() throws java.io.IOException {+ FillFolderStartPackStream();+ FillStartPos();+ FillFolderStartFileIndex();+ }++ public long GetFolderFullPackSize(int folderIndex) {+ int packStreamIndex = FolderStartPackStreamIndex.get(folderIndex);+ Folder folder = (Folder)Folders.get(folderIndex);+ long size = 0;+ for (int i = 0; i < folder.PackStreams.size(); i++)+ size += PackSizes.get(packStreamIndex + i);+ return size;+ }+++ void FillFolderStartFileIndex() throws java.io.IOException {+ FolderStartFileIndex.clear();+ FolderStartFileIndex.Reserve(Folders.size());+ FileIndexToFolderIndexMap.clear();+ FileIndexToFolderIndexMap.Reserve(Files.size());++ int folderIndex = 0;+ int indexInFolder = 0;+ for (int i = 0; i < Files.size(); i++) {+ FileItem file = (FileItem)Files.get(i);+ boolean emptyStream = !file.HasStream;+ if (emptyStream && indexInFolder == 0) {+ FileIndexToFolderIndexMap.add(ArchiveDB.kNumNoIndex);+ continue;+ }+ if (indexInFolder == 0) {+ // v3.13 incorrectly worked with empty folders+ // v4.07: Loop for skipping empty folders+ for (;;) {+ if (folderIndex >= Folders.size())+ throw new java.io.IOException("Incorrect Header"); // CInArchiveException(CInArchiveException::kIncorrectHeader);+ FolderStartFileIndex.add(i); // check it+ if (NumUnPackStreamsVector.get(folderIndex) != 0)+ break;+ folderIndex++;+ }+ }+ FileIndexToFolderIndexMap.add(folderIndex);+ if (emptyStream)+ continue;+ indexInFolder++;+ if (indexInFolder >= NumUnPackStreamsVector.get(folderIndex)) {+ folderIndex++;+ indexInFolder = 0;+ }+ }+ }++ public long GetFolderStreamPos(int folderIndex, int indexInFolder) {+ return ArchiveInfo.DataStartPosition ++ PackStreamStartPositions.get(FolderStartPackStreamIndex.get(folderIndex) ++ indexInFolder);+ }+}\ No newline at end of filediff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/BindInfoEx.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/BindInfoEx.javanew file mode 100644index 000000000..3618dbb49--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/BindInfoEx.java@@ -0,0 +1,25 @@+package SevenZip.Archive.SevenZip;++import java.util.Vector;++import SevenZip.Archive.Common.BindInfo;++class BindInfoEx extends BindInfo {++ Vector CoderMethodIDs = new Vector();++ public void Clear() {+ super.Clear(); // CBindInfo::Clear();+ CoderMethodIDs.clear();+ }++ public boolean equals(Object obj) {+ if (obj instanceof BindInfoEx) {+ BindInfoEx arg = (BindInfoEx)obj;+ for (int i = 0; i < this.CoderMethodIDs.size(); i++)+ if (this.CoderMethodIDs.get(i) != arg.CoderMethodIDs.get(i))+ return false;+ }+ return super.equals(obj);+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/CoderInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/CoderInfo.javanew file mode 100644index 000000000..58d3dc0dd--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/CoderInfo.java@@ -0,0 +1,17 @@+package SevenZip.Archive.SevenZip;++import java.util.Vector;++public class CoderInfo {++ public int NumInStreams;+ public int NumOutStreams;+ public Vector AltCoders = new Vector();++ boolean IsSimpleCoder() { return (NumInStreams == 1) && (NumOutStreams == 1); }++ public CoderInfo() {+ NumInStreams = 0;+ NumOutStreams = 0;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Decoder.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Decoder.javanew file mode 100644index 000000000..69f8d435a--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Decoder.java@@ -0,0 +1,213 @@+package SevenZip.Archive.SevenZip;++import java.io.IOException;+import java.io.OutputStream;+import java.util.Vector;++import SevenZip.ICompressCoder2;+import SevenZip.ICompressCoder;+import SevenZip.ICompressFilter;+import SevenZip.ICompressProgressInfo;+import SevenZip.IInStream;++import SevenZip.Archive.Common.BindPair;+import SevenZip.Archive.Common.CoderMixer2ST;+import SevenZip.Archive.Common.FilterCoder;++import Common.LongVector;++public class Decoder {++ private boolean _bindInfoExPrevIsDefined;+ private BindInfoEx _bindInfoExPrev;++ private boolean _multiThread;++ // CoderMixer2MT _mixerCoderMTSpec;+ private CoderMixer2ST _mixerCoderSTSpec;+ private final Vector _decoders;++ public Decoder(boolean multiThread) {+ this._multiThread = multiThread;+ this._bindInfoExPrevIsDefined = false;+ this._bindInfoExPrev = new BindInfoEx();+ this._decoders = new Vector();+ }++ private static ICompressCoder getSimpleCoder(AltCoderInfo altCoderInfo) throws IOException {+ ICompressCoder decoder = null;+ ICompressFilter filter = null;++ // #ifdef COMPRESS_LZMA+ if (altCoderInfo.MethodID.equals(MethodID.k_LZMA))+ decoder = new SevenZip.Compression.LZMA.Decoder(altCoderInfo.Properties.toByteArray()); // NCompress::NLZMA::CDecoder;+ if (altCoderInfo.MethodID.equals(MethodID.k_PPMD))+ throw new IOException("PPMD not implemented"); // decoder = new NCompress::NPPMD::CDecoder;+ if (altCoderInfo.MethodID.equals(MethodID.k_BCJ_X86))+ filter = new SevenZip.Compression.Branch.BCJ_x86_Decoder();+ if (altCoderInfo.MethodID.equals(MethodID.k_Deflate))+ throw new IOException("DEFLATE not implemented"); // decoder = new NCompress::NDeflate::NDecoder::CCOMCoder;+ if (altCoderInfo.MethodID.equals(MethodID.k_BZip2))+ throw new IOException("BZIP2 not implemented"); // decoder = new NCompress::NBZip2::CDecoder;+ if (altCoderInfo.MethodID.equals(MethodID.k_Copy))+ decoder = new SevenZip.Compression.Copy.Decoder(); // decoder = new NCompress::CCopyCoder;+ if (altCoderInfo.MethodID.equals(MethodID.k_7zAES))+ throw new IOException("k_7zAES not implemented"); // filter = new NCrypto::NSevenZ::CDecoder;++ if (filter != null) {+ FilterCoder coderSpec = new FilterCoder();+ coderSpec.Filter = filter;+ decoder = coderSpec;+ }++ if (decoder == null)+ throw new IOException("decoder " + altCoderInfo.MethodID + " not implemented");+ return decoder;+ }++ private static ICompressCoder2 getComplexCoder(AltCoderInfo altCoderInfo) throws IOException {+ ICompressCoder2 decoder = null;++ if (altCoderInfo.MethodID.equals(MethodID.k_BCJ2))+ decoder = new SevenZip.Compression.Branch.BCJ2_x86_Decoder();++ if (decoder == null)+ throw new IOException("decoder " + altCoderInfo.MethodID + " not implemented");+ return decoder;+ }++ private void createNewCoders(+ BindInfoEx bindInfo,+ Folder folderInfo) throws IOException {+ int i;+ this._decoders.clear();+ if (this._mixerCoderSTSpec != null) this._mixerCoderSTSpec.close(); // _mixerCoder.Release();+ if (this._multiThread) {+ /*+ _mixerCoderMTSpec = new CoderMixer2MT();+ _mixerCoder = _mixerCoderMTSpec;+ _mixerCoderCommon = _mixerCoderMTSpec;+ */+ throw new IOException("multithreaded decoder not implemented");+ } else {+ this._mixerCoderSTSpec = new CoderMixer2ST(bindInfo);+ }++ for (i=0; i<folderInfo.Coders.size(); i++) {+ CoderInfo coderInfo = (CoderInfo)folderInfo.Coders.get(i);+ AltCoderInfo altCoderInfo = (AltCoderInfo)coderInfo.AltCoders.firstElement();++ if (coderInfo.IsSimpleCoder()) {+ ICompressCoder decoder = getSimpleCoder(altCoderInfo);+ this._decoders.add(decoder);++ if (this._multiThread) {+ // _mixerCoderMTSpec.AddCoder(decoder);+ // has already ben checked above+ // throw new IOException("Multithreaded decoder is not implemented");+ } else {+ this._mixerCoderSTSpec.AddCoder(decoder, false);+ }+ } else {+ ICompressCoder2 decoder = getComplexCoder(altCoderInfo);+ this._decoders.add(decoder);++ if (this._multiThread) {+ // _mixerCoderMTSpec.AddCoder2(decoder);+ // has already ben checked above+ // throw new IOException("Multithreaded decoder is not implemented");+ } else {+ this._mixerCoderSTSpec.AddCoder2(decoder, false);+ }+ }+ }+ this._bindInfoExPrev = bindInfo;+ this._bindInfoExPrevIsDefined = true;+ }++ private void setCoderMixerCommonInfos(Folder folderInfo, LongVector packSizes) {+ int packStreamIndex = 0, unPackStreamIndex = 0;+ for (int i=0; i<folderInfo.Coders.size(); i++) {+ CoderInfo coderInfo = (CoderInfo)folderInfo.Coders.get(i);+ int numInStreams = coderInfo.NumInStreams;+ int numOutStreams = coderInfo.NumOutStreams;+ LongVector packSizesPointers = new LongVector(); // CRecordVector<const UInt64 *>+ LongVector unPackSizesPointers = new LongVector(); // CRecordVector<const UInt64 *>+ packSizesPointers.Reserve(numInStreams);+ unPackSizesPointers.Reserve(numOutStreams);+ int j;++ for (j=0; j<numOutStreams; j++, unPackStreamIndex++)+ unPackSizesPointers.add(folderInfo.UnPackSizes.get(unPackStreamIndex));++ for (j=0; j<numInStreams; j++, packStreamIndex++) {+ final long packSizesPointer;+ final int bindPairIndex = folderInfo.FindBindPairForInStream(packStreamIndex);+ final int index;+ if (bindPairIndex >= 0) {+ index = ((BindPair)folderInfo.BindPairs.get(bindPairIndex)).OutIndex;+ packSizesPointer = folderInfo.UnPackSizes.get(index);+ } else {+ index = folderInfo.FindPackStreamArrayIndex(packStreamIndex);+ if (index < 0)+ throw new IndexOutOfBoundsException("PackStreamArrayIndex: " + index);+ packSizesPointer = packSizes.get(index);+ }+ packSizesPointers.add(packSizesPointer);+ }++ this._mixerCoderSTSpec.SetCoderInfo(+ i,+ packSizesPointers, // &packSizesPointers.Front(),+ unPackSizesPointers // &unPackSizesPointers.Front()+ );+ }+ }++ public void Decode(+ IInStream inStream, long startPos,+ LongVector packSizes, int packSizesOffset,+ Folder folderInfo,+ OutputStream outStream,+ ICompressProgressInfo compressProgress+ ) throws IOException {++ final Vector inStreams = folderInfo.getInStreams(+ inStream,+ startPos,+ packSizes,+ packSizesOffset);++ final BindInfoEx bindInfo = folderInfo.toBindInfoEx();++ if (!(this._bindInfoExPrevIsDefined && bindInfo.equals(this._bindInfoExPrev))) {+ createNewCoders(bindInfo, folderInfo);+ } else { /* should not happen, as far as I understood... */ }++ this._mixerCoderSTSpec.ReInit();+ // this._mixerCoderCommon.setCoderInfos(this._decoders, folderInfo, packSizes);+ setCoderMixerCommonInfos(folderInfo, packSizes);++ // int mainCoder = bindInfo.FindOutStream(bindInfo.OutStreams.get(0))[0];++ if (this._multiThread) {+ // _mixerCoderMTSpec.SetProgressCoderIndex(mainCoder);+ throw new IOException("Multithreaded decoder is not implemented");+ }++ if (folderInfo.Coders.size() == 0)+ throw new IOException("no decoders available");++ final Vector outStreams = new Vector(1);+ outStreams.add(outStream);++ this._mixerCoderSTSpec.Code(+ inStreams,+ null,+ inStreams.size(),+ outStreams,+ null,+ 1,+ compressProgress);+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ExtractFolderInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ExtractFolderInfo.javanew file mode 100644index 000000000..882a88ef8--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ExtractFolderInfo.java@@ -0,0 +1,33 @@+package SevenZip.Archive.SevenZip;++import Common.BoolVector;++public class ExtractFolderInfo {+ /* #ifdef _7Z_VOL+ int VolumeIndex;+ #endif */+ public int FileIndex;+ public int FolderIndex;+ public BoolVector ExtractStatuses = new BoolVector();+ public long UnPackSize;+ public ExtractFolderInfo(+ /* #ifdef _7Z_VOL+ int volumeIndex,+ #endif */+ int fileIndex, int folderIndex) // CNum fileIndex, CNum folderIndex+ {+ /* #ifdef _7Z_VOL+ VolumeIndex(volumeIndex),+ #endif */+ FileIndex = fileIndex;+ FolderIndex = folderIndex;+ UnPackSize = 0;++ if (fileIndex != ArchiveDB.kNumNoIndex)+ {+ ExtractStatuses.Reserve(1);+ ExtractStatuses.add(true);+ }+ }+}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/FileItem.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/FileItem.javanew file mode 100644index 000000000..aa80ac3c7--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/FileItem.java@@ -0,0 +1,36 @@+package SevenZip.Archive.SevenZip;++public class FileItem {++ public long CreationTime;+ public long LastWriteTime;+ public long LastAccessTime;++ public long UnPackSize;+ public long StartPos;+ public int Attributes;+ public int FileCRC;++ public boolean IsDirectory;+ public boolean IsAnti;+ public boolean IsFileCRCDefined;+ public boolean AreAttributesDefined;+ public boolean HasStream;+ // public boolean IsCreationTimeDefined; replace by (CreationTime != 0)+ // public boolean IsLastWriteTimeDefined; replace by (LastWriteTime != 0)+ // public boolean IsLastAccessTimeDefined; replace by (LastAccessTime != 0)+ public boolean IsStartPosDefined;+ public String name;++ public FileItem() {+ HasStream = true;+ IsDirectory = false;+ IsAnti = false;+ IsFileCRCDefined = false;+ AreAttributesDefined = false;+ CreationTime = 0; // IsCreationTimeDefined = false;+ LastWriteTime = 0; // IsLastWriteTimeDefined = false;+ LastAccessTime = 0; // IsLastAccessTimeDefined = false;+ IsStartPosDefined = false;+ }+}\ No newline at end of filediff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Folder.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Folder.javanew file mode 100644index 000000000..71ee151e1--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Folder.java@@ -0,0 +1,106 @@+package SevenZip.Archive.SevenZip;++import java.io.IOException;+import java.util.Vector;++import Common.IntVector;+import Common.LimitedSequentialInStream;+import Common.LockedInStream;+import Common.LockedSequentialInStreamImp;+import Common.LongVector;++import SevenZip.IInStream;+import SevenZip.Archive.Common.BindPair;+import SevenZip.Archive.Common.CoderStreamsInfo;++public class Folder {++ public Vector Coders = new Vector();+ public Vector BindPairs = new Vector();+ public IntVector PackStreams = new IntVector();+ public LongVector UnPackSizes = new LongVector();+ int UnPackCRC;+ boolean UnPackCRCDefined;++ Folder() {+ UnPackCRCDefined = false;+ }++ public long GetUnPackSize() throws IOException {+ if (UnPackSizes.isEmpty())+ return 0;+ for (int i = UnPackSizes.size() - 1; i >= 0; i--)+ if (FindBindPairForOutStream(i) < 0)+ return UnPackSizes.get(i);+ throw new IOException("1"); // throw 1 // TBD+ }++ public int FindBindPairForInStream(int inStreamIndex) {+ for(int i = 0; i < BindPairs.size(); i++)+ if (((BindPair)BindPairs.get(i)).InIndex == inStreamIndex)+ return i;+ return -1;+ }++ public int FindBindPairForOutStream(int outStreamIndex) {+ for(int i = 0; i < BindPairs.size(); i++)+ if (((BindPair)BindPairs.get(i)).OutIndex == outStreamIndex)+ return i;+ return -1;+ }++ public int FindPackStreamArrayIndex(int inStreamIndex) {+ for(int i = 0; i < PackStreams.size(); i++)+ if (PackStreams.get(i) == inStreamIndex)+ return i;+ return -1;+ }++ public int GetNumOutStreams() {+ int result = 0;+ for (int i = 0; i < Coders.size(); i++)+ result += ((CoderInfo)Coders.get(i)).NumOutStreams;+ return result;+ }++ public Vector getInStreams(+ IInStream inStream, long startPos,+ LongVector packSizes, int packSizesOffset) {+ final Vector inStreams = new Vector(this.PackStreams.size());+ final LockedInStream lockedInStream = new LockedInStream(inStream);+ for (int j = 0; j < this.PackStreams.size(); j++) {+ inStreams.add(new LimitedSequentialInStream(+ new LockedSequentialInStreamImp(lockedInStream, startPos),+ packSizes.get(j + packSizesOffset)));+ startPos += packSizes.get(j + packSizesOffset);+ }+ return inStreams;+ }++ public BindInfoEx toBindInfoEx() {+ BindInfoEx bindInfo = new BindInfoEx();++ for (int i = 0; i < this.BindPairs.size(); i++) {+ BindPair bindPair = new BindPair();+ bindPair.InIndex = ((BindPair)this.BindPairs.get(i)).InIndex;+ bindPair.OutIndex = ((BindPair)this.BindPairs.get(i)).OutIndex;+ bindInfo.BindPairs.add(bindPair);+ }+ int outStreamIndex = 0;+ for (int i = 0; i < this.Coders.size(); i++) {+ CoderStreamsInfo coderStreamsInfo = new CoderStreamsInfo();+ CoderInfo coderInfo = (CoderInfo)this.Coders.get(i);+ coderStreamsInfo.NumInStreams = coderInfo.NumInStreams;+ coderStreamsInfo.NumOutStreams = coderInfo.NumOutStreams;+ bindInfo.Coders.add(coderStreamsInfo);+ AltCoderInfo altCoderInfo = (AltCoderInfo)coderInfo.AltCoders.firstElement();+ bindInfo.CoderMethodIDs.add(altCoderInfo.MethodID);+ for (int j = 0; j < coderStreamsInfo.NumOutStreams; j++, outStreamIndex++)+ if (this.FindBindPairForOutStream(outStreamIndex) < 0)+ bindInfo.OutStreams.add(outStreamIndex);+ }+ for (int i = 0; i < this.PackStreams.size(); i++)+ bindInfo.InStreams.add(this.PackStreams.get(i));+ return bindInfo;+ }+}\ No newline at end of filediff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/FolderOutStream.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/FolderOutStream.javanew file mode 100644index 000000000..1e7a4697d--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/FolderOutStream.java@@ -0,0 +1,161 @@+package SevenZip.Archive.SevenZip;++import java.io.IOException;+import java.io.OutputStream;++import SevenZip.Archive.Common.OutStreamWithCRC;+import SevenZip.Archive.IArchiveExtractCallback;+import SevenZip.Archive.IInArchive;++import Common.BoolVector;++public class FolderOutStream extends OutputStream {++ private OutStreamWithCRC outStreamWithHashSpec;+ private ArchiveDB archiveDatabase;+ private BoolVector extractStatuses;+ private int startIndex;+ private int ref2Offset;+ private IArchiveExtractCallback extractCallback;+ private boolean testMode;+ private int currentIndex;+ private boolean fileIsOpen;+ private long filePos;++ public FolderOutStream(+ ArchiveDB archiveDatabase,+ int ref2Offset,+ int startIndex,+ BoolVector extractStatuses,+ IArchiveExtractCallback extractCallback,+ boolean testMode) throws IOException {+ this(new OutStreamWithCRC(), archiveDatabase, ref2Offset, startIndex, extractStatuses, extractCallback, testMode);+ }++ public FolderOutStream(OutStreamWithCRC os,+ ArchiveDB archiveDatabase,+ int ref2Offset,+ int startIndex,+ BoolVector extractStatuses,+ IArchiveExtractCallback extractCallback,+ boolean testMode) throws IOException {+ if (os == null) throw new NullPointerException();+ this.outStreamWithHashSpec = os;+ this.archiveDatabase = archiveDatabase;+ this.ref2Offset = ref2Offset;+ this.startIndex = startIndex;++ this.extractStatuses = extractStatuses;+ this.extractCallback = extractCallback;+ this.testMode = testMode;++ this.currentIndex = 0;+ this.fileIsOpen = false;+ WriteEmptyFiles();+ }++ private void OpenFile() throws IOException {+ int askMode;+ if (this.extractStatuses.get(this.currentIndex)) {+ askMode = this.testMode+ ? IInArchive.NExtract_NAskMode_kTest+ : IInArchive.NExtract_NAskMode_kExtract;+ } else {+ askMode = IInArchive.NExtract_NAskMode_kSkip;+ }++ int index = this.startIndex + this.currentIndex;++ OutputStream realOutStream = this.extractCallback.GetStream(this.ref2Offset + index, askMode);+ this.outStreamWithHashSpec.setStream(realOutStream);+ this.outStreamWithHashSpec.reset();+ if (realOutStream == null && askMode == IInArchive.NExtract_NAskMode_kExtract) {+ FileItem fileInfo = (FileItem)this.archiveDatabase.Files.get(index);+ if (!fileInfo.IsAnti && !fileInfo.IsDirectory)+ askMode = IInArchive.NExtract_NAskMode_kSkip;+ }+ this.extractCallback.PrepareOperation(askMode);+ }++ private int WriteEmptyFiles() throws IOException {+ int begin = this.currentIndex;+ for(;this.currentIndex < this.extractStatuses.size(); this.currentIndex++) {+ int index = this.startIndex + this.currentIndex;+ FileItem fileInfo = (FileItem)this.archiveDatabase.Files.get(index);+ if (!fileInfo.IsAnti && !fileInfo.IsDirectory && fileInfo.UnPackSize != 0)+ return -1; // return HRESULT.S_OK;+ OpenFile();++ this.extractCallback.SetOperationResult(IInArchive.NExtract_NOperationResult_kOK);+ this.outStreamWithHashSpec.releaseStream();+ }+ return this.extractStatuses.size() - begin;+ }++ public void write(int b) throws IOException {+ throw new IOException("FolderOutStream - write() not implemented");+ }++ public void /* UInt32 *processedSize */ write(byte[] data, int off, int size) throws IOException {+ int realProcessedSize = 0;+ while(this.currentIndex < this.extractStatuses.size()) {+ if (this.fileIsOpen) {+ int index = this.startIndex + this.currentIndex;+ FileItem fileInfo = (FileItem)this.archiveDatabase.Files.get(index);+ long fileSize = fileInfo.UnPackSize;++ long numBytesToWrite2 = fileSize - this.filePos;+ int tmp = size - realProcessedSize;+ if (tmp < numBytesToWrite2) numBytesToWrite2 = tmp;++ int processedSizeLocal;+ // int res = _outStreamWithHash.Write((const Byte *)data + realProcessedSize,numBytesToWrite, &processedSizeLocal));+ // if (res != HRESULT.S_OK) throw new java.io.IOException("_outStreamWithHash.Write : " + res); // return res;+ processedSizeLocal = (int)numBytesToWrite2;+ this.outStreamWithHashSpec.write(data, realProcessedSize + off, (int)numBytesToWrite2);++ this.filePos += processedSizeLocal;+ realProcessedSize += processedSizeLocal;++ if (this.filePos == fileSize) {+ boolean digestsAreEqual = !fileInfo.IsFileCRCDefined || (fileInfo.FileCRC == this.outStreamWithHashSpec.getCRC());+ this.extractCallback.SetOperationResult(digestsAreEqual ?+ IInArchive.NExtract_NOperationResult_kOK :+ IInArchive.NExtract_NOperationResult_kCRCError);++ this.outStreamWithHashSpec.releaseStream();+ this.fileIsOpen = false;+ this.currentIndex++;+ }+ if (realProcessedSize == size) {+ WriteEmptyFiles();+ return ;// return realProcessedSize;+ }+ } else {+ OpenFile();+ this.fileIsOpen = true;+ this.filePos = 0;+ }+ }+ }++ public void FlushCorrupted(int resultEOperationResult) throws IOException {+ while(this.currentIndex < this.extractStatuses.size()) {+ if (this.fileIsOpen) {+ this.extractCallback.SetOperationResult(resultEOperationResult);++ this.outStreamWithHashSpec.releaseStream();+ this.fileIsOpen = false;+ this.currentIndex++;+ } else {+ OpenFile();+ this.fileIsOpen = true;+ }+ }+ }++ public boolean IsWritingFinished() {+ return this.currentIndex == this.extractStatuses.size();+ }++}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Handler.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Handler.javanew file mode 100644index 000000000..8daaf15c5--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Handler.java@@ -0,0 +1,286 @@+package SevenZip.Archive.SevenZip;++import java.io.File;+import java.io.IOException;+import java.util.Vector;++import SevenZip.HRESULT;+import SevenZip.IInStream;+import SevenZip.MyRandomAccessFile;++import SevenZip.ICompressProgressInfo;+import SevenZip.Common.LocalProgress;+import SevenZip.Common.LocalCompressProgressInfo;+import SevenZip.Archive.IInArchive;+import SevenZip.Archive.IArchiveExtractCallback;+import SevenZip.Archive.SevenZipEntry;++public class Handler implements IInArchive {++ public IInStream _inStream;+ public ArchiveDB _database;+ int _numThreads = 1; // XXX: configurable++ public Handler(File archive) throws IOException {+ this(new MyRandomAccessFile(archive, "r"), kMaxCheckStartPosition);+ }++ public Handler(IInStream stream) throws IOException {+ this(stream, kMaxCheckStartPosition);+ }++ public Handler(IInStream stream, long maxCheckStartPosition) throws IOException {+ InStream archive = new InStream(stream, maxCheckStartPosition);+ this._database = new ArchiveDB(archive);+ this._inStream = stream;+ }++ public void Extract(int [] indices, int numItems,+ int testModeSpec, IArchiveExtractCallback extractCallback) throws IOException {++ boolean testMode = (testModeSpec != 0);+ long importantTotalUnPacked = 0;++ boolean allFilesMode = (numItems == -1);+ if (allFilesMode)+ numItems = this._database.Files.size();++ if (numItems == 0)+ return;++ Vector extractFolderInfoVector = new Vector();+ for (int ii = 0; ii < numItems; ii++) {+ int ref2Index = allFilesMode ? ii : indices[ii];++ ArchiveDB database = _database;+ int fileIndex = ref2Index;++ int folderIndex = database.FileIndexToFolderIndexMap.get(fileIndex);+ if (folderIndex == ArchiveDB.kNumNoIndex) {+ extractFolderInfoVector.add( new ExtractFolderInfo(fileIndex, ArchiveDB.kNumNoIndex));+ continue;+ }+ if (extractFolderInfoVector.isEmpty() ||+ folderIndex != ((ExtractFolderInfo)extractFolderInfoVector.lastElement()).FolderIndex) {+ extractFolderInfoVector.add(new ExtractFolderInfo(ArchiveDB.kNumNoIndex, folderIndex));+ Folder folderInfo = (Folder)database.Folders.get(folderIndex);+ long unPackSize = folderInfo.GetUnPackSize();+ importantTotalUnPacked += unPackSize;+ ((ExtractFolderInfo)extractFolderInfoVector.lastElement()).UnPackSize = unPackSize;+ }++ ExtractFolderInfo efi = (ExtractFolderInfo)extractFolderInfoVector.lastElement();++ int startIndex = database.FolderStartFileIndex.get(folderIndex); // CNum+ for (int index = efi.ExtractStatuses.size(); index <= fileIndex - startIndex; index++)+ efi.ExtractStatuses.add(index == fileIndex - startIndex);+ }++ extractCallback.SetTotal(importantTotalUnPacked);++ Decoder decoder = new Decoder(false);++ long currentImportantTotalUnPacked = 0;+ long totalFolderUnPacked;++ for (int i = 0; i < extractFolderInfoVector.size(); i++, currentImportantTotalUnPacked += totalFolderUnPacked) {+ ExtractFolderInfo efi = (ExtractFolderInfo)extractFolderInfoVector.get(i);+ totalFolderUnPacked = efi.UnPackSize;++ extractCallback.SetCompleted(currentImportantTotalUnPacked);++ int startIndex; // CNum+ if (efi.FileIndex != ArchiveDB.kNumNoIndex)+ startIndex = efi.FileIndex;+ else+ startIndex = this._database.FolderStartFileIndex.get(efi.FolderIndex);+++ FolderOutStream folderOutStream = new FolderOutStream(this._database, 0, startIndex, efi.ExtractStatuses, extractCallback, testMode);+ int result = HRESULT.S_OK;++ if (efi.FileIndex != ArchiveDB.kNumNoIndex)+ continue;++ int folderIndex = efi.FolderIndex; // CNum+ Folder folderInfo = (Folder)this._database.Folders.get(folderIndex);++ LocalProgress localProgressSpec = new LocalProgress(extractCallback, false);++ ICompressProgressInfo compressProgress = new LocalCompressProgressInfo(+ localProgressSpec,+ ICompressProgressInfo.INVALID,+ currentImportantTotalUnPacked);++ int packStreamIndex = this._database.FolderStartPackStreamIndex.get(folderIndex); // CNum+ long folderStartPackPos = this._database.GetFolderStreamPos(folderIndex, 0);++ try {+ /* TODO: result = */ decoder.Decode(+ this._inStream,+ folderStartPackPos,+ this._database.PackSizes,+ packStreamIndex,+ folderInfo,+ folderOutStream,+ compressProgress);++ if (result == HRESULT.S_FALSE) {+ folderOutStream.FlushCorrupted(IInArchive.NExtract_NOperationResult_kDataError);+ // if (result != HRESULT.S_OK) return result;+ continue;+ }+ if (result == HRESULT.E_NOTIMPL) {+ folderOutStream.FlushCorrupted(IInArchive.NExtract_NOperationResult_kUnSupportedMethod);+ // if (result != HRESULT.S_OK) return result;+ continue;+ }+ if (folderOutStream.IsWritingFinished()) {+ folderOutStream.FlushCorrupted(IInArchive.NExtract_NOperationResult_kDataError);+ // if (result != HRESULT.S_OK) return result;+ continue;+ }+ } catch(Exception e) {+ System.out.println("IOException : " + e);+ e.printStackTrace();+ folderOutStream.FlushCorrupted(IInArchive.NExtract_NOperationResult_kDataError);+ // if (result != HRESULT.S_OK) return result;+ continue;+ }+ }+ }++ protected void finalize() throws Throwable {+ close();+ super.finalize();+ }++ public void close() throws IOException {+ if (_inStream != null) _inStream.close();+ _inStream = null;+ _database.clear();+ }++ public int size() {+ return _database.Files.size();+ }++ private long getPackSize(int index2) {+ long packSize = 0;+ int folderIndex = _database.FileIndexToFolderIndexMap.get(index2);+ if (folderIndex != ArchiveDB.kNumNoIndex) {+ if (_database.FolderStartFileIndex.get(folderIndex) == index2)+ packSize = _database.GetFolderFullPackSize(folderIndex);+ }+ return packSize;+ }++ private static int GetUInt32FromMemLE(byte [] p , int off) {+ return p[off]+ | (((int)p[off + 1]) << 8)+ | (((int)p[off + 2]) << 16)+ | (((int)p[off + 3]) << 24);+ }++ private static String GetStringForSizeValue(int value) {+ for (int i = 31; i >= 0; i--)+ if ((1 << i) == value)+ return Integer.toString(i);+ StringBuffer result = new StringBuffer();+ if (value % (1 << 20) == 0) {+ result.append(value >> 20);+ result.append('m');+ } else if (value % (1 << 10) == 0) {+ result.append(value >> 10);+ result.append('k');+ } else {+ result.append(value);+ result.append('b');+ }+ return result.toString();+ }++ private String getMethods(int index2) {+ int folderIndex = _database.FileIndexToFolderIndexMap.get(index2);+ if (folderIndex != ArchiveDB.kNumNoIndex) {+ Folder folderInfo = (Folder)_database.Folders.get(folderIndex);+ StringBuffer methodsString = new StringBuffer();+ for (int i = folderInfo.Coders.size() - 1; i >= 0; i--) {+ CoderInfo coderInfo = (CoderInfo)folderInfo.Coders.get(i);+ if (methodsString.length() > 0)+ methodsString.append(' ');++ // MethodInfo methodInfo;++ for (int j = 0; j < coderInfo.AltCoders.size(); j++) {+ if (j > 0) methodsString.append('|');+ AltCoderInfo altCoderInfo = (AltCoderInfo)coderInfo.AltCoders.get(j);++ if (altCoderInfo.MethodID.getName() == null) {+ // TBD methodsString += altCoderInfo.MethodID.ConvertToString();+ } else {+ methodsString.append(altCoderInfo.MethodID.getName());++ if (altCoderInfo.MethodID.equals(MethodID.k_LZMA)) {+ if (altCoderInfo.Properties.size() >= 5) {+ methodsString.append(':');+ int dicSize = GetUInt32FromMemLE(altCoderInfo.Properties.toByteArray(), 1);+ methodsString.append(GetStringForSizeValue(dicSize));+ }+ }+ /* else if (altCoderInfo.MethodID == k_PPMD) {+ if (altCoderInfo.Properties.GetCapacity() >= 5) {+ Byte order = *(const Byte *)altCoderInfo.Properties;+ methodsString += ":o";+ methodsString += ConvertUInt32ToString(order);+ methodsString += ":mem";+ UInt32 dicSize = GetUInt32FromMemLE(+ ((const Byte *)altCoderInfo.Properties + 1));+ methodsString += GetStringForSizeValue(dicSize);+ }+ } else if (altCoderInfo.MethodID == k_AES) {+ if (altCoderInfo.Properties.GetCapacity() >= 1) {+ methodsString += ":";+ const Byte *data = (const Byte *)altCoderInfo.Properties;+ Byte firstByte = *data++;+ UInt32 numCyclesPower = firstByte & 0x3F;+ methodsString += ConvertUInt32ToString(numCyclesPower);+ }+ } else {+ if (altCoderInfo.Properties.GetCapacity() > 0) {+ methodsString += ":[";+ for (size_t bi = 0; bi < altCoderInfo.Properties.GetCapacity(); bi++) {+ if (bi > 5 && bi + 1 < altCoderInfo.Properties.GetCapacity()) {+ methodsString += "..";+ break;+ } else+ methodsString += GetHex2(altCoderInfo.Properties[bi]);+ }+ methodsString += "]";+ }+ }+ */+ }+ }+ }+ return methodsString.toString();+ }++ return new String();+ }++ public SevenZipEntry getEntry(int index) {+ SevenZip.Archive.SevenZip.FileItem item = (FileItem)_database.Files.get(index);+ return new SevenZipEntry(+ item.name,+ getPackSize(index),+ item.UnPackSize,+ (item.IsFileCRCDefined) ? item.FileCRC & 0xFFFFFFFFL : -1,+ item.LastWriteTime,+ (item.IsStartPosDefined) ? item.StartPos : -1,+ item.IsDirectory,+ item.Attributes,+ getMethods(index));+ }++}\ No newline at end of filediff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Header.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Header.javanew file mode 100644index 000000000..ce9847e0b--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Header.java@@ -0,0 +1,43 @@+package SevenZip.Archive.SevenZip;++class Header {++ public static final int kSignatureSize = 6;+ public static final byte [] kSignature= { '7', 'z', (byte)0xBC, (byte)0xAF, 0x27, 0x1C };+ public static final byte kMajorVersion = 0;++ public static class NID {+ public static final int kEnd = 0;+ public static final int kHeader = 1;+ public static final int kArchiveProperties = 2;+ public static final int kAdditionalStreamsInfo = 3;+ public static final int kMainStreamsInfo = 4;+ public static final int kFilesInfo = 5;++ public static final int kPackInfo = 6;+ public static final int kUnPackInfo = 7;+ public static final int kSubStreamsInfo = 8;++ public static final int kSize = 9;+ public static final int kCRC = 10;++ public static final int kFolder = 11;+ public static final int kCodersUnPackSize = 12;+ public static final int kNumUnPackStream = 13;++ public static final int kEmptyStream = 14;+ public static final int kEmptyFile = 15;+ public static final int kAnti = 16;++ public static final int kName = 17;+ public static final int kCreationTime = 18;+ public static final int kLastAccessTime = 19;+ public static final int kLastWriteTime = 20;+ public static final int kWinAttributes = 21;+ public static final int kComment = 22;++ public static final int kEncodedHeader = 23;++ public static final int kStartPos = 24;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InArchiveInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InArchiveInfo.javanew file mode 100644index 000000000..1e537dc69--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InArchiveInfo.java@@ -0,0 +1,18 @@+package SevenZip.Archive.SevenZip;++import Common.LongVector;++class InArchiveInfo {+ public byte ArchiveVersion_Major;+ public byte ArchiveVersion_Minor;++ public long StartPosition;+ public long StartPositionAfterHeader;+ public long DataStartPosition;+ public long DataStartPosition2;+ LongVector FileInfoPopIDs = new LongVector();++ void Clear() {+ FileInfoPopIDs.clear();+ }+}\ No newline at end of filediff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InByte2.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InByte2.javanew file mode 100644index 000000000..79683ade1--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InByte2.java@@ -0,0 +1,45 @@+package SevenZip.Archive.SevenZip;+import java.io.ByteArrayOutputStream;+import java.io.IOException;++class InByte2 {+ byte [] _buffer;+ int _size;+ int _pos;++ public InByte2() {+ }++ public InByte2(byte [] buffer, int size) {+ _buffer = buffer;+ _size = size;+ _pos = 0;+ }++ public int ReadByte() throws IOException {+ if(_pos >= _size)+ throw new IOException("CInByte2 - Can't read stream");+ return (_buffer[_pos++] & 0xFF);+ }++ int ReadBytes2(byte[] data, int size) {+ int processedSize;+ for(processedSize = 0; processedSize < size && _pos < _size; processedSize++)+ data[processedSize] = _buffer[_pos++];+ return processedSize;+ }++ boolean ReadBytes(byte[] data, int size) {+ int processedSize = ReadBytes2(data, size);+ return (processedSize == size);+ }++ int readBytes(ByteArrayOutputStream baos, int size) {+ int processedSize;+ for (processedSize = 0; processedSize < size && _pos < _size; processedSize++)+ baos.write(_buffer[_pos++]);+ return processedSize;+ }++ int GetProcessedSize() { return _pos; }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InStream.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InStream.javanew file mode 100644index 000000000..2d66ae785--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/InStream.java@@ -0,0 +1,292 @@+package SevenZip.Archive.SevenZip;++import java.io.ByteArrayOutputStream;+import java.io.IOException;+import java.util.Arrays;+import java.util.Vector;++import Common.BoolVector;+import Common.IntVector;++import SevenZip.IInStream;+import SevenZip.Common.StreamUtils;++public class InStream {++ public static final int kNumMax = 0x7FFFFFFF;++ final IInStream stream;++ private final Vector _inByteVector = new Vector();+ private /* TODO: final */ InByte2 _inByteBack = null;++ final long archiveBeginStreamPosition;+ long position;++ public InStream(IInStream stream, long searchHeaderSizeLimit) throws IOException {+ this.stream = stream;+ this.position = stream.Seek(0, IInStream.STREAM_SEEK_CUR);+ this.archiveBeginStreamPosition = FindAndReadSignature(searchHeaderSizeLimit);+ }++ private long FindAndReadSignature(+ long searchHeaderSizeLimit) throws IOException {++ this.stream.Seek(this.position, IInStream.STREAM_SEEK_SET);++ byte[] signature = new byte[Header.kSignatureSize];++ int processedSize = ReadDirect(this.stream, signature, 0, Header.kSignatureSize);+ if (processedSize != Header.kSignatureSize)+ throw new IOException("detected illegal signature length: " + processedSize + " at byte " + this.position);++ if (TestSignatureCandidate(signature, 0))+ return this.position;++ // SFX support+ final int kBufferSize = 1 << 16;+ byte [] buffer = new byte[kBufferSize];+ int numPrevBytes = Header.kSignatureSize - 1;++ System.arraycopy(signature, 1, buffer, 0, numPrevBytes);++ long curTestPos = this.position + 1;+ while (searchHeaderSizeLimit == -1 ||+ curTestPos - this.position <= searchHeaderSizeLimit) {++ int numReadBytes = kBufferSize - numPrevBytes;+ processedSize = ReadDirect(this.stream, buffer, numPrevBytes, numReadBytes);+ if (processedSize == -1)+ throw new IOException("unexpected EOF during search for signature");++ int numBytesInBuffer = numPrevBytes + processedSize;+ if (numBytesInBuffer < Header.kSignatureSize)+ throw new IOException("detected illegal signature length: " + numBytesInBuffer + " at byte " + this.position);++ int numTests = numBytesInBuffer - Header.kSignatureSize + 1;+ for (int pos=0; pos<numTests; pos++, curTestPos++) {+ if (TestSignatureCandidate(buffer, pos)) {+ this.position = curTestPos + Header.kSignatureSize;+ this.stream.Seek(this.position, IInStream.STREAM_SEEK_SET);+ return curTestPos;+ }+ }+ numPrevBytes = numBytesInBuffer - numTests;+ System.arraycopy(buffer, numTests, buffer, 0, numPrevBytes);+ }++ throw new IOException("signature not found within the given " + searchHeaderSizeLimit + " bytes");+ }++ public void AddByteStream(byte [] buffer, int size) {+ this._inByteVector.add(this._inByteBack = new InByte2(buffer, size));+ }++ public void DeleteByteStream() {+ this._inByteVector.removeElementAt(this._inByteVector.size() - 1);+ if (!this._inByteVector.isEmpty())+ this._inByteBack = (InByte2)this._inByteVector.lastElement();+ }++ public static boolean TestSignatureCandidate(byte[] testBytes, int off) {+ if (off == 0)+ return Arrays.equals(testBytes, Header.kSignature);+ for (int i=0; i<Header.kSignatureSize; i++) {+ // System.out.println(" " + i + ":" + testBytes[i] + " " + kSignature[i]);+ if (testBytes[i + off] != Header.kSignature[i])+ return false;+ }+ return true;+ }++ public int ReadDirect(+ IInStream stream,+ byte[] data,+ int off,+ int size) throws IOException {+ int realProcessedSize = StreamUtils.ReadStream(stream, data, off, size);+ if (realProcessedSize != -1)+ this.position += realProcessedSize;+ return realProcessedSize;+ }++ public int ReadDirect(byte[] data, int size) throws IOException {+ return ReadDirect(this.stream, data, 0, size);+ }++ public boolean SafeReadDirect(byte[] data, int size) throws IOException {+ return (ReadDirect(data, size) == size);+ }++ public int SafeReadDirectUInt32() throws IOException {+ int val = 0;+ byte[] b = new byte[4];++ int realProcessedSize = ReadDirect(b, 4);+ if (realProcessedSize != 4)+ throw new IOException("Unexpected End Of Archive"); // throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);++ for (int i = 0; i < 4; i++)+ val |= (b[i] & 0xFF) << (8 * i);+ return val;+ }++ public int ReadUInt32() throws IOException {+ int value = 0;+ for (int i = 0; i < 4; i++) {+ int b = ReadByte();+ value |= ((b) << (8 * i));+ }+ return value;+ }++ public long ReadUInt64() throws IOException {+ long value = 0;+ for (int i = 0; i < 8; i++) {+ int b = ReadByte();+ value |= (((long)b) << (8 * i));+ }+ return value;+ }++ public boolean ReadBytes(byte data[], int size) throws IOException {+ return this._inByteBack.ReadBytes(data, size);+ }++ public boolean ReadBytes(ByteArrayOutputStream baos, int size) throws IOException {+ return this._inByteBack.readBytes(baos, size) == size;+ }++ public int ReadByte() throws IOException {+ return this._inByteBack.ReadByte();+ }++ public long SafeReadDirectUInt64() throws IOException {+ long val = 0;+ byte [] b = new byte[8];++ int realProcessedSize = ReadDirect(b, 8);+ if (realProcessedSize != 8)+ throw new IOException("Unexpected End Of Archive"); // throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);++ for (int i = 0; i < 8; i++) {+ val |= ((long)(b[i] & 0xFF) << (8 * i));+ }+ return val;+ }++ public char ReadWideCharLE() throws IOException {+ int b1 = this._inByteBack.ReadByte();+ int b2 = this._inByteBack.ReadByte();+ char c = (char)(((char)(b2) << 8) + b1);+ return c;+ }++ public long ReadNumber() throws IOException {+ int firstByte = ReadByte();++ int mask = 0x80;+ long value = 0;+ for (int i = 0; i < 8; i++) {+ if ((firstByte & mask) == 0) {+ long highPart = firstByte & (mask - 1);+ value += (highPart << (i * 8));+ return value;+ }+ int b = ReadByte();+ if (b < 0)+ throw new IOException("ReadNumber - Can't read stream");++ value |= (((long)b) << (8 * i));+ mask >>= 1;+ }+ return value;+ }++ public int ReadNum() throws IOException { // CNum+ long value64 = ReadNumber();+ if (value64 > InStream.kNumMax)+ throw new IOException("ReadNum - value > CNum.kNumMax"); // return E_FAIL;++ return (int)value64;+ }++ public long ReadID() throws IOException {+ return ReadNumber();+ }++ public void SkeepData(long size) throws IOException {+ for (long i = 0; i < size; i++)+ ReadByte();+ }++ public void SkeepData() throws IOException {+ long size = ReadNumber();+ SkeepData(size);+ }++ public void skipToAttribute(long attribute) throws IOException {+ long type;+ while ((type = ReadID()) != attribute) {+ if (type == Header.NID.kEnd)+ throw new IOException("unexpected end of archive");+ SkeepData();+ }+ }++ public void close() throws IOException {+ if (this.stream != null) this.stream.close(); // _stream.Release();+ }++ public BoolVector ReadBoolVector(int numItems) throws IOException {+ BoolVector v = new BoolVector(numItems);+ int b = 0;+ int mask = 0;+ for (int i=0; i<numItems; i++) {+ if (mask == 0) {+ b = ReadByte();+ mask = 0x80;+ }+ v.add((b & mask) != 0);+ mask >>= 1;+ }+ return v;+ }++ public BoolVector ReadBoolVector2(int numItems) throws IOException { // CBoolVector+ int allAreDefined = ReadByte();+ if (allAreDefined == 0)+ return ReadBoolVector(numItems);+ BoolVector v = new BoolVector(numItems);+ for (int i = 0; i < numItems; i++)+ v.add(true);+ return v;+ }++ public IntVector ReadHashDigests(+ int numItems,+ BoolVector digestsDefined) throws IOException {+ digestsDefined.setBoolVector(ReadBoolVector2(numItems));+ final IntVector digests = new IntVector(numItems);+ digests.clear();+ digests.Reserve(numItems);+ for (int i=0; i<numItems; i++) {+ int crc = 0;+ if (digestsDefined.get(i))+ crc = ReadUInt32();+ digests.add(crc);+ }+ return digests;+ }++ public static final long SECS_BETWEEN_EPOCHS = 11644473600L;+ public static final long SECS_TO_100NS = 10000000L; /* 10^7 */++ public static long FileTimeToLong(int dwHighDateTime, int dwLowDateTime) {+ // The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1+ long tm = dwHighDateTime;+ tm <<=32;+ tm |= (dwLowDateTime & 0xFFFFFFFFL);+ return (tm - (SECS_BETWEEN_EPOCHS * SECS_TO_100NS)) / (10000L); /* now convert to milliseconds */+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/MethodID.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/MethodID.javanew file mode 100644index 000000000..cd8aee80f--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/MethodID.java@@ -0,0 +1,83 @@+package SevenZip.Archive.SevenZip;++public class MethodID implements Comparable {++ public static final MethodID k_LZMA = new MethodID(0x3, 0x1, 0x1, "LZMA");+ public static final MethodID k_PPMD = new MethodID(0x3, 0x4, 0x1, "PPMD");+ public static final MethodID k_BCJ_X86 = new MethodID(0x3, 0x3, 0x1, 0x3, "BCJ_x86");+ public static final MethodID k_BCJ = new MethodID(0x3, 0x3, 0x1, 0x3, "BCJ");+ public static final MethodID k_BCJ2 = new MethodID(0x3, 0x3, 0x1, 0x1B, "BCJ2");+ public static final MethodID k_Deflate = new MethodID(0x4, 0x1, 0x8, "Deflate");+ public static final MethodID k_Deflate64 = new MethodID(0x4, 0x1, 0x9, "Defalte64");+ public static final MethodID k_BZip2 = new MethodID(0x4, 0x2, 0x2, "BZip2");+ public static final MethodID k_Copy = new MethodID(0x0, "Copy");+ public static final MethodID k_7zAES = new MethodID(0x6, 0xF1, 0x07, 0x01, "7zAES");++ public byte[] ID;+ public byte IDSize;++ private static final int kMethodIDSize = 15;+ private final String name;++ public MethodID(String name) {+ this.ID = new byte[kMethodIDSize];+ this.IDSize = 0;+ this.name = name;+ }++ public MethodID(int a, String name) {+ int size = 1;+ this.ID = new byte[size];+ this.IDSize = (byte)size;+ this.ID[0] = (byte)a;+ this.name = name;+ }++ public MethodID(int a, int b, int c, String name) {+ int size = 3;+ this.ID = new byte[size];+ this.IDSize = (byte)size;+ this.ID[0] = (byte)a;+ this.ID[1] = (byte)b;+ this.ID[2] = (byte)c;+ this.name = name;+ }++ public MethodID(int a, int b, int c, int d, String name) {+ int size = 4;+ this.ID = new byte[size];+ this.IDSize = (byte)size;+ this.ID[0] = (byte)a;+ this.ID[1] = (byte)b;+ this.ID[2] = (byte)c;+ this.ID[3] = (byte)d;+ this.name = name;+ }++ public int compareTo(Object arg) {+ MethodID o = (MethodID)arg;+ if (this.IDSize != o.IDSize) return (int)(this.IDSize - o.IDSize);+ for (int i=0; i<this.IDSize; i++)+ if (this.ID[i] != o.ID[i]) return (int)(this.ID[i] - o.ID[i]);+ return 0;+ }++ public boolean equals(Object anObject) {+ if (anObject instanceof MethodID) {+ MethodID m = (MethodID)anObject;+ if (this.IDSize != m.IDSize) return false;+ for(int i = 0; i < this.IDSize ; i++)+ if (this.ID[i] != m.ID[i]) return false;+ return true;+ }+ return super.equals(anObject);+ }++ public String getName() {+ return this.name;+ }++ public String toString() {+ return (this.name == null) ? "undefined" : this.name;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/StreamSwitch.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/StreamSwitch.javanew file mode 100644index 000000000..47809bc51--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/StreamSwitch.java@@ -0,0 +1,45 @@+package SevenZip.Archive.SevenZip;++import java.io.IOException;+import java.util.Vector;++class StreamSwitch {++ InStream _archive;+ boolean _needRemove;++ public StreamSwitch() {+ _needRemove = false;+ }++ public void close() {+ Remove();+ }++ void Remove() {+ if (_needRemove) {+ _archive.DeleteByteStream();+ _needRemove = false;+ }+ }++ void Set(InStream archive, byte[] data) {+ Set(archive, data, data.length);+ }++ void Set(InStream archive, byte[] data, int size) {+ Remove();+ _archive = archive;+ _archive.AddByteStream(data, size);+ _needRemove = true;+ }++ void Set(InStream archive, Vector dataVector) throws IOException {+ Remove();+ int external = archive.ReadByte();+ if (external != 0) {+ int dataIndex = archive.ReadNum();+ Set(archive, (byte[])dataVector.get(dataIndex));+ }+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZipEntry.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZipEntry.javanew file mode 100644index 000000000..906b4386f--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZipEntry.java@@ -0,0 +1,132 @@+package SevenZip.Archive;++import SevenZip.Archive.SevenZip.MethodID;++public class SevenZipEntry {++ protected long LastWriteTime;++ protected long UnPackSize;+ protected long PackSize;++ protected int Attributes;+ protected long FileCRC;++ protected boolean IsDirectory;++ protected String Name;+ protected String Methods;++ protected long Position;++ public SevenZipEntry(+ String name,+ long packSize,+ long unPackSize,+ long crc,+ long lastWriteTime,+ long position,+ boolean isDir,+ int att,+ String methods) {++ this.Name = name;+ this.PackSize = packSize;+ this.UnPackSize = unPackSize;+ this.FileCRC = crc;+ this.LastWriteTime = lastWriteTime;+ this.Position = position;+ this.IsDirectory = isDir;+ this.Attributes = att;+ this.Methods = methods;+ }++ public SevenZipEntry(+ String name,+ long packSize,+ long unPackSize,+ long crc,+ long lastWriteTime,+ long position,+ boolean isDir,+ int att,+ MethodID[] methods) {++ this.Name = name;+ this.PackSize = packSize;+ this.UnPackSize = unPackSize;+ this.FileCRC = crc;+ this.LastWriteTime = lastWriteTime;+ this.Position = position;+ this.IsDirectory = isDir;+ this.Attributes = att;++ StringBuffer methodNames = new StringBuffer();+ for (int i=0; i<methods.length; i++)+ if (methods[i].getName() != null) {+ if (methodNames.length() > 0)+ methodNames.append(' ');+ methodNames.append(methods[i].getName());+ }+ this.Methods = methodNames.toString();+ }++ public long getCompressedSize() {+ return PackSize;+ }++ public long getSize() {+ return UnPackSize;+ }++ public long getCrc() {+ return FileCRC;+ }++ public String getName() {+ return Name;+ }++ public long getTime() {+ return LastWriteTime;+ }++ public long getPosition() {+ return Position;+ }++ public boolean isDirectory() {+ return IsDirectory;+ }++ static final String kEmptyAttributeChar = ".";+ static final String kDirectoryAttributeChar = "D";+ static final String kReadonlyAttributeChar = "R";+ static final String kHiddenAttributeChar = "H";+ static final String kSystemAttributeChar = "S";+ static final String kArchiveAttributeChar = "A";+ static public final int FILE_ATTRIBUTE_READONLY = 0x00000001 ;+ static public final int FILE_ATTRIBUTE_HIDDEN = 0x00000002 ;+ static public final int FILE_ATTRIBUTE_SYSTEM = 0x00000004 ;+ static public final int FILE_ATTRIBUTE_DIRECTORY = 0x00000010;+ static public final int FILE_ATTRIBUTE_ARCHIVE = 0x00000020 ;++ public String getAttributesString() {+ String ret = "";+ ret += ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0 || IsDirectory) ?+ kDirectoryAttributeChar: kEmptyAttributeChar;+ ret += ((Attributes & FILE_ATTRIBUTE_READONLY) != 0)?+ kReadonlyAttributeChar: kEmptyAttributeChar;+ ret += ((Attributes & FILE_ATTRIBUTE_HIDDEN) != 0) ?+ kHiddenAttributeChar: kEmptyAttributeChar;+ ret += ((Attributes & FILE_ATTRIBUTE_SYSTEM) != 0) ?+ kSystemAttributeChar: kEmptyAttributeChar;+ ret += ((Attributes & FILE_ATTRIBUTE_ARCHIVE) != 0) ?+ kArchiveAttributeChar: kEmptyAttributeChar;+ return ret;+ }++ public String getMethods() {+ return Methods;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/ArchiveExtractCallback.java b/libbuild/J7Zip-modified/src/SevenZip/ArchiveExtractCallback.javanew file mode 100644index 000000000..aabe1d3a8--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ArchiveExtractCallback.java@@ -0,0 +1,148 @@+package SevenZip;++import SevenZip.Archive.IArchiveExtractCallback;+import SevenZip.Archive.IInArchive;+import SevenZip.Archive.SevenZipEntry;++import java.io.File;+import java.io.IOException;+import java.io.OutputStream;+import java.io.RandomAccessFile;++public class ArchiveExtractCallback implements IArchiveExtractCallback // , ICryptoGetTextPassword,+{++ protected IInArchive archiveHandler; // IInArchive+ protected String filePath; // name inside arcvhive+ protected String diskFilePath; // full path to file on disk++ public long NumErrors;+ public boolean PasswordIsDefined;+ protected String Password;+ protected boolean extractMode;++ protected boolean isDirectory;+ protected final File exractPath;++ public ArchiveExtractCallback(File extractPath) {+ this.PasswordIsDefined = false;+ this.exractPath = extractPath;+ }++ public ArchiveExtractCallback() {+ this(null);+ }++ public void Init(IInArchive archiveHandler) {+ this.NumErrors = 0;+ this.archiveHandler = archiveHandler;+ }++ public void SetTotal(long size) { }+ public void SetCompleted(long completeValue) { }++ public void PrepareOperation(int askExtractMode) {+ this.extractMode = (askExtractMode == IInArchive.NExtract_NAskMode_kExtract);+ switch (askExtractMode) {+ case IInArchive.NExtract_NAskMode_kExtract:+ System.out.print("Extracting ");+ break;+ case IInArchive.NExtract_NAskMode_kTest:+ System.out.print("Testing ");+ break;+ case IInArchive.NExtract_NAskMode_kSkip:+ System.out.print("Skipping ");+ break;+ };+ System.out.print(this.filePath);+ }++ public void SetOperationResult(int operationResult) throws IOException {+ if (operationResult != IInArchive.NExtract_NOperationResult_kOK) {+ this.NumErrors++;+ System.out.print(" ");+ switch(operationResult) {+ case IInArchive.NExtract_NOperationResult_kUnSupportedMethod:+ throw new IOException("Unsupported Method");+ case IInArchive.NExtract_NOperationResult_kCRCError:+ throw new IOException("CRC Failed");+ case IInArchive.NExtract_NOperationResult_kDataError:+ throw new IOException("Data Error");+ default:+ // throw new IOException("Unknown Error");+ }+ }+ System.out.println();+ }++ public OutputStream GetStream(int index, int askExtractMode) throws IOException {+ RAOutputStream r = null;+ SevenZipEntry item = this.archiveHandler.getEntry(index);+ this.filePath = item.getName();++ File file;+ if (this.exractPath == null) {+ file = new File(this.filePath);+ } else {+ file = new File(this.exractPath, this.filePath);+ }+ this.diskFilePath = file.getAbsolutePath();++ if (askExtractMode == IInArchive.NExtract_NAskMode_kExtract) {+ if (this.isDirectory = item.isDirectory()) {+ if (!file.isDirectory() && !file.mkdirs())+ throw new IOException("failed to make directories: " + file);+ return null;+ }++ File dirs = file.getParentFile();+ if (dirs != null && !dirs.isDirectory() && !dirs.mkdirs()) {+ throw new IOException("failed to make directories: " + dirs);+ }++ long pos = item.getPosition();+ if (pos == -1) {+ file.delete();+ }++ RandomAccessFile outStr = new RandomAccessFile(file, "rw");++ if (pos != -1)+ outStr.seek(pos);++ r = new RAOutputStream(outStr);+ }++ // other case : skip ...+ return r;+ }++ private class RAOutputStream extends OutputStream {+ RandomAccessFile file;++ public RAOutputStream(RandomAccessFile f) {+ this.file = f;+ }++ public void close() throws IOException {+ this.file.close();+ this.file = null;+ }+ /*+ public void flush() throws IOException {+ file.flush();+ }+ */+ public void write(byte[] b) throws IOException {+ this.file.write(b);+ }++ public void write(byte[] b, int off, int len) throws IOException {+ this.file.write(b,off,len);+ }++ public void write(int b) throws IOException {+ this.file.write(b);+ }+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/CRC.java b/libbuild/J7Zip-modified/src/SevenZip/CRC.javanew file mode 100644index 000000000..f2f791f17--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/CRC.java@@ -0,0 +1,52 @@+// SevenZip/CRC.java++package SevenZip;++public class CRC+{+ static public int[] Table = new int[256];++ static+ {+ for (int i = 0; i < 256; i++)+ {+ int r = i;+ for (int j = 0; j < 8; j++)+ if ((r & 1) != 0)+ r = (r >>> 1) ^ 0xEDB88320;+ else+ r >>>= 1;+ Table[i] = r;+ }+ }++ int _value = -1;++ public void Init()+ {+ _value = -1;+ }++ public void Update(byte[] data, int offset, int size)+ {+ for (int i = 0; i < size; i++)+ _value = Table[(_value ^ data[offset + i]) & 0xFF] ^ (_value >>> 8);+ }++ public void Update(byte[] data)+ {+ int size = data.length;+ for (int i = 0; i < size; i++)+ _value = Table[(_value ^ data[i]) & 0xFF] ^ (_value >>> 8);+ }++ public void UpdateByte(int b)+ {+ _value = Table[(_value ^ b) & 0xFF] ^ (_value >>> 8);+ }++ public int GetDigest()+ {+ return _value ^ (-1);+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Common/InBuffer.java b/libbuild/J7Zip-modified/src/SevenZip/Common/InBuffer.javanew file mode 100644index 000000000..35c692048--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Common/InBuffer.java@@ -0,0 +1,77 @@+package SevenZip.Common;++import java.io.IOException;+import java.io.InputStream;++public class InBuffer {++ int _bufferPos;+ int _bufferLimit;+ byte [] _bufferBase;+ InputStream _stream = null; // CMyComPtr<ISequentialInStream>+ long _processedSize;+ int _bufferSize;+ boolean _wasFinished;++ public InBuffer() {++ }+ // ~CInBuffer() { Free(); }++ public void Create(int bufferSize) {+ final int kMinBlockSize = 1;+ if (bufferSize < kMinBlockSize)+ bufferSize = kMinBlockSize;+ if (_bufferBase != null && _bufferSize == bufferSize)+ return ;+ Free();+ _bufferSize = bufferSize;+ _bufferBase = new byte[bufferSize];+ }+ void Free() {+ _bufferBase = null;+ }++ public void SetStream(InputStream stream) { // ISequentialInStream+ _stream = stream;+ }+ public void Init() {+ _processedSize = 0;+ _bufferPos = 0; // = _bufferBase;+ _bufferLimit = 0; // _buffer;+ _wasFinished = false;+ }+ public void ReleaseStream() throws IOException {+ if (_stream != null) _stream.close(); // _stream.Release();+ _stream = null;+ }++ public int read() throws IOException {+ if(_bufferPos >= _bufferLimit)+ return ReadBlock2();+ return _bufferBase[_bufferPos++] & 0xFF;+ }++ public boolean ReadBlock() throws IOException {+ if (_wasFinished)+ return false;+ _processedSize += _bufferPos; // (_buffer - _bufferBase);++ int numProcessedBytes = _stream.read(_bufferBase, 0,_bufferSize);+ if (numProcessedBytes == -1) numProcessedBytes = 0; // EOF++ _bufferPos = 0; // _bufferBase;+ _bufferLimit = numProcessedBytes; // _buffer + numProcessedBytes;+ _wasFinished = (numProcessedBytes == 0);+ return (!_wasFinished);+ }++ public int ReadBlock2() throws IOException {+ if(!ReadBlock())+ return -1; // 0xFF;+ return _bufferBase[_bufferPos++] & 0xFF;+ }++ public long GetProcessedSize() { return _processedSize + (_bufferPos); }+ public boolean WasFinished() { return _wasFinished; }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Common/LocalCompressProgressInfo.java b/libbuild/J7Zip-modified/src/SevenZip/Common/LocalCompressProgressInfo.javanew file mode 100644index 000000000..ee8d87ab6--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Common/LocalCompressProgressInfo.java@@ -0,0 +1,44 @@+package SevenZip.Common;++import SevenZip.ICompressProgressInfo;++public class LocalCompressProgressInfo implements ICompressProgressInfo {+ final ICompressProgressInfo _progress;++ final boolean _inStartValueIsAssigned;+ final boolean _outStartValueIsAssigned;+ final long _inStartValue;+ final long _outStartValue;++ public LocalCompressProgressInfo(+ ICompressProgressInfo progress,+ long inStartValue,+ long outStartValue) {+ _progress = progress;+ _inStartValueIsAssigned = (inStartValue != ICompressProgressInfo.INVALID);+ _inStartValue = inStartValue;+ _outStartValueIsAssigned = (outStartValue != ICompressProgressInfo.INVALID);+ _outStartValue = outStartValue;+ }++ public void SetRatioInfo(long inSize, long outSize) {+ long inSizeNew, outSizeNew;+ long inSizeNewPointer;+ long outSizeNewPointer;+ if (_inStartValueIsAssigned && inSize != ICompressProgressInfo.INVALID) {+ inSizeNew = _inStartValue + (inSize); // *inSize+ inSizeNewPointer = inSizeNew;+ } else {+ inSizeNewPointer = ICompressProgressInfo.INVALID;+ }++ if (_outStartValueIsAssigned && outSize != ICompressProgressInfo.INVALID) {+ outSizeNew = _outStartValue + (outSize);+ outSizeNewPointer = outSizeNew;+ } else {+ outSizeNewPointer = ICompressProgressInfo.INVALID;+ }+ _progress.SetRatioInfo(inSizeNewPointer, outSizeNewPointer);+ }++}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Common/LocalProgress.java b/libbuild/J7Zip-modified/src/SevenZip/Common/LocalProgress.javanew file mode 100644index 000000000..f54e3d8de--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Common/LocalProgress.java@@ -0,0 +1,19 @@+package SevenZip.Common;++import SevenZip.ICompressProgressInfo;+import SevenZip.IProgress;++public class LocalProgress implements ICompressProgressInfo {+ private final IProgress _progress;+ private final boolean _inSizeIsMain;++ public LocalProgress(IProgress progress, boolean inSizeIsMain) {+ this._progress = progress;+ this._inSizeIsMain = inSizeIsMain;+ }++ public void SetRatioInfo(long inSize, long outSize) {+ _progress.SetCompleted(_inSizeIsMain ? inSize : outSize);+ }++}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Common/StreamUtils.java b/libbuild/J7Zip-modified/src/SevenZip/Common/StreamUtils.javanew file mode 100644index 000000000..a034e0763--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Common/StreamUtils.java@@ -0,0 +1,27 @@+package SevenZip.Common;++import java.io.IOException;+import java.io.InputStream;++public class StreamUtils {++ static public int ReadStream(InputStream stream, byte[] data, int off, int size) throws IOException {+ int processedSize = 0;++ while(size != 0) {+ int processedSizeLoc = stream.read(data,off + processedSize,size);+ if (processedSizeLoc > 0)+ {+ processedSize += processedSizeLoc;+ size -= processedSizeLoc;+ }+ if (processedSizeLoc == -1) {+ if (processedSize > 0) return processedSize;+ return -1; // EOF+ }+ }+ return processedSize;+ }++ // HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize);+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/Branch/BCJ2_x86_Decoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/Branch/BCJ2_x86_Decoder.javanew file mode 100644index 000000000..b8c33699e--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/Branch/BCJ2_x86_Decoder.java@@ -0,0 +1,187 @@++package SevenZip.Compression.Branch;++import java.io.IOException;+import java.io.InputStream;+import java.io.OutputStream;+import java.util.Vector;++import SevenZip.Compression.LZ.OutWindow;++import SevenZip.ICompressCoder2;+import SevenZip.ICompressProgressInfo;+import SevenZip.Common.InBuffer;++public class BCJ2_x86_Decoder implements ICompressCoder2 {++ public static final int kNumMoveBits = 5;++ InBuffer _mainInStream = new InBuffer();+ InBuffer _callStream = new InBuffer();+ InBuffer _jumpStream = new InBuffer();++ SevenZip.Compression.RangeCoder.BitDecoder _statusE8Decoder[] = new SevenZip.Compression.RangeCoder.BitDecoder[256];+ SevenZip.Compression.RangeCoder.BitDecoder _statusE9Decoder = new SevenZip.Compression.RangeCoder.BitDecoder(kNumMoveBits);+ SevenZip.Compression.RangeCoder.BitDecoder _statusJccDecoder = new SevenZip.Compression.RangeCoder.BitDecoder(kNumMoveBits);++ OutWindow _outStream = new OutWindow();+ SevenZip.Compression.RangeCoder.Decoder _rangeDecoder = new SevenZip.Compression.RangeCoder.Decoder();+++ // static final boolean IsJcc(int b0, int b1) {+ // return ((b0 == 0x0F) && ((b1 & 0xF0) == 0x80));+ // }++ void CodeReal(+ Vector inStreams,+ Object useless1, // const UInt64 ** /* inSizes */,+ int numInStreams,+ Vector outStreams,+ Object useless2, // const UInt64 ** /* outSizes */,+ int numOutStreams,+ ICompressProgressInfo progress) throws java.io.IOException {++ if (numInStreams != 4 || numOutStreams != 1)+ throw new IllegalArgumentException("numInStreams != 4 || numOutStreams != 1");++ _mainInStream.Create(1 << 16);+ _callStream.Create(1 << 20);+ _jumpStream.Create(1 << 16);+ _rangeDecoder.Create(1 << 20);+ _outStream.Create(1 << 16);++ _mainInStream.SetStream((InputStream)inStreams.get(0));+ _callStream.SetStream((InputStream)inStreams.get(1));+ _jumpStream.SetStream((InputStream)inStreams.get(2));+ _rangeDecoder.SetStream((InputStream)inStreams.get(3));+ _outStream.SetStream((OutputStream)outStreams.get(0));++ _mainInStream.Init();+ _callStream.Init();+ _jumpStream.Init();+ _rangeDecoder.Init();+ _outStream.Init();++ for (int i = 0; i < 256; i++) {+ _statusE8Decoder[i] = new SevenZip.Compression.RangeCoder.BitDecoder(kNumMoveBits);+ _statusE8Decoder[i].Init();+ }+ _statusE9Decoder.Init();+ _statusJccDecoder.Init();++ int prevByte = 0;+ int processedBytes = 0;+ for (;;) {++ if (processedBytes > (1 << 20) && progress != null) {+ long nowPos64 = _outStream.GetProcessedSize();+ progress.SetRatioInfo(ICompressProgressInfo.INVALID, nowPos64);+ processedBytes = 0;+ }++ processedBytes++;+ int b = _mainInStream.read();+ if (b == -1) {+ Flush();+ return;+ }+ _outStream.WriteByte(b); // System.out.println("0:"+b);+ // if ((b != 0xE8) && (b != 0xE9) && (!IsJcc(prevByte, b))) {+ if ((b != 0xE8) && (b != 0xE9) && (!((prevByte == 0x0F) && ((b & 0xF0) == 0x80)))) {+ prevByte = b;+ continue;+ }++ boolean status;+ if (b == 0xE8)+ status = (_statusE8Decoder[prevByte].Decode(_rangeDecoder) == 1);+ else if (b == 0xE9)+ status = (_statusE9Decoder.Decode(_rangeDecoder) == 1);+ else+ status = (_statusJccDecoder.Decode(_rangeDecoder) == 1);++ if (status) {+ int src;+ if (b == 0xE8) {+ int b0 = _callStream.read();+ // if(b0 == -1) return HRESULT.S_FALSE;+ src = ((int)b0) << 24;++ b0 = _callStream.read();+ // if(b0 == -1) return HRESULT.S_FALSE;+ src |= ((int)b0) << 16;++ b0 = _callStream.read();+ // if(b0 == -1) return HRESULT.S_FALSE;+ src |= ((int)b0) << 8;++ b0 = _callStream.read();+ if (b0 == -1) return; // TODO: HRESULT.S_FALSE;+ src |= ((int)b0);++ } else {+ int b0 = _jumpStream.read();+ // if(b0 == -1) return HRESULT.S_FALSE;+ src = ((int)b0) << 24;++ b0 = _jumpStream.read();+ // if(b0 == -1) return HRESULT.S_FALSE;+ src |= ((int)b0) << 16;++ b0 = _jumpStream.read();+ // if(b0 == -1) return HRESULT.S_FALSE;+ src |= ((int)b0) << 8;++ b0 = _jumpStream.read();+ if(b0 == -1) return; // TODO: HRESULT.S_FALSE;+ src |= ((int)b0);++ }+ int dest = src - ((int)_outStream.GetProcessedSize() + 4) ;+ _outStream.WriteByte(dest);+ _outStream.WriteByte((dest >> 8));+ _outStream.WriteByte((dest >> 16));+ _outStream.WriteByte((dest >> 24));+ prevByte = (int)(dest >> 24) & 0xFF;+ processedBytes += 4;+ } else+ prevByte = b;+ }+ }++ public void Flush() throws IOException {+ _outStream.Flush();+ }++ public void Code(+ Vector inStreams, // ISequentialInStream **inStreams,+ Object useless_inSizes, // const UInt64 ** /* inSizes */,+ int numInStreams,+ Vector outStreams, // ISequentialOutStream **outStreams+ Object useless_outSizes, // const UInt64 ** /* outSizes */,+ int numOutStreams,+ ICompressProgressInfo progress) throws java.io.IOException {++ try {+ CodeReal(inStreams, useless_inSizes, numInStreams,+ outStreams, useless_outSizes,numOutStreams, progress);+ } catch(java.io.IOException e) {+ throw e;+ } finally {+ ReleaseStreams();+ }+ }++ void ReleaseStreams() throws java.io.IOException {+ _mainInStream.ReleaseStream();+ _callStream.ReleaseStream();+ _jumpStream.ReleaseStream();+ _rangeDecoder.ReleaseStream();+ _outStream.ReleaseStream();+ }++ public void close() throws java.io.IOException {+ ReleaseStreams();+ }++}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/Branch/BCJ_x86_Decoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/Branch/BCJ_x86_Decoder.javanew file mode 100644index 000000000..87cccc26b--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/Branch/BCJ_x86_Decoder.java@@ -0,0 +1,114 @@+package SevenZip.Compression.Branch;++import SevenZip.HRESULT;+import SevenZip.ICompressFilter;++public class BCJ_x86_Decoder implements ICompressFilter {++ // struct CBranch86 - begin+ int [] _prevMask = new int[1]; // UInt32+ int [] _prevPos = new int[1]; // UInt32+ void x86Init() {+ _prevMask[0] = 0;+ _prevPos[0] = -5;+ }+ // struct CBranch86 - end++ static final boolean [] kMaskToAllowedStatus = {true, true, true, false, true, false, false, false };++ static final int [] kMaskToBitNumber = {0, 1, 2, 2, 3, 3, 3, 3};++ static final boolean Test86MSByte(int b) { return ((b) == 0 || (b) == 0xFF); }++ static final int x86_Convert(byte [] buffer, int endPos, int nowPos,+ int [] prevMask, int [] prevPos, boolean encoding) {+ int bufferPos = 0;+ int limit;++ if (endPos < 5)+ return 0;++ if (nowPos - prevPos[0] > 5)+ prevPos[0] = nowPos - 5;++ limit = endPos - 5;+ while(bufferPos <= limit) {+ int b = (buffer[bufferPos] & 0xFF);+ int offset;+ if (b != 0xE8 && b != 0xE9) {+ bufferPos++;+ continue;+ }+ offset = (nowPos + bufferPos - prevPos[0]);+ prevPos[0] = (nowPos + bufferPos);+ if (offset > 5)+ prevMask[0] = 0;+ else {+ for (int i = 0; i < offset; i++) {+ prevMask[0] &= 0x77;+ prevMask[0] <<= 1;+ }+ }+ b = (buffer[bufferPos + 4] & 0xFF);+ if (Test86MSByte(b) && kMaskToAllowedStatus[(prevMask[0] >> 1) & 0x7] &&+ (prevMask[0] >>> 1) < 0x10) {+ int src =+ ((int)(b) << 24) |+ ((int)(buffer[bufferPos + 3] & 0xFF) << 16) |+ ((int)(buffer[bufferPos + 2] & 0xFF) << 8) |+ (buffer[bufferPos + 1] & 0xFF);++ int dest;+ for (;;) {+ int index;+ if (encoding)+ dest = (nowPos + bufferPos + 5) + src;+ else+ dest = src - (nowPos + bufferPos + 5);+ if (prevMask[0] == 0)+ break;+ index = kMaskToBitNumber[prevMask[0] >>> 1];+ b = (int)((dest >> (24 - index * 8)) & 0xFF);+ if (!Test86MSByte(b))+ break;+ src = dest ^ ((1 << (32 - index * 8)) - 1);+ }+ buffer[bufferPos + 4] = (byte)(~(((dest >> 24) & 1) - 1));+ buffer[bufferPos + 3] = (byte)(dest >> 16);+ buffer[bufferPos + 2] = (byte)(dest >> 8);+ buffer[bufferPos + 1] = (byte)dest;+ bufferPos += 5;+ prevMask[0] = 0;+ } else {+ bufferPos++;+ prevMask[0] |= 1;+ if (Test86MSByte(b))+ prevMask[0] |= 0x10;+ }+ }+ return bufferPos;+ }++ public int SubFilter(byte [] data, int size) {+ return x86_Convert(data, size, _bufferPos, _prevMask, _prevPos, false);+ }++ public void SubInit() {+ x86Init();+ }++ int _bufferPos; // UInt32++ // ICompressFilter interface+ public int Init() {+ _bufferPos = 0;+ SubInit();+ return HRESULT.S_OK;+ }++ public int Filter(byte [] data, int size) {+ int processedSize = SubFilter(data, size);+ _bufferPos += processedSize;+ return processedSize;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/Copy/Decoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/Copy/Decoder.javanew file mode 100644index 000000000..3ffc2efa4--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/Copy/Decoder.java@@ -0,0 +1,36 @@++package SevenZip.Compression.Copy;++import SevenZip.ICompressCoder;+import SevenZip.ICompressProgressInfo;++public class Decoder implements ICompressCoder {++ static final int kBufferSize = 1 << 17;++ public void Code(+ java.io.InputStream inStream, // , ISequentialInStream+ java.io.OutputStream outStream, // ISequentialOutStream+ long outSize, ICompressProgressInfo progress) throws java.io.IOException {++ byte [] _buffer = new byte[kBufferSize];+ long TotalSize = 0;++ for (;;) {+ int realProcessedSize;+ int size = kBufferSize;++ if (outSize != -1) // NULL+ if (size > (outSize - TotalSize))+ size = (int)(outSize - TotalSize);++ realProcessedSize = inStream.read(_buffer, 0,size);+ if(realProcessedSize == -1) // EOF+ break;+ outStream.write(_buffer,0,realProcessedSize);+ TotalSize += realProcessedSize;+ if (progress != null)+ progress.SetRatioInfo(TotalSize, TotalSize);+ }+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/BinTree.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/BinTree.javanew file mode 100644index 000000000..0516ada61--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/BinTree.java@@ -0,0 +1,383 @@+// LZ.BinTree++package SevenZip.Compression.LZ;+import java.io.IOException;++++public class BinTree extends InWindow+{+ int _cyclicBufferPos;+ int _cyclicBufferSize = 0;+ int _matchMaxLen;++ int[] _son;+ int[] _hash;++ int _cutValue = 0xFF;+ int _hashMask;+ int _hashSizeSum = 0;++ boolean HASH_ARRAY = true;++ static final int kHash2Size = 1 << 10;+ static final int kHash3Size = 1 << 16;+ static final int kBT2HashSize = 1 << 16;+ static final int kStartMaxLen = 1;+ static final int kHash3Offset = kHash2Size;+ static final int kEmptyHashValue = 0;+ static final int kMaxValForNormalize = (1 << 30) - 1;++ int kNumHashDirectBytes = 0;+ int kMinMatchCheck = 4;+ int kFixHashSize = kHash2Size + kHash3Size;++ public void SetType(int numHashBytes)+ {+ HASH_ARRAY = (numHashBytes > 2);+ if (HASH_ARRAY)+ {+ kNumHashDirectBytes = 0;+ kMinMatchCheck = 4;+ kFixHashSize = kHash2Size + kHash3Size;+ }+ else+ {+ kNumHashDirectBytes = 2;+ kMinMatchCheck = 2 + 1;+ kFixHashSize = 0;+ }+ }+++++ public void Init() throws IOException+ {+ super.Init();+ for (int i = 0; i < _hashSizeSum; i++)+ _hash[i] = kEmptyHashValue;+ _cyclicBufferPos = 0;+ ReduceOffsets(-1);+ }++ public void MovePos() throws IOException+ {+ if (++_cyclicBufferPos >= _cyclicBufferSize)+ _cyclicBufferPos = 0;+ super.MovePos();+ if (_pos == kMaxValForNormalize)+ Normalize();+ }+++++++++ public boolean Create(int historySize, int keepAddBufferBefore,+ int matchMaxLen, int keepAddBufferAfter)+ {+ if (historySize > kMaxValForNormalize - 256)+ return false;+ _cutValue = 16 + (matchMaxLen >> 1);++ int windowReservSize = (historySize + keepAddBufferBefore ++ matchMaxLen + keepAddBufferAfter) / 2 + 256;++ super.Create(historySize + keepAddBufferBefore, matchMaxLen + keepAddBufferAfter, windowReservSize);++ _matchMaxLen = matchMaxLen;++ int cyclicBufferSize = historySize + 1;+ if (_cyclicBufferSize != cyclicBufferSize)+ _son = new int[(_cyclicBufferSize = cyclicBufferSize) * 2];++ int hs = kBT2HashSize;++ if (HASH_ARRAY)+ {+ hs = historySize - 1;+ hs |= (hs >> 1);+ hs |= (hs >> 2);+ hs |= (hs >> 4);+ hs |= (hs >> 8);+ hs >>= 1;+ hs |= 0xFFFF;+ if (hs > (1 << 24))+ hs >>= 1;+ _hashMask = hs;+ hs++;+ hs += kFixHashSize;+ }+ if (hs != _hashSizeSum)+ _hash = new int [_hashSizeSum = hs];+ return true;+ }+ public int GetMatches(int[] distances) throws IOException+ {+ int lenLimit;+ if (_pos + _matchMaxLen <= _streamPos)+ lenLimit = _matchMaxLen;+ else+ {+ lenLimit = _streamPos - _pos;+ if (lenLimit < kMinMatchCheck)+ {+ MovePos();+ return 0;+ }+ }++ int offset = 0;+ int matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;+ int cur = _bufferOffset + _pos;+ int maxLen = kStartMaxLen; // to avoid items for len < hashSize;+ int hashValue, hash2Value = 0, hash3Value = 0;++ if (HASH_ARRAY)+ {+ int temp = CrcTable[_bufferBase[cur] & 0xFF] ^ (_bufferBase[cur + 1] & 0xFF);+ hash2Value = temp & (kHash2Size - 1);+ temp ^= ((int)(_bufferBase[cur + 2] & 0xFF) << 8);+ hash3Value = temp & (kHash3Size - 1);+ hashValue = (temp ^ (CrcTable[_bufferBase[cur + 3] & 0xFF] << 5)) & _hashMask;+ }+ else+ hashValue = ((_bufferBase[cur] & 0xFF) ^ ((int)(_bufferBase[cur + 1] & 0xFF) << 8));++ int curMatch = _hash[kFixHashSize + hashValue];+ if (HASH_ARRAY)+ {+ int curMatch2 = _hash[hash2Value];+ int curMatch3 = _hash[kHash3Offset + hash3Value];+ _hash[hash2Value] = _pos;+ _hash[kHash3Offset + hash3Value] = _pos;+ if (curMatch2 > matchMinPos)+ if (_bufferBase[_bufferOffset + curMatch2] == _bufferBase[cur])+ {+ distances[offset++] = maxLen = 2;+ distances[offset++] = _pos - curMatch2 - 1;+ }+ if (curMatch3 > matchMinPos)+ if (_bufferBase[_bufferOffset + curMatch3] == _bufferBase[cur])+ {+ if (curMatch3 == curMatch2)+ offset -= 2;+ distances[offset++] = maxLen = 3;+ distances[offset++] = _pos - curMatch3 - 1;+ curMatch2 = curMatch3;+ }+ if (offset != 0 && curMatch2 == curMatch)+ {+ offset -= 2;+ maxLen = kStartMaxLen;+ }+ }++ _hash[kFixHashSize + hashValue] = _pos;++ int ptr0 = (_cyclicBufferPos << 1) + 1;+ int ptr1 = (_cyclicBufferPos << 1);++ int len0, len1;+ len0 = len1 = kNumHashDirectBytes;++ if (kNumHashDirectBytes != 0)+ {+ if (curMatch > matchMinPos)+ {+ if (_bufferBase[_bufferOffset + curMatch + kNumHashDirectBytes] !=+ _bufferBase[cur + kNumHashDirectBytes])+ {+ distances[offset++] = maxLen = kNumHashDirectBytes;+ distances[offset++] = _pos - curMatch - 1;+ }+ }+ }++ int count = _cutValue;++ while (true)+ {+ if (curMatch <= matchMinPos || count-- == 0)+ {+ _son[ptr0] = _son[ptr1] = kEmptyHashValue;+ break;+ }+ int delta = _pos - curMatch;+ int cyclicPos = ((delta <= _cyclicBufferPos) ?+ (_cyclicBufferPos - delta) :+ (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1;++ int pby1 = _bufferOffset + curMatch;+ int len = Math.min(len0, len1);+ if (_bufferBase[pby1 + len] == _bufferBase[cur + len])+ {+ while(++len != lenLimit)+ if (_bufferBase[pby1 + len] != _bufferBase[cur + len])+ break;+ if (maxLen < len)+ {+ distances[offset++] = maxLen = len;+ distances[offset++] = delta - 1;+ if (len == lenLimit)+ {+ _son[ptr1] = _son[cyclicPos];+ _son[ptr0] = _son[cyclicPos + 1];+ break;+ }+ }+ }+ if ((_bufferBase[pby1 + len] & 0xFF) < (_bufferBase[cur + len] & 0xFF))+ {+ _son[ptr1] = curMatch;+ ptr1 = cyclicPos + 1;+ curMatch = _son[ptr1];+ len1 = len;+ }+ else+ {+ _son[ptr0] = curMatch;+ ptr0 = cyclicPos;+ curMatch = _son[ptr0];+ len0 = len;+ }+ }+ MovePos();+ return offset;+ }++ public void Skip(int num) throws IOException+ {+ do+ {+ int lenLimit;+ if (_pos + _matchMaxLen <= _streamPos)+ lenLimit = _matchMaxLen;+ else+ {+ lenLimit = _streamPos - _pos;+ if (lenLimit < kMinMatchCheck)+ {+ MovePos();+ continue;+ }+ }++ int matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;+ int cur = _bufferOffset + _pos;++ int hashValue;++ if (HASH_ARRAY)+ {+ int temp = CrcTable[_bufferBase[cur] & 0xFF] ^ (_bufferBase[cur + 1] & 0xFF);+ int hash2Value = temp & (kHash2Size - 1);+ _hash[hash2Value] = _pos;+ temp ^= ((int)(_bufferBase[cur + 2] & 0xFF) << 8);+ int hash3Value = temp & (kHash3Size - 1);+ _hash[kHash3Offset + hash3Value] = _pos;+ hashValue = (temp ^ (CrcTable[_bufferBase[cur + 3] & 0xFF] << 5)) & _hashMask;+ }+ else+ hashValue = ((_bufferBase[cur] & 0xFF) ^ ((int)(_bufferBase[cur + 1] & 0xFF) << 8));++ int curMatch = _hash[kFixHashSize + hashValue];+ _hash[kFixHashSize + hashValue] = _pos;++ int ptr0 = (_cyclicBufferPos << 1) + 1;+ int ptr1 = (_cyclicBufferPos << 1);++ int len0, len1;+ len0 = len1 = kNumHashDirectBytes;++ int count = _cutValue;+ while (true)+ {+ if (curMatch <= matchMinPos || count-- == 0)+ {+ _son[ptr0] = _son[ptr1] = kEmptyHashValue;+ break;+ }++ int delta = _pos - curMatch;+ int cyclicPos = ((delta <= _cyclicBufferPos) ?+ (_cyclicBufferPos - delta) :+ (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1;++ int pby1 = _bufferOffset + curMatch;+ int len = Math.min(len0, len1);+ if (_bufferBase[pby1 + len] == _bufferBase[cur + len])+ {+ while (++len != lenLimit)+ if (_bufferBase[pby1 + len] != _bufferBase[cur + len])+ break;+ if (len == lenLimit)+ {+ _son[ptr1] = _son[cyclicPos];+ _son[ptr0] = _son[cyclicPos + 1];+ break;+ }+ }+ if ((_bufferBase[pby1 + len] & 0xFF) < (_bufferBase[cur + len] & 0xFF))+ {+ _son[ptr1] = curMatch;+ ptr1 = cyclicPos + 1;+ curMatch = _son[ptr1];+ len1 = len;+ }+ else+ {+ _son[ptr0] = curMatch;+ ptr0 = cyclicPos;+ curMatch = _son[ptr0];+ len0 = len;+ }+ }+ MovePos();+ }+ while (--num != 0);+ }++ void NormalizeLinks(int[] items, int numItems, int subValue)+ {+ for (int i = 0; i < numItems; i++)+ {+ int value = items[i];+ if (value <= subValue)+ value = kEmptyHashValue;+ else+ value -= subValue;+ items[i] = value;+ }+ }++ void Normalize()+ {+ int subValue = _pos - _cyclicBufferSize;+ NormalizeLinks(_son, _cyclicBufferSize * 2, subValue);+ NormalizeLinks(_hash, _hashSizeSum, subValue);+ ReduceOffsets(subValue);+ }++ public void SetCutValue(int cutValue) { _cutValue = cutValue; }++ private static final int[] CrcTable = new int[256];++ static+ {+ for (int i = 0; i < 256; i++)+ {+ int r = i;+ for (int j = 0; j < 8; j++)+ if ((r & 1) != 0)+ r = (r >>> 1) ^ 0xEDB88320;+ else+ r >>>= 1;+ CrcTable[i] = r;+ }+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/InWindow.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/InWindow.javanew file mode 100644index 000000000..5f3f0b4d0--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/InWindow.java@@ -0,0 +1,131 @@+// LZ.InWindow++package SevenZip.Compression.LZ;++import java.io.IOException;++public class InWindow+{+ public byte[] _bufferBase; // pointer to buffer with data+ java.io.InputStream _stream;+ int _posLimit; // offset (from _buffer) of first byte when new block reading must be done+ boolean _streamEndWasReached; // if (true) then _streamPos shows real end of stream++ int _pointerToLastSafePosition;++ public int _bufferOffset;++ public int _blockSize; // Size of Allocated memory block+ public int _pos; // offset (from _buffer) of curent byte+ int _keepSizeBefore; // how many BYTEs must be kept in buffer before _pos+ int _keepSizeAfter; // how many BYTEs must be kept buffer after _pos+ public int _streamPos; // offset (from _buffer) of first not read byte from Stream++ public void MoveBlock()+ {+ int offset = _bufferOffset + _pos - _keepSizeBefore;+ // we need one additional byte, since MovePos moves on 1 byte.+ if (offset > 0)+ offset--;++ int numBytes = _bufferOffset + _streamPos - offset;++ // check negative offset ????+ for (int i = 0; i < numBytes; i++)+ _bufferBase[i] = _bufferBase[offset + i];+ _bufferOffset -= offset;+ }++ public void ReadBlock() throws IOException+ {+ if (_streamEndWasReached)+ return;+ while (true)+ {+ int size = (0 - _bufferOffset) + _blockSize - _streamPos;+ if (size == 0)+ return;+ int numReadBytes = _stream.read(_bufferBase, _bufferOffset + _streamPos, size);+ if (numReadBytes == -1)+ {+ _posLimit = _streamPos;+ int pointerToPostion = _bufferOffset + _posLimit;+ if (pointerToPostion > _pointerToLastSafePosition)+ _posLimit = _pointerToLastSafePosition - _bufferOffset;++ _streamEndWasReached = true;+ return;+ }+ _streamPos += numReadBytes;+ if (_streamPos >= _pos + _keepSizeAfter)+ _posLimit = _streamPos - _keepSizeAfter;+ }+ }++ void Free() { _bufferBase = null; }++ public void Create(int keepSizeBefore, int keepSizeAfter, int keepSizeReserv)+ {+ _keepSizeBefore = keepSizeBefore;+ _keepSizeAfter = keepSizeAfter;+ int blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;+ if (_bufferBase == null || _blockSize != blockSize)+ {+ Free();+ _blockSize = blockSize;+ _bufferBase = new byte[_blockSize];+ }+ _pointerToLastSafePosition = _blockSize - keepSizeAfter;+ }++ public void SetStream(java.io.InputStream stream) { _stream = stream; }+ public void ReleaseStream() { _stream = null; }++ public void Init() throws IOException+ {+ _bufferOffset = 0;+ _pos = 0;+ _streamPos = 0;+ _streamEndWasReached = false;+ ReadBlock();+ }++ public void MovePos() throws IOException+ {+ _pos++;+ if (_pos > _posLimit)+ {+ int pointerToPostion = _bufferOffset + _pos;+ if (pointerToPostion > _pointerToLastSafePosition)+ MoveBlock();+ ReadBlock();+ }+ }++ public byte GetIndexByte(int index) { return _bufferBase[_bufferOffset + _pos + index]; }++ // index + limit have not to exceed _keepSizeAfter;+ public int GetMatchLen(int index, int distance, int limit)+ {+ if (_streamEndWasReached)+ if ((_pos + index) + limit > _streamPos)+ limit = _streamPos - (_pos + index);+ distance++;+ // Byte *pby = _buffer + (size_t)_pos + index;+ int pby = _bufferOffset + _pos + index;++ int i;+ for (i = 0; i < limit && _bufferBase[pby + i] == _bufferBase[pby + i - distance]; i++);+ return i;+ }++ public int GetNumAvailableBytes() { return _streamPos - _pos; }++ public void ReduceOffsets(int subValue)+ {+ _bufferOffset += subValue;+ _posLimit -= subValue;+ _pos -= subValue;+ _streamPos -= subValue;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/OutWindow.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/OutWindow.javanew file mode 100644index 000000000..327029c78--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZ/OutWindow.java@@ -0,0 +1,107 @@+// LZ.OutWindow++package SevenZip.Compression.LZ;++import java.io.IOException;++public class OutWindow {+ byte[] _buffer;+ byte[] _buffer2 = null;+ int _bufferPos2 = 0;+ int _pos;+ int _windowSize = 0;+ int _streamPos;+ java.io.OutputStream _stream;+ long _processedSize;++ public void Create(int windowSize) {+ final int kMinBlockSize = 1;+ if (windowSize < kMinBlockSize)+ windowSize = kMinBlockSize;++ if (_buffer == null || _windowSize != windowSize)+ _buffer = new byte[windowSize];+ _windowSize = windowSize;+ _pos = 0;+ _streamPos = 0;+ }++ public void SetStream(java.io.OutputStream stream) throws IOException {+ ReleaseStream();+ _stream = stream;+ }++ public void ReleaseStream() throws IOException {+ Flush();+ _stream = null;+ }++ public void SetMemStream(byte [] d) {+ _buffer2 = d;+ _bufferPos2 = 0;+ }++ public void Init() {+ Init(false);+ }+ public void Init(boolean solid) {+ _processedSize = 0;+ if (!solid) {+ _streamPos = 0;+ _pos = 0;+ }+ }++ public void Flush() throws IOException {+ int size = _pos - _streamPos;+ if (size == 0)+ return;+ if (_stream != null) _stream.write(_buffer, _streamPos, size);+ if (_buffer2 != null) {+ System.arraycopy(_buffer, _streamPos, _buffer2, _bufferPos2, size);+ _bufferPos2 += size;+ }+ if (_pos >= _windowSize)+ _pos = 0;+ _streamPos = _pos;+ }++ public void CopyBlock(int distance, int len) throws IOException {+ int pos = _pos - distance - 1;+ if (pos < 0)+ pos += _windowSize;+ for (; len != 0; len--) {+ if (pos >= _windowSize)+ pos = 0;+ _buffer[_pos++] = _buffer[pos++];+ _processedSize++;+ if (_pos >= _windowSize)+ Flush();+ }+ }++ public void PutByte(byte b) throws IOException {+ _buffer[_pos++] = b;+ _processedSize++;+ if (_pos >= _windowSize)+ Flush();+ }++ public void WriteByte(int b) throws IOException {+ _buffer[_pos++] = (byte)b;+ _processedSize++;+ if (_pos >= _windowSize)+ Flush();+ }++ public byte GetByte(int distance) {+ int pos = _pos - distance - 1;+ if (pos < 0)+ pos += _windowSize;+ return _buffer[pos];+ }++ public long GetProcessedSize() {+ return _processedSize;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Base.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Base.javanew file mode 100644index 000000000..18deed923--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Base.java@@ -0,0 +1,88 @@+// Base.java++package SevenZip.Compression.LZMA;++public class Base+{+ public static final int kNumRepDistances = 4;+ public static final int kNumStates = 12;++ public static final int StateInit()+ {+ return 0;+ }++ public static final int StateUpdateChar(int index)+ {+ if (index < 4)+ return 0;+ if (index < 10)+ return index - 3;+ return index - 6;+ }++ public static final int StateUpdateMatch(int index)+ {+ return (index < 7 ? 7 : 10);+ }++ public static final int StateUpdateRep(int index)+ {+ return (index < 7 ? 8 : 11);+ }++ public static final int StateUpdateShortRep(int index)+ {+ return (index < 7 ? 9 : 11);+ }++ public static final boolean StateIsCharState(int index)+ {+ return index < 7;+ }++ public static final int kNumPosSlotBits = 6;+ public static final int kDicLogSizeMin = 0;+ // public static final int kDicLogSizeMax = 28;+ // public static final int kDistTableSizeMax = kDicLogSizeMax * 2;++ public static final int kNumLenToPosStatesBits = 2; // it's for speed optimization+ public static final int kNumLenToPosStates = 1 << kNumLenToPosStatesBits;++ public static final int kMatchMinLen = 2;++ public static final int GetLenToPosState(int len)+ {+ len -= kMatchMinLen;+ if (len < kNumLenToPosStates)+ return len;+ return (int)(kNumLenToPosStates - 1);+ }++ public static final int kNumAlignBits = 4;+ public static final int kAlignTableSize = 1 << kNumAlignBits;+ public static final int kAlignMask = (kAlignTableSize - 1);++ public static final int kStartPosModelIndex = 4;+ public static final int kEndPosModelIndex = 14;+ public static final int kNumPosModels = kEndPosModelIndex - kStartPosModelIndex;++ public static final int kNumFullDistances = 1 << (kEndPosModelIndex / 2);++ public static final int kNumLitPosStatesBitsEncodingMax = 4;+ public static final int kNumLitContextBitsMax = 8;++ public static final int kNumPosStatesBitsMax = 4;+ public static final int kNumPosStatesMax = (1 << kNumPosStatesBitsMax);+ public static final int kNumPosStatesBitsEncodingMax = 4;+ public static final int kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax);++ public static final int kNumLowLenBits = 3;+ public static final int kNumMidLenBits = 3;+ public static final int kNumHighLenBits = 8;+ public static final int kNumLowLenSymbols = 1 << kNumLowLenBits;+ public static final int kNumMidLenSymbols = 1 << kNumMidLenBits;+ public static final int kNumLenSymbols = kNumLowLenSymbols + kNumMidLenSymbols ++ (1 << kNumHighLenBits);+ public static final int kMatchMaxLen = kMatchMinLen + kNumLenSymbols - 1;+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Decoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Decoder.javanew file mode 100644index 000000000..66f86bdf0--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Decoder.java@@ -0,0 +1,438 @@+package SevenZip.Compression.LZMA;++import SevenZip.ICompressCoder;+import SevenZip.ICompressGetInStreamProcessedSize;+import SevenZip.ICompressProgressInfo;+import SevenZip.ICompressSetInStream;+import SevenZip.ICompressSetOutStreamSize;++import java.io.IOException;+import java.io.InputStream;+import java.io.OutputStream;++import SevenZip.Compression.LZ.OutWindow;+import SevenZip.Compression.LZMA.Base;+import SevenZip.Compression.RangeCoder.BitTreeDecoder;++public class Decoder extends InputStream implements ICompressCoder, ICompressGetInStreamProcessedSize,+ ICompressSetInStream, ICompressSetOutStreamSize {++ private static final int kLenIdFinished = -1;+ private static final int kLenIdNeedInit = -2;++ private final SevenZip.Compression.RangeCoder.Decoder m_RangeDecoder = new SevenZip.Compression.RangeCoder.Decoder();+ private final OutWindow m_OutWindow = new OutWindow();++ private final short[] m_IsMatchDecoders = new short[Base.kNumStates << Base.kNumPosStatesBitsMax];+ private final short[] m_IsRepDecoders = new short[Base.kNumStates];+ private final short[] m_IsRepG0Decoders = new short[Base.kNumStates];+ private final short[] m_IsRepG1Decoders = new short[Base.kNumStates];+ private final short[] m_IsRepG2Decoders = new short[Base.kNumStates];+ private final short[] m_IsRep0LongDecoders = new short[Base.kNumStates << Base.kNumPosStatesBitsMax];+ private final short[] m_PosDecoders = new short[Base.kNumFullDistances - Base.kEndPosModelIndex];++ private final BitTreeDecoder[] m_PosSlotDecoder = new BitTreeDecoder[Base.kNumLenToPosStates];+ private final BitTreeDecoder m_PosAlignDecoder = new BitTreeDecoder(Base.kNumAlignBits);++ private final LenDecoder m_LenDecoder;+ private final LenDecoder m_RepLenDecoder;++ private final LiteralDecoder m_LiteralDecoder;++ private final int m_DictionarySize;+ private final int m_DictionarySizeCheck;++ private int m_posStateMask;++ private long _outSize = 0;+ private boolean _outSizeDefined = false;+ private int _remainLen; // -1 means end of stream. // -2 means need Init+ private int _rep0;+ private int _rep1;+ private int _rep2;+ private int _rep3;+ private int _state;++ public Decoder(byte[] properties) {+ for (int i = 0; i < Base.kNumLenToPosStates; i++)+ this.m_PosSlotDecoder[i] = new BitTreeDecoder(Base.kNumPosSlotBits);++ if (properties.length < 5)+ throw new IllegalArgumentException("properties.length < 5");+ int val = properties[0] & 0xFF;+ int lc = val % 9;+ int remainder = val / 9;+ int lp = remainder % 5;+ int pb = remainder / 5;+ int dictionarySize = 0;+ for (int i = 0; i < 4; i++)+ dictionarySize += ((int)(properties[1 + i]) & 0xFF) << (i * 8);++ // Set lc, lp, pb+ if (lc > Base.kNumLitContextBitsMax || lp > 4 || pb > Base.kNumPosStatesBitsMax)+ throw new IllegalArgumentException("lc > Base.kNumLitContextBitsMax || lp > 4 || pb > Base.kNumPosStatesBitsMax");+ if (this.m_LiteralDecoder != null) throw new NullPointerException("LiteralDecoder != null, WTF?!");+ this.m_LiteralDecoder = new LiteralDecoder(lp, lc);+ int numPosStates = 1 << pb;+ this.m_LenDecoder = new LenDecoder(numPosStates);+ this.m_RepLenDecoder = new LenDecoder(numPosStates);+ this.m_posStateMask = numPosStates - 1;++ // set dictionary size+ if (dictionarySize < 0)+ throw new IllegalArgumentException("dictionarySize must not be smaller than 0");+ this.m_DictionarySize = dictionarySize;+ this.m_DictionarySizeCheck = Math.max(this.m_DictionarySize, 1);+ this.m_OutWindow.Create(Math.max(this.m_DictionarySizeCheck, (1 << 12)));+ this.m_RangeDecoder.Create(1 << 20);+ }++ public long GetInStreamProcessedSize() {+ throw new UnknownError("GetInStreamProcessedSize");+ // return m_RangeDecoder.GetProcessedSize();+ }++ public void ReleaseInStream() throws IOException {+ this.m_RangeDecoder.ReleaseStream();+ }++ public void SetInStream(InputStream inStream) { // Common.ISequentialInStream+ this.m_RangeDecoder.SetStream(inStream);+ }++ public void SetOutStreamSize(long outSize /* const UInt64 *outSize*/ ) {+ this._outSizeDefined = (outSize != ICompressSetOutStreamSize.INVALID_OUTSIZE);+ if (this._outSizeDefined)+ this._outSize = outSize;+ this._remainLen = kLenIdNeedInit;+ this.m_OutWindow.Init();+ }++ // #ifdef _ST_MODE+ public int read() throws IOException {+ throw new IOException("LZMA Decoder - read() not implemented");+ }++ public int read(byte [] data, int off, int size) throws IOException {+ if (off != 0) throw new IOException("LZMA Decoder - read(byte [] data, int off != 0, int size)) not implemented");++ long startPos = this.m_OutWindow.GetProcessedSize();+ this.m_OutWindow.SetMemStream(data);+ CodeSpec(size);+ Flush();+ int ret = (int)(this.m_OutWindow.GetProcessedSize() - startPos);+ if (ret == 0) ret = -1;+ return ret;+ }++ // #endif // _ST_MODE++ private void Init() throws IOException {+ this.m_OutWindow.Init(false);++ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_IsMatchDecoders);+ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_IsRep0LongDecoders);+ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_IsRepDecoders);+ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_IsRepG0Decoders);+ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_IsRepG1Decoders);+ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_IsRepG2Decoders);+ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_PosDecoders);++ this._rep0 = this._rep1 = this._rep2 = this._rep3 = 0;+ this._state = Base.StateInit();++ // this.m_LiteralDecoder.Init();+ for (int i = 0; i < Base.kNumLenToPosStates; i++)+ this.m_PosSlotDecoder[i].Init();+ // this.m_LenDecoder.Init();+ // this.m_RepLenDecoder.Init();+ this.m_PosAlignDecoder.Init();+ }++ public void Flush() throws IOException {+ this.m_OutWindow.Flush();+ }++ private void ReleaseStreams() throws IOException {+ this.m_OutWindow.ReleaseStream();+ ReleaseInStream();+ }++ public void CodeReal(+ InputStream inStream, // , ISequentialInStream+ OutputStream outStream, // ISequentialOutStream+ long outSize,+ ICompressProgressInfo progress // useless_progress+ ) throws IOException {+ SetInStream(inStream);+ this.m_OutWindow.SetStream(outStream);+ SetOutStreamSize(outSize);++ do {+ int curSize = 1 << 18;+ CodeSpec(curSize);+ if (this._remainLen == kLenIdFinished)+ break;++ if (progress != null) {+ long inSize = this.m_RangeDecoder.GetProcessedSize();+ long nowPos64 = this.m_OutWindow.GetProcessedSize();+ progress.SetRatioInfo(inSize, nowPos64);+ }+ } while (!this._outSizeDefined || this.m_OutWindow.GetProcessedSize() < this._outSize);+ Flush();+ }++ public void Code(+ InputStream inStream, // , ISequentialInStream+ OutputStream outStream, // ISequentialOutStream+ long outSize,+ ICompressProgressInfo progress // useless_progress+ ) throws IOException {+ try {+ CodeReal(inStream,outStream,outSize,progress);+ } finally {+ Flush();+ ReleaseStreams();+ }+ }++ private void CodeSpec(int curSize) throws IOException {+ if (this._outSizeDefined) {+ long rem = this._outSize - this.m_OutWindow.GetProcessedSize();+ if (curSize > rem)+ curSize = (int)rem;+ }++ if (this._remainLen == kLenIdFinished)+ return;+ if (this._remainLen == kLenIdNeedInit) {+ this.m_RangeDecoder.Init();+ Init();+ this._remainLen = 0;+ }+ if (curSize == 0)+ return;++ int rep0 = this._rep0;+ int rep1 = this._rep1;+ int rep2 = this._rep2;+ int rep3 = this._rep3;+ int state = this._state;+ byte prevByte;++ while(this._remainLen > 0 && curSize > 0) {+ prevByte = this.m_OutWindow.GetByte(rep0);+ this.m_OutWindow.PutByte(prevByte);+ this._remainLen--;+ curSize--;+ }+ long nowPos64 = this.m_OutWindow.GetProcessedSize();+ if (nowPos64 == 0) {+ prevByte = 0;+ } else {+ prevByte = this.m_OutWindow.GetByte(0);+ }++ while(curSize > 0) {+ if (this.m_RangeDecoder.bufferedStream.WasFinished())+ throw new IOException("m_RangeDecoder.bufferedStream was finised");+ // return HRESULT.S_FALSE;+ int posState = (int)nowPos64 & this.m_posStateMask;++ if (this.m_RangeDecoder.DecodeBit(this.m_IsMatchDecoders, (state << Base.kNumPosStatesBitsMax) + posState) == 0) {+ LiteralDecoder.Decoder2 decoder2 = this.m_LiteralDecoder.GetDecoder((int)nowPos64, prevByte);+ if (!Base.StateIsCharState(state)) {+ prevByte = decoder2.DecodeWithMatchByte(this.m_RangeDecoder, this.m_OutWindow.GetByte(rep0));+ } else {+ prevByte = decoder2.DecodeNormal(this.m_RangeDecoder);+ }+ this.m_OutWindow.PutByte(prevByte);+ state = Base.StateUpdateChar(state);+ curSize--;+ nowPos64++;+ } else {+ int len;+ if (this.m_RangeDecoder.DecodeBit(this.m_IsRepDecoders, state) == 1) {+ len = 0;+ if (this.m_RangeDecoder.DecodeBit(this.m_IsRepG0Decoders, state) == 0) {+ if (this.m_RangeDecoder.DecodeBit(this.m_IsRep0LongDecoders, (state << Base.kNumPosStatesBitsMax) + posState) == 0) {+ state = Base.StateUpdateShortRep(state);+ len = 1;+ }+ } else {+ int distance;+ if (this.m_RangeDecoder.DecodeBit(this.m_IsRepG1Decoders, state) == 0) {+ distance = rep1;+ } else {+ if (this.m_RangeDecoder.DecodeBit(this.m_IsRepG2Decoders, state) == 0) {+ distance = rep2;+ } else {+ distance = rep3;+ rep3 = rep2;+ }+ rep2 = rep1;+ }+ rep1 = rep0;+ rep0 = distance;+ }+ if (len == 0) {+ len = this.m_RepLenDecoder.Decode(this.m_RangeDecoder, posState) + Base.kMatchMinLen;+ state = Base.StateUpdateRep(state);+ }+ } else {+ rep3 = rep2;+ rep2 = rep1;+ rep1 = rep0;+ len = Base.kMatchMinLen + this.m_LenDecoder.Decode(this.m_RangeDecoder, posState);+ state = Base.StateUpdateMatch(state);+ int posSlot = this.m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(this.m_RangeDecoder);+ if (posSlot >= Base.kStartPosModelIndex) {+ int numDirectBits = (posSlot >> 1) - 1;+ rep0 = ((2 | (posSlot & 1)) << numDirectBits);+ if (posSlot < Base.kEndPosModelIndex) {+ rep0 += BitTreeDecoder.ReverseDecode(+ this.m_PosDecoders,+ rep0 - posSlot - 1,+ this.m_RangeDecoder,+ numDirectBits);+ } else {+ rep0 += (this.m_RangeDecoder.DecodeDirectBits(numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits);+ rep0 += this.m_PosAlignDecoder.ReverseDecode(this.m_RangeDecoder);+ if (rep0 < 0) {+ if (rep0 == -1)+ break;+ throw new IOException("rep0 == -1");+ // return HRESULT.S_FALSE;+ }+ }+ } else {+ rep0 = posSlot;+ }+ }++ if (rep0 >= nowPos64 || rep0 >= this.m_DictionarySizeCheck) {+ // m_OutWindow.Flush();+ this._remainLen = kLenIdFinished;+ throw new IOException("rep0 >= nowPos64 || rep0 >= m_DictionarySizeCheck");+ // return HRESULT.S_FALSE;+ }+++ int locLen = len;+ if (len > curSize)+ locLen = curSize;+ // if (!m_OutWindow.CopyBlock(rep0, locLen))+ // return HRESULT.S_FALSE;+ this.m_OutWindow.CopyBlock(rep0, locLen);+ prevByte = this.m_OutWindow.GetByte(0);+ curSize -= locLen;+ nowPos64 += locLen;+ len -= locLen;+ if (len != 0) {+ this._remainLen = len;+ break;+ }+ }+ }++ if (this.m_RangeDecoder.bufferedStream.WasFinished())+ throw new IOException("m_RangeDecoder.bufferedStream was finised");++ this._rep0 = rep0;+ this._rep1 = rep1;+ this._rep2 = rep2;+ this._rep3 = rep3;+ this._state = state;+ }++ private class LenDecoder {++ private final short[] m_Choice = new short[2];+ private final BitTreeDecoder[] m_LowCoder = new BitTreeDecoder[Base.kNumPosStatesMax];+ private final BitTreeDecoder[] m_MidCoder = new BitTreeDecoder[Base.kNumPosStatesMax];+ private final BitTreeDecoder m_HighCoder = new BitTreeDecoder(Base.kNumHighLenBits);+ private int m_NumPosStates = 0;++ public LenDecoder(int numPosStates) {+ while (this.m_NumPosStates < numPosStates) {+ this.m_LowCoder[this.m_NumPosStates] = new BitTreeDecoder(Base.kNumLowLenBits);+ this.m_MidCoder[this.m_NumPosStates] = new BitTreeDecoder(Base.kNumMidLenBits);+ this.m_NumPosStates++;+ }+ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_Choice);+ for (int posState = 0; posState < this.m_NumPosStates; posState++) {+ this.m_LowCoder[posState].Init();+ this.m_MidCoder[posState].Init();+ }+ this.m_HighCoder.Init();+ }++ public int Decode(SevenZip.Compression.RangeCoder.Decoder rangeDecoder, int posState) throws IOException {+ if (rangeDecoder.DecodeBit(this.m_Choice, 0) == 0)+ return this.m_LowCoder[posState].Decode(rangeDecoder);+ int symbol = Base.kNumLowLenSymbols;+ if (rangeDecoder.DecodeBit(this.m_Choice, 1) == 0)+ symbol += this.m_MidCoder[posState].Decode(rangeDecoder);+ else+ symbol += Base.kNumMidLenSymbols + this.m_HighCoder.Decode(rangeDecoder);+ return symbol;+ }+ }++ private static class LiteralDecoder {++ private final Decoder2[] m_Coders;+ private final int m_NumPrevBits;+ private final int m_NumPosBits;+ private final int m_PosMask;++ public LiteralDecoder(int numPosBits, int numPrevBits) {+ this.m_NumPrevBits = numPrevBits;+ this.m_NumPosBits = numPosBits;+ this.m_PosMask = (1 << numPosBits) - 1;+ final int numStates = 1 << (this.m_NumPrevBits + this.m_NumPosBits);+ this.m_Coders = new Decoder2[numStates];+ for (int i = 0; i < numStates; i++)+ this.m_Coders[i] = new Decoder2();+ }++ private Decoder2 GetDecoder(int pos, byte prevByte) {+ final int indexHigh = (pos & this.m_PosMask) << this.m_NumPrevBits;+ final int indexLow = (prevByte & 0xFF) >>> (8 - this.m_NumPrevBits);+ return this.m_Coders[indexHigh + indexLow];+ }++ private static class Decoder2 {+ final short[] m_Decoders = new short[0x300];++ public Decoder2() {+ SevenZip.Compression.RangeCoder.Decoder.InitBitModels(this.m_Decoders);+ }++ public byte DecodeNormal(SevenZip.Compression.RangeCoder.Decoder rangeDecoder) throws IOException {+ int symbol = 1;+ do {+ symbol = (symbol << 1) | rangeDecoder.DecodeBit(this.m_Decoders, symbol);+ } while (symbol < 0x100);+ return (byte)symbol;+ }++ public byte DecodeWithMatchByte(SevenZip.Compression.RangeCoder.Decoder rangeDecoder, byte matchByte) throws IOException {+ int symbol = 1, matchBit, bit;+ do {+ matchBit = (matchByte >> 7) & 1;+ matchByte <<= 1;+ bit = rangeDecoder.DecodeBit(this.m_Decoders, ((1 + matchBit) << 8) + symbol);+ symbol = (symbol << 1) | bit;+ if (matchBit != bit) {+ while (symbol < 0x100)+ symbol = (symbol << 1) | rangeDecoder.DecodeBit(this.m_Decoders, symbol);+ break;+ }+ } while (symbol < 0x100);+ return (byte)symbol;+ }+ }+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Encoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Encoder.javanew file mode 100644index 000000000..61666acd7--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/LZMA/Encoder.java@@ -0,0 +1,1280 @@++package SevenZip.Compression.LZMA;++import java.io.IOException;+import java.io.InputStream;+import java.io.OutputStream;++import SevenZip.ICodeProgress;+import SevenZip.Compression.LZ.BinTree;+import SevenZip.Compression.LZMA.Base;+import SevenZip.Compression.RangeCoder.BitTreeEncoder;++public class Encoder {++ public static final int EMatchFinderTypeBT2 = 0;+ public static final int EMatchFinderTypeBT4 = 1;+ public static final int kNumLenSpecSymbols = Base.kNumLowLenSymbols + Base.kNumMidLenSymbols;+ public static final int kPropSize = 5;++ private static final int kIfinityPrice = 0xFFFFFFF;++ private static final int kDefaultDictionaryLogSize = 22;+ private static final int kNumFastBytesDefault = 0x20;++ private static byte[] g_FastPos = new byte[1 << 11];+ private static final int kNumOpts = 1 << 12;++ static {+ int kFastSlots = 22;+ int c = 2;+ g_FastPos[0] = 0;+ g_FastPos[1] = 1;+ for (int slotFast = 2; slotFast < kFastSlots; slotFast++) {+ int k = (1 << ((slotFast >> 1) - 1));+ for (int j = 0; j < k; j++, c++)+ g_FastPos[c] = (byte)slotFast;+ }+ }+++ static int GetPosSlot(int pos) {+ if (pos < (1 << 11)) return g_FastPos[pos];+ if (pos < (1 << 21)) return (g_FastPos[pos >> 10] + 20);+ return (g_FastPos[pos >> 20] + 40);+ }++ static int GetPosSlot2(int pos) {+ if (pos < (1 << 17)) return (g_FastPos[pos >> 6] + 12);+ if (pos < (1 << 27)) return (g_FastPos[pos >> 16] + 32);+ return (g_FastPos[pos >> 26] + 52);+ }++ private int _state = Base.StateInit();+ private byte _previousByte;+ private int[] _repDistances = new int[Base.kNumRepDistances];+ private Optimal[] _optimum = new Optimal[kNumOpts];+ private BinTree _matchFinder = null;+ private SevenZip.Compression.RangeCoder.Encoder _rangeEncoder = new SevenZip.Compression.RangeCoder.Encoder();+ private short[] _isMatch = new short[Base.kNumStates << Base.kNumPosStatesBitsMax];+ private short[] _isRep = new short[Base.kNumStates];+ private short[] _isRepG0 = new short[Base.kNumStates];+ private short[] _isRepG1 = new short[Base.kNumStates];+ private short[] _isRepG2 = new short[Base.kNumStates];+ private short[] _isRep0Long = new short[Base.kNumStates << Base.kNumPosStatesBitsMax];+ private BitTreeEncoder[] _posSlotEncoder = new BitTreeEncoder[Base.kNumLenToPosStates]; // kNumPosSlotBits+ private short[] _posEncoders = new short[Base.kNumFullDistances - Base.kEndPosModelIndex];+ private BitTreeEncoder _posAlignEncoder = new BitTreeEncoder(Base.kNumAlignBits);+ private LenPriceTableEncoder _lenEncoder = new LenPriceTableEncoder();+ private LenPriceTableEncoder _repMatchLenEncoder = new LenPriceTableEncoder();+ private LiteralEncoder _literalEncoder = new LiteralEncoder();+ private int[] _matchDistances = new int[Base.kMatchMaxLen * 2 + 2];+ private int _numFastBytes = kNumFastBytesDefault;+ private int _longestMatchLength;+ private int _numDistancePairs;+ private int _additionalOffset;+ private int _optimumEndIndex;+ private int _optimumCurrentIndex;+ private boolean _longestMatchWasFound;+ private int[] _posSlotPrices = new int[1 << (Base.kNumPosSlotBits + Base.kNumLenToPosStatesBits)];+ private int[] _distancesPrices = new int[Base.kNumFullDistances << Base.kNumLenToPosStatesBits];+ private int[] _alignPrices = new int[Base.kAlignTableSize];+ private int _alignPriceCount;+ private int _distTableSize = (kDefaultDictionaryLogSize * 2);+ private int _posStateBits = 2;+ private int _posStateMask = (4 - 1);+ private int _numLiteralPosStateBits = 0;+ private int _numLiteralContextBits = 3;+ private int _dictionarySize = (1 << kDefaultDictionaryLogSize);+ private int _dictionarySizePrev = -1;+ private int _numFastBytesPrev = -1;+ private long nowPos64;+ private boolean _finished;+ private InputStream _inStream;+ private int _matchFinderType = EMatchFinderTypeBT4;+ private boolean _writeEndMark = false;+ private boolean _needReleaseMFStream = false;+ private int[] reps = new int[Base.kNumRepDistances];+ private int[] repLens = new int[Base.kNumRepDistances];+ private int backRes;+ private long[] processedInSize = new long[1];+ private long[] processedOutSize = new long[1];+ private boolean[] finished = new boolean[1];+ private byte[] properties = new byte[kPropSize];+ private int[] tempPrices = new int[Base.kNumFullDistances];+ private int _matchPriceCount;++ public Encoder() {+ for (int i = 0; i < kNumOpts; i++)+ this._optimum[i] = new Optimal();+ for (int i = 0; i < Base.kNumLenToPosStates; i++)+ this._posSlotEncoder[i] = new BitTreeEncoder(Base.kNumPosSlotBits);+ }++ private int Backward(int cur) {+ this._optimumEndIndex = cur;+ int posMem = this._optimum[cur].PosPrev;+ int backMem = this._optimum[cur].BackPrev;+ do {+ if (this._optimum[cur].Prev1IsChar) {+ this._optimum[posMem].MakeAsChar();+ this._optimum[posMem].PosPrev = posMem - 1;+ if (this._optimum[cur].Prev2) {+ this._optimum[posMem - 1].Prev1IsChar = false;+ this._optimum[posMem - 1].PosPrev = this._optimum[cur].PosPrev2;+ this._optimum[posMem - 1].BackPrev = this._optimum[cur].BackPrev2;+ }+ }+ int posPrev = posMem;+ int backCur = backMem;++ backMem = this._optimum[posPrev].BackPrev;+ posMem = this._optimum[posPrev].PosPrev;++ this._optimum[posPrev].BackPrev = backCur;+ this._optimum[posPrev].PosPrev = cur;+ cur = posPrev;+ } while (cur > 0);+ this.backRes = this._optimum[0].BackPrev;+ this._optimumCurrentIndex = this._optimum[0].PosPrev;+ return this._optimumCurrentIndex;+ }+++ private void BaseInit() {+ this._state = Base.StateInit();+ this._previousByte = 0;+ for (int i = 0; i < Base.kNumRepDistances; i++)+ this._repDistances[i] = 0;+ }++ private boolean ChangePair(int smallDist, int bigDist) {+ int kDif = 7;+ return (smallDist < (1 << (32 - kDif)) && bigDist >= (smallDist << kDif));+ }++ public void Code(+ InputStream inStream,+ OutputStream outStream,+ long inSize,+ long outSize,+ ICodeProgress progress) throws IOException {+ this._needReleaseMFStream = false;+ try {+ SetStreams(inStream, outStream, inSize, outSize);+ while (true) {++ CodeOneBlock(this.processedInSize, this.processedOutSize,+ this.finished);+ if (this.finished[0]) return;+ if (progress != null) {+ progress.SetProgress(this.processedInSize[0],+ this.processedOutSize[0]);+ }+ }+ } finally {+ ReleaseStreams();+ }+ }+++ public void CodeOneBlock(long[] inSize, long[] outSize, boolean[] finished)+ throws IOException {+ inSize[0] = 0;+ outSize[0] = 0;+ finished[0] = true;++ if (this._inStream != null) {+ this._matchFinder.SetStream(this._inStream);+ this._matchFinder.Init();+ this._needReleaseMFStream = true;+ this._inStream = null;+ }++ if (this._finished) return;+ this._finished = true;++ long progressPosValuePrev = this.nowPos64;+ if (this.nowPos64 == 0) {+ if (this._matchFinder.GetNumAvailableBytes() == 0) {+ Flush((int)this.nowPos64);+ return;+ }++ ReadMatchDistances();+ int posState = (int)this.nowPos64 & this._posStateMask;+ this._rangeEncoder.Encode(this._isMatch, (this._state << Base.kNumPosStatesBitsMax) + posState, 0);+ this._state = Base.StateUpdateChar(this._state);+ byte curByte = this._matchFinder.GetIndexByte(0 - this._additionalOffset);+ this._literalEncoder.GetSubCoder((int)this.nowPos64, this._previousByte).Encode(this._rangeEncoder, curByte);+ this._previousByte = curByte;+ this._additionalOffset--;+ this.nowPos64++;+ }+ if (this._matchFinder.GetNumAvailableBytes() == 0) {+ Flush((int)this.nowPos64);+ return;+ }++ while (true) {+ int len = GetOptimum((int)this.nowPos64);+ int pos = this.backRes;+ int posState = ((int)this.nowPos64) & this._posStateMask;+ int complexState = (this._state << Base.kNumPosStatesBitsMax) + posState;+ if (len == 1 && pos == -1) {+ this._rangeEncoder.Encode(this._isMatch, complexState, 0);+ byte curByte = this._matchFinder.GetIndexByte((int)(0 - this._additionalOffset));+ LiteralEncoder.Encoder2 subCoder = this._literalEncoder.GetSubCoder((int)this.nowPos64, this._previousByte);+ if (!Base.StateIsCharState(this._state)) {+ byte matchByte = this._matchFinder.GetIndexByte(+ (int)(0 - this._repDistances[0] - 1 - this._additionalOffset));+ subCoder.EncodeMatched(this._rangeEncoder, matchByte, curByte);+ } else {+ subCoder.Encode(this._rangeEncoder, curByte);+ }+ this._previousByte = curByte;+ this._state = Base.StateUpdateChar(this._state);+ } else {+ this._rangeEncoder.Encode(this._isMatch, complexState, 1);+ if (pos < Base.kNumRepDistances) {+ this._rangeEncoder.Encode(this._isRep, this._state, 1);+ if (pos == 0) {+ this._rangeEncoder.Encode(this._isRepG0, this._state, 0);+ if (len == 1) {+ this._rangeEncoder.Encode(this._isRep0Long, complexState, 0);+ } else {+ this._rangeEncoder.Encode(this._isRep0Long, complexState, 1);+ }+ } else {+ this._rangeEncoder.Encode(this._isRepG0, this._state, 1);+ if (pos == 1) {+ this._rangeEncoder.Encode(this._isRepG1, this._state, 0);+ } else {+ this._rangeEncoder.Encode(this._isRepG1, this._state, 1);+ this._rangeEncoder.Encode(this._isRepG2, this._state, pos - 2);+ }+ }++ if (len == 1) {+ this._state = Base.StateUpdateShortRep(this._state);+ } else {+ this._repMatchLenEncoder.Encode(this._rangeEncoder, len - Base.kMatchMinLen, posState);+ this._state = Base.StateUpdateRep(this._state);+ }+ int distance = this._repDistances[pos];+ if (pos != 0) {+ for (int i = pos; i >= 1; i--)+ this._repDistances[i] = this._repDistances[i - 1];+ this._repDistances[0] = distance;+ }+ } else {+ this._rangeEncoder.Encode(this._isRep, this._state, 0);+ this._state = Base.StateUpdateMatch(this._state);+ this._lenEncoder.Encode(this._rangeEncoder, len - Base.kMatchMinLen, posState);+ pos -= Base.kNumRepDistances;+ int posSlot = GetPosSlot(pos);+ int lenToPosState = Base.GetLenToPosState(len);+ this._posSlotEncoder[lenToPosState].Encode(this._rangeEncoder, posSlot);++ if (posSlot >= Base.kStartPosModelIndex) {+ int footerBits = (int)((posSlot >> 1) - 1);+ int baseVal = ((2 | (posSlot & 1)) << footerBits);+ int posReduced = pos - baseVal;++ if (posSlot < Base.kEndPosModelIndex)+ BitTreeEncoder.ReverseEncode(+ this._posEncoders,+ baseVal - posSlot - 1,+ this._rangeEncoder,+ footerBits,+ posReduced);+ else {+ this._rangeEncoder.EncodeDirectBits(+ posReduced >> Base.kNumAlignBits,+ footerBits - Base.kNumAlignBits);+ this._posAlignEncoder.ReverseEncode(this._rangeEncoder, posReduced & Base.kAlignMask);+ this._alignPriceCount++;+ }+ }+ int distance = pos;+ for (int i = Base.kNumRepDistances - 1; i >= 1; i--)+ this._repDistances[i] = this._repDistances[i - 1];+ this._repDistances[0] = distance;+ this._matchPriceCount++;+ }+ this._previousByte = this._matchFinder.GetIndexByte(len - 1 - this._additionalOffset);+ }+ this._additionalOffset -= len;+ this.nowPos64 += len;+ if (this._additionalOffset == 0) {+ // if (!_fastMode)+ if (this._matchPriceCount >= (1 << 7))+ FillDistancesPrices();+ if (this._alignPriceCount >= Base.kAlignTableSize)+ FillAlignPrices();+ inSize[0] = this.nowPos64;+ outSize[0] = this._rangeEncoder.GetProcessedSizeAdd();+ if (this._matchFinder.GetNumAvailableBytes() == 0) {+ Flush((int)this.nowPos64);+ return;+ }++ if (this.nowPos64 - progressPosValuePrev >= (1 << 12)) {+ this._finished = false;+ finished[0] = false;+ return;+ }+ }+ } // end while+ }++ private void Create() {+ if (this._matchFinder == null) {+ BinTree bt = new BinTree();+ int numHashBytes = (this._matchFinderType == EMatchFinderTypeBT2) ? 2 : 4;+ bt.SetType(numHashBytes);+ this._matchFinder = bt;+ }+ this._literalEncoder.Create(this._numLiteralPosStateBits, this._numLiteralContextBits);++ if (this._dictionarySize == this._dictionarySizePrev && this._numFastBytesPrev == this._numFastBytes)+ return;+ this._matchFinder.Create(this._dictionarySize, kNumOpts, this._numFastBytes, Base.kMatchMaxLen + 1);+ this._dictionarySizePrev = this._dictionarySize;+ this._numFastBytesPrev = this._numFastBytes;+ }++ private void FillAlignPrices() {+ for (int i = 0; i < Base.kAlignTableSize; i++)+ this._alignPrices[i] = this._posAlignEncoder.ReverseGetPrice(i);+ this._alignPriceCount = 0;+ }++ private void FillDistancesPrices() {+ for (int i = Base.kStartPosModelIndex; i < Base.kNumFullDistances; i++) {+ int posSlot = GetPosSlot(i);+ int footerBits = (int)((posSlot >> 1) - 1);+ int baseVal = ((2 | (posSlot & 1)) << footerBits);+ this.tempPrices[i] = BitTreeEncoder.ReverseGetPrice(+ this._posEncoders,+ baseVal - posSlot - 1,+ footerBits,+ i - baseVal);+ }++ for (int lenToPosState = 0; lenToPosState < Base.kNumLenToPosStates; lenToPosState++) {+ int posSlot;+ BitTreeEncoder encoder = this._posSlotEncoder[lenToPosState];++ int st = (lenToPosState << Base.kNumPosSlotBits);+ for (posSlot = 0; posSlot < this._distTableSize; posSlot++)+ this._posSlotPrices[st + posSlot] = encoder.GetPrice(posSlot);+ for (posSlot = Base.kEndPosModelIndex; posSlot < this._distTableSize; posSlot++)+ this._posSlotPrices[st + posSlot] += (((posSlot >> 1) - 1) - Base.kNumAlignBits) << SevenZip.Compression.RangeCoder.Encoder.kNumBitPriceShiftBits;++ int st2 = lenToPosState * Base.kNumFullDistances;+ int i;+ for (i = 0; i < Base.kStartPosModelIndex; i++)+ this._distancesPrices[st2 + i] = this._posSlotPrices[st + i];+ for (; i < Base.kNumFullDistances; i++)+ this._distancesPrices[st2 + i] = this._posSlotPrices[st + GetPosSlot(i)] + this.tempPrices[i];+ }+ this._matchPriceCount = 0;+ }++ private void Flush(int nowPos) throws IOException {+ ReleaseMFStream();+ WriteEndMarker(nowPos & this._posStateMask);+ this._rangeEncoder.FlushData();+ this._rangeEncoder.FlushStream();+ }++ private int GetOptimum(int position) throws IOException {+ if (this._optimumEndIndex != this._optimumCurrentIndex) {+ int lenRes = this._optimum[this._optimumCurrentIndex].PosPrev - this._optimumCurrentIndex;+ this.backRes = this._optimum[this._optimumCurrentIndex].BackPrev;+ this._optimumCurrentIndex = this._optimum[this._optimumCurrentIndex].PosPrev;+ return lenRes;+ }+ this._optimumCurrentIndex = this._optimumEndIndex = 0;++ int lenMain, numDistancePairs;+ if (!this._longestMatchWasFound) {+ lenMain = ReadMatchDistances();+ } else {+ lenMain = this._longestMatchLength;+ this._longestMatchWasFound = false;+ }+ numDistancePairs = this._numDistancePairs;++ int numAvailableBytes = this._matchFinder.GetNumAvailableBytes() + 1;+ if (numAvailableBytes < 2) {+ this.backRes = -1;+ return 1;+ }+ if (numAvailableBytes > Base.kMatchMaxLen)+ numAvailableBytes = Base.kMatchMaxLen;++ int repMaxIndex = 0;+ int i;+ for (i = 0; i < Base.kNumRepDistances; i++) {+ this.reps[i] = this._repDistances[i];+ this.repLens[i] = this._matchFinder.GetMatchLen(+ 0 - 1,+ this.reps[i],+ Base.kMatchMaxLen);+ if (this.repLens[i] > this.repLens[repMaxIndex]) repMaxIndex = i;+ }+ if (this.repLens[repMaxIndex] >= this._numFastBytes) {+ this.backRes = repMaxIndex;+ int lenRes = this.repLens[repMaxIndex];+ MovePos(lenRes - 1);+ return lenRes;+ }++ if (lenMain >= this._numFastBytes) {+ this.backRes = this._matchDistances[numDistancePairs - 1] + Base.kNumRepDistances;+ MovePos(lenMain - 1);+ return lenMain;+ }++ byte currentByte = this._matchFinder.GetIndexByte(0 - 1);+ byte matchByte = this._matchFinder.GetIndexByte(0 - this._repDistances[0] - 1 - 1);++ if (lenMain < 2 && currentByte != matchByte && this.repLens[repMaxIndex] < 2) {+ this.backRes = -1;+ return 1;+ }++ this._optimum[0].State = this._state;++ int posState = (position & this._posStateMask);++ this._optimum[1].Price = SevenZip.Compression.RangeCoder.Encoder.GetPrice0(+ this._isMatch[(this._state << Base.kNumPosStatesBitsMax) + posState]) ++ this._literalEncoder.GetSubCoder(position, this._previousByte).GetPrice(+ !Base.StateIsCharState(this._state), matchByte,+ currentByte);+ this._optimum[1].MakeAsChar();++ int matchPrice = SevenZip.Compression.RangeCoder.Encoder.GetPrice1(+ this._isMatch[(this._state << Base.kNumPosStatesBitsMax) + posState]);+ int repMatchPrice = matchPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(this._isRep[this._state]);++ if (matchByte == currentByte) {+ int shortRepPrice = repMatchPrice + GetRepLen1Price(this._state, posState);+ if (shortRepPrice < this._optimum[1].Price) {+ this._optimum[1].Price = shortRepPrice;+ this._optimum[1].MakeAsShortRep();+ }+ }++ int lenEnd = ((lenMain >= this.repLens[repMaxIndex]) ? lenMain : this.repLens[repMaxIndex]);++ if (lenEnd < 2) {+ this.backRes = this._optimum[1].BackPrev;+ return 1;+ }++ this._optimum[1].PosPrev = 0;++ this._optimum[0].Backs0 = this.reps[0];+ this._optimum[0].Backs1 = this.reps[1];+ this._optimum[0].Backs2 = this.reps[2];+ this._optimum[0].Backs3 = this.reps[3];++ int len = lenEnd;+ do {+ this._optimum[len--].Price = kIfinityPrice;+ } while (len >= 2);++ for (i = 0; i < Base.kNumRepDistances; i++) {+ int repLen = this.repLens[i];+ if (repLen < 2) continue;+ int price = repMatchPrice + GetPureRepPrice(i, this._state, posState);+ do {+ int curAndLenPrice = price + this._repMatchLenEncoder.GetPrice(repLen - 2, posState);+ Optimal optimum = this._optimum[repLen];+ if (curAndLenPrice < optimum.Price) {+ optimum.Price = curAndLenPrice;+ optimum.PosPrev = 0;+ optimum.BackPrev = i;+ optimum.Prev1IsChar = false;+ }+ } while (--repLen >= 2);+ }++ int normalMatchPrice = matchPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice0(this._isRep[this._state]);+ len = ((this.repLens[0] >= 2) ? this.repLens[0] + 1 : 2);+ if (len <= lenMain) {+ int offs = 0;+ while (len > this._matchDistances[offs])+ offs += 2;++ for (;; len++) {+ int distance = this._matchDistances[offs + 1];+ int curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState);+ Optimal optimum = this._optimum[len];+ if (curAndLenPrice < optimum.Price) {+ optimum.Price = curAndLenPrice;+ optimum.PosPrev = 0;+ optimum.BackPrev = distance + Base.kNumRepDistances;+ optimum.Prev1IsChar = false;+ }+ if (len == this._matchDistances[offs]) {+ offs += 2;+ if (offs == numDistancePairs) break;+ }+ }+ }++ int cur = 0;+ while (true) {+ cur++;+ if (cur == lenEnd) return Backward(cur);+ int newLen = ReadMatchDistances();+ numDistancePairs = this._numDistancePairs;+ if (newLen >= this._numFastBytes) {+ this._longestMatchLength = newLen;+ this._longestMatchWasFound = true;+ return Backward(cur);+ }++ position++;+ int posPrev = this._optimum[cur].PosPrev;+ int state;+ if (this._optimum[cur].Prev1IsChar) {+ posPrev--;+ if (this._optimum[cur].Prev2) {+ state = this._optimum[this._optimum[cur].PosPrev2].State;+ if (this._optimum[cur].BackPrev2 < Base.kNumRepDistances) {+ state = Base.StateUpdateRep(state);+ } else {+ state = Base.StateUpdateMatch(state);+ }+ } else {+ state = this._optimum[posPrev].State;+ }+ state = Base.StateUpdateChar(state);+ } else {+ state = this._optimum[posPrev].State;+ }++ if (posPrev == cur - 1) {+ if (this._optimum[cur].IsShortRep()) {+ state = Base.StateUpdateShortRep(state);+ } else {+ state = Base.StateUpdateChar(state);+ }+ } else {+ int pos;+ if (this._optimum[cur].Prev1IsChar && this._optimum[cur].Prev2) {+ posPrev = this._optimum[cur].PosPrev2;+ pos = this._optimum[cur].BackPrev2;+ state = Base.StateUpdateRep(state);+ } else if ((pos = this._optimum[cur].BackPrev) < Base.kNumRepDistances) {+ state = Base.StateUpdateRep(state);+ } else {+ state = Base.StateUpdateMatch(state);+ }+ Optimal opt = this._optimum[posPrev];+ if (pos < Base.kNumRepDistances) {+ if (pos == 0) {+ this.reps[0] = opt.Backs0;+ this.reps[1] = opt.Backs1;+ this.reps[2] = opt.Backs2;+ this.reps[3] = opt.Backs3;+ } else if (pos == 1) {+ this.reps[0] = opt.Backs1;+ this.reps[1] = opt.Backs0;+ this.reps[2] = opt.Backs2;+ this.reps[3] = opt.Backs3;+ } else if (pos == 2) {+ this.reps[0] = opt.Backs2;+ this.reps[1] = opt.Backs0;+ this.reps[2] = opt.Backs1;+ this.reps[3] = opt.Backs3;+ } else {+ this.reps[0] = opt.Backs3;+ this.reps[1] = opt.Backs0;+ this.reps[2] = opt.Backs1;+ this.reps[3] = opt.Backs2;+ }+ } else {+ this.reps[0] = (pos - Base.kNumRepDistances);+ this.reps[1] = opt.Backs0;+ this.reps[2] = opt.Backs1;+ this.reps[3] = opt.Backs2;+ }+ }+ this._optimum[cur].State = state;+ this._optimum[cur].Backs0 = this.reps[0];+ this._optimum[cur].Backs1 = this.reps[1];+ this._optimum[cur].Backs2 = this.reps[2];+ this._optimum[cur].Backs3 = this.reps[3];+ int curPrice = this._optimum[cur].Price;++ currentByte = this._matchFinder.GetIndexByte(0 - 1);+ matchByte = this._matchFinder.GetIndexByte(0 - this.reps[0] - 1 - 1);++ posState = (position & this._posStateMask);++ int curAnd1Price = curPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice0(+ this._isMatch[(state << Base.kNumPosStatesBitsMax) + posState]) ++ this._literalEncoder.GetSubCoder(+ position,+ this._matchFinder.GetIndexByte(0 - 2)+ ).GetPrice(+ !Base.StateIsCharState(state), matchByte,+ currentByte);++ Optimal nextOptimum = this._optimum[cur + 1];++ boolean nextIsChar = false;+ if (curAnd1Price < nextOptimum.Price) {+ nextOptimum.Price = curAnd1Price;+ nextOptimum.PosPrev = cur;+ nextOptimum.MakeAsChar();+ nextIsChar = true;+ }++ matchPrice = curPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(+ this._isMatch[(state << Base.kNumPosStatesBitsMax) + posState]);+ repMatchPrice = matchPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(this._isRep[state]);++ if (matchByte == currentByte && !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0)) {+ int shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState);+ if (shortRepPrice <= nextOptimum.Price) {+ nextOptimum.Price = shortRepPrice;+ nextOptimum.PosPrev = cur;+ nextOptimum.MakeAsShortRep();+ nextIsChar = true;+ }+ }++ int numAvailableBytesFull = this._matchFinder.GetNumAvailableBytes() + 1;+ numAvailableBytesFull = Math.min(kNumOpts - 1 - cur, numAvailableBytesFull);+ numAvailableBytes = numAvailableBytesFull;++ if (numAvailableBytes < 2) continue;+ if (numAvailableBytes > this._numFastBytes)+ numAvailableBytes = this._numFastBytes;+ if (!nextIsChar && matchByte != currentByte) {+ // try Literal + rep0+ int t = Math.min(numAvailableBytesFull - 1, this._numFastBytes);+ int lenTest2 = this._matchFinder.GetMatchLen(0, this.reps[0], t);+ if (lenTest2 >= 2) {+ int state2 = Base.StateUpdateChar(state);++ int posStateNext = (position + 1) & this._posStateMask;+ int nextRepMatchPrice = curAnd1Price ++ SevenZip.Compression.RangeCoder.Encoder.GetPrice1(+ this._isMatch[(state2 << Base.kNumPosStatesBitsMax) + posStateNext]+ ) + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(this._isRep[state2]);+ {+ int offset = cur + 1 + lenTest2;+ while (lenEnd < offset)+ this._optimum[++lenEnd].Price = kIfinityPrice;++ int curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext);+ Optimal optimum = this._optimum[offset];+ if (curAndLenPrice < optimum.Price) {+ optimum.Price = curAndLenPrice;+ optimum.PosPrev = cur + 1;+ optimum.BackPrev = 0;+ optimum.Prev1IsChar = true;+ optimum.Prev2 = false;+ }+ }+ }+ }++ int startLen = 2; // speed optimization++ for (int repIndex = 0; repIndex < Base.kNumRepDistances; repIndex++) {+ int lenTest = this._matchFinder.GetMatchLen(0 - 1, this.reps[repIndex], numAvailableBytes);+ if (lenTest < 2) continue;+ int lenTestTemp = lenTest;+ do {+ while (lenEnd < cur + lenTest)+ this._optimum[++lenEnd].Price = kIfinityPrice;+ int curAndLenPrice = repMatchPrice+ + GetRepPrice(repIndex, lenTest, state, posState);+ Optimal optimum = this._optimum[cur + lenTest];+ if (curAndLenPrice < optimum.Price) {+ optimum.Price = curAndLenPrice;+ optimum.PosPrev = cur;+ optimum.BackPrev = repIndex;+ optimum.Prev1IsChar = false;+ }+ } while (--lenTest >= 2);+ lenTest = lenTestTemp;++ if (repIndex == 0) startLen = lenTest + 1;+++ // if (_maxMode)+ if (lenTest < numAvailableBytesFull) {+ int t = Math.min(numAvailableBytesFull - 1 - lenTest, this._numFastBytes);+ int lenTest2 = this._matchFinder.GetMatchLen(lenTest, this.reps[repIndex], t);+ if (lenTest2 >= 2) {+ int state2 = Base.StateUpdateRep(state);++ int posStateNext = (position + lenTest) & this._posStateMask;+ int curAndLenCharPrice = repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState) ++ SevenZip.Compression.RangeCoder.Encoder.GetPrice0(+ this._isMatch[(state2 << Base.kNumPosStatesBitsMax) + posStateNext]+ ) + this._literalEncoder.GetSubCoder(+ position + lenTest,+ this._matchFinder.GetIndexByte(lenTest - 1 - 1)+ ).GetPrice(+ true,+ this._matchFinder.GetIndexByte(lenTest - 1 - (this.reps[repIndex] + 1)),+ this._matchFinder.GetIndexByte(lenTest - 1));+ state2 = Base.StateUpdateChar(state2);+ posStateNext = (position + lenTest + 1) & this._posStateMask;+ int nextMatchPrice = curAndLenCharPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(+ this._isMatch[(state2 << Base.kNumPosStatesBitsMax) + posStateNext]);+ int nextRepMatchPrice = nextMatchPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(+ this._isRep[state2]);+++ // for(; lenTest2 >= 2; lenTest2--)+ {+ int offset = lenTest + 1 + lenTest2;+ while (lenEnd < cur + offset)+ this._optimum[++lenEnd].Price = kIfinityPrice;++ int curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext);+ Optimal optimum = this._optimum[cur + offset];+ if (curAndLenPrice < optimum.Price) {+ optimum.Price = curAndLenPrice;+ optimum.PosPrev = cur + lenTest + 1;+ optimum.BackPrev = 0;+ optimum.Prev1IsChar = true;+ optimum.Prev2 = true;+ optimum.PosPrev2 = cur;+ optimum.BackPrev2 = repIndex;+ }+ }+ }+ }+ }++ if (newLen > numAvailableBytes) {+ newLen = numAvailableBytes;+ for (numDistancePairs = 0; newLen > this._matchDistances[numDistancePairs]; numDistancePairs += 2);+ this._matchDistances[numDistancePairs] = newLen;+ numDistancePairs += 2;+ }++ if (newLen >= startLen) {+ normalMatchPrice = matchPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice0(this._isRep[state]);+ while (lenEnd < cur + newLen)+ this._optimum[++lenEnd].Price = kIfinityPrice;++ int offs = 0;+ while (startLen > this._matchDistances[offs])+ offs += 2;++ for (int lenTest = startLen;; lenTest++) {+ int curBack = this._matchDistances[offs + 1];+ int curAndLenPrice = normalMatchPrice + GetPosLenPrice(curBack, lenTest, posState);+ Optimal optimum = this._optimum[cur + lenTest];+ if (curAndLenPrice < optimum.Price) {+ optimum.Price = curAndLenPrice;+ optimum.PosPrev = cur;+ optimum.BackPrev = curBack + Base.kNumRepDistances;+ optimum.Prev1IsChar = false;+ }++ if (lenTest == this._matchDistances[offs]) {+ if (lenTest < numAvailableBytesFull) {+ int t = Math.min(numAvailableBytesFull - 1 - lenTest, this._numFastBytes);+ int lenTest2 = this._matchFinder.GetMatchLen(lenTest, curBack, t);+ if (lenTest2 >= 2) {+ int state2 = Base.StateUpdateMatch(state);++ int posStateNext = (position + lenTest) & this._posStateMask;+ int curAndLenCharPrice = curAndLenPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice0(+ this._isMatch[(state2 << Base.kNumPosStatesBitsMax) + posStateNext]) ++ this._literalEncoder.GetSubCoder(+ position + lenTest,+ this._matchFinder.GetIndexByte(lenTest - 1 - 1)+ ).GetPrice(+ true,+ this._matchFinder.GetIndexByte(lenTest - (curBack + 1) - 1),+ this._matchFinder.GetIndexByte(lenTest - 1));+ state2 = Base.StateUpdateChar(state2);+ posStateNext = (position + lenTest + 1) & this._posStateMask;+ int nextMatchPrice = curAndLenCharPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(+ this._isMatch[(state2 << Base.kNumPosStatesBitsMax) + posStateNext]);+ int nextRepMatchPrice = nextMatchPrice + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(+ this._isRep[state2]);++ int offset = lenTest + 1 + lenTest2;+ while (lenEnd < cur + offset)+ this._optimum[++lenEnd].Price = kIfinityPrice;++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext);+ optimum = this._optimum[cur + offset];+ if (curAndLenPrice < optimum.Price) {+ optimum.Price = curAndLenPrice;+ optimum.PosPrev = cur + lenTest + 1;+ optimum.BackPrev = 0;+ optimum.Prev1IsChar = true;+ optimum.Prev2 = true;+ optimum.PosPrev2 = cur;+ optimum.BackPrev2 = curBack + Base.kNumRepDistances;+ }+ }+ }+ offs += 2;+ if (offs == numDistancePairs) break;+ } // end if+ } // end for+ } // end if+ } // end while+ }++ private int GetPosLenPrice(int pos, int len, int posState) {+ int price;+ int lenToPosState = Base.GetLenToPosState(len);+ if (pos < Base.kNumFullDistances) {+ price = this._distancesPrices[(lenToPosState * Base.kNumFullDistances) + pos];+ } else {+ price = this._posSlotPrices[(lenToPosState << Base.kNumPosSlotBits) + GetPosSlot2(pos)] ++ this._alignPrices[pos & Base.kAlignMask];+ }+ return price + this._lenEncoder.GetPrice(len - Base.kMatchMinLen, posState);+ }++ private int GetPureRepPrice(int repIndex, int state, int posState) {+ int price;+ if (repIndex == 0) {+ price = SevenZip.Compression.RangeCoder.Encoder.GetPrice0(this._isRepG0[state]);+ price += SevenZip.Compression.RangeCoder.Encoder.GetPrice1(+ this._isRep0Long[(state << Base.kNumPosStatesBitsMax) + posState]);+ } else {+ price = SevenZip.Compression.RangeCoder.Encoder.GetPrice1(this._isRepG0[state]);+ if (repIndex == 1) {+ price += SevenZip.Compression.RangeCoder.Encoder.GetPrice0(this._isRepG1[state]);+ } else {+ price += SevenZip.Compression.RangeCoder.Encoder.GetPrice1(this._isRepG1[state]);+ price += SevenZip.Compression.RangeCoder.Encoder.GetPrice(this._isRepG2[state], repIndex - 2);+ }+ }+ return price;+ }++ private int GetRepLen1Price(int state, int posState) {+ final int r1 = SevenZip.Compression.RangeCoder.Encoder.GetPrice0(this._isRepG0[state]);+ final int r2 = SevenZip.Compression.RangeCoder.Encoder.GetPrice0(+ this._isRep0Long[(state << Base.kNumPosStatesBitsMax) + posState]);+ return r1 + r2;+ }++ private int GetRepPrice(int repIndex, int len, int state, int posState) {+ final int price = this._repMatchLenEncoder.GetPrice(len - Base.kMatchMinLen, posState);+ return price + GetPureRepPrice(repIndex, state, posState);+ }++ private void Init() {+ BaseInit();+ this._rangeEncoder.Init();++ SevenZip.Compression.RangeCoder.Encoder.InitBitModels(this._isMatch);+ SevenZip.Compression.RangeCoder.Encoder.InitBitModels(this._isRep0Long);+ SevenZip.Compression.RangeCoder.Encoder.InitBitModels(this._isRep);+ SevenZip.Compression.RangeCoder.Encoder.InitBitModels(this._isRepG0);+ SevenZip.Compression.RangeCoder.Encoder.InitBitModels(this._isRepG1);+ SevenZip.Compression.RangeCoder.Encoder.InitBitModels(this._isRepG2);+ SevenZip.Compression.RangeCoder.Encoder.InitBitModels(this._posEncoders);++ this._literalEncoder.Init();+ for (int i = 0; i < Base.kNumLenToPosStates; i++)+ this._posSlotEncoder[i].Init();++ this._lenEncoder.Init(1 << this._posStateBits);+ this._repMatchLenEncoder.Init(1 << this._posStateBits);++ this._posAlignEncoder.Init();++ this._longestMatchWasFound = false;+ this._optimumEndIndex = 0;+ this._optimumCurrentIndex = 0;+ this._additionalOffset = 0;+ }++ private void MovePos(int num) throws IOException {+ if (num > 0) {+ this._matchFinder.Skip(num);+ this._additionalOffset += num;+ }+ }++ private int ReadMatchDistances() throws IOException {+ int lenRes = 0;+ this._numDistancePairs = this._matchFinder.GetMatches(this._matchDistances);+ if (this._numDistancePairs > 0) {+ lenRes = this._matchDistances[this._numDistancePairs - 2];+ if (lenRes == this._numFastBytes)+ lenRes += this._matchFinder.GetMatchLen(+ (int)lenRes - 1,+ this._matchDistances[this._numDistancePairs - 1],+ Base.kMatchMaxLen - lenRes);+ }+ this._additionalOffset++;+ return lenRes;+ }++ private void ReleaseMFStream() {+ if (this._matchFinder != null && this._needReleaseMFStream) {+ this._matchFinder.ReleaseStream();+ this._needReleaseMFStream = false;+ }+ }++ private void ReleaseOutStream() {+ this._rangeEncoder.ReleaseStream();+ }++ private void ReleaseStreams() {+ ReleaseMFStream();+ ReleaseOutStream();+ }++ public boolean SetNumFastBytes(int numFastBytes) {+ if (numFastBytes < 5 || numFastBytes > Base.kMatchMaxLen) return false;+ this._numFastBytes = numFastBytes;+ return true;+ }++ public boolean SetAlgorithm(int algorithm) {+ /*+ * _fastMode = (algorithm == 0); _maxMode = (algorithm >= 2);+ */+ return true;+ }++ public boolean SetDictionarySize(int dictionarySize) {+ int kDicLogSizeMaxCompress = 29;+ if (dictionarySize < (1 << Base.kDicLogSizeMin) || dictionarySize > (1 << kDicLogSizeMaxCompress))+ return false;+ this._dictionarySize = dictionarySize;+ int dicLogSize;+ for (dicLogSize = 0; dictionarySize > (1 << dicLogSize); dicLogSize++);+ this._distTableSize = dicLogSize * 2;+ return true;+ }++ public void SetEndMarkerMode(boolean endMarkerMode) {+ this._writeEndMark = endMarkerMode;+ }++ public boolean SetLcLpPb(int lc, int lp, int pb) {+ if (+ lp < 0 || lp > Base.kNumLitPosStatesBitsEncodingMax ||+ lc < 0 || lc > Base.kNumLitContextBitsMax ||+ pb < 0 || pb > Base.kNumPosStatesBitsEncodingMax+ ) return false;+ this._numLiteralPosStateBits = lp;+ this._numLiteralContextBits = lc;+ this._posStateBits = pb;+ this._posStateMask = (1 << this._posStateBits) - 1;+ return true;+ }++ public boolean SetMatchFinder(int matchFinderIndex) {+ if (matchFinderIndex < 0 || matchFinderIndex > 2) return false;+ int matchFinderIndexPrev = this._matchFinderType;+ this._matchFinderType = matchFinderIndex;+ if (this._matchFinder != null && matchFinderIndexPrev != this._matchFinderType) {+ this._dictionarySizePrev = -1;+ this._matchFinder = null;+ }+ return true;+ }++ private void SetOutStream(OutputStream outStream) {+ this._rangeEncoder.SetStream(outStream);+ }++ private void SetStreams(InputStream inStream, OutputStream outStream, long inSize, long outSize) {+ this._inStream = inStream;+ this._finished = false;+ Create();+ SetOutStream(outStream);+ Init();+ /* if (!_fastMode) */ {+ FillDistancesPrices();+ FillAlignPrices();+ }++ this._lenEncoder.SetTableSize(this._numFastBytes + 1 - Base.kMatchMinLen);+ this._lenEncoder.UpdateTables(1 << this._posStateBits);+ this._repMatchLenEncoder.SetTableSize(this._numFastBytes + 1 - Base.kMatchMinLen);+ this._repMatchLenEncoder.UpdateTables(1 << this._posStateBits);++ this.nowPos64 = 0;+ }++ private void SetWriteEndMarkerMode(boolean writeEndMarker) {+ this._writeEndMark = writeEndMarker;+ }++ public void WriteCoderProperties(java.io.OutputStream outStream)+ throws IOException {+ this.properties[0] = (byte)((this._posStateBits * 5 + this._numLiteralPosStateBits) * 9 + this._numLiteralContextBits);+ for (int i = 0; i < 4; i++)+ this.properties[1 + i] = (byte)(this._dictionarySize >> (8 * i));+ outStream.write(this.properties, 0, kPropSize);+ }++ private void WriteEndMarker(int posState) throws IOException {+ if (!this._writeEndMark)+ return;++ this._rangeEncoder.Encode(+ this._isMatch,+ (this._state << Base.kNumPosStatesBitsMax) + posState,+ 1);+ this._rangeEncoder.Encode(this._isRep, this._state, 0);+ this._state = Base.StateUpdateMatch(this._state);+ int len = Base.kMatchMinLen;+ this._lenEncoder.Encode(this._rangeEncoder, len - Base.kMatchMinLen, posState);+ int posSlot = (1 << Base.kNumPosSlotBits) - 1;+ int lenToPosState = Base.GetLenToPosState(len);+ this._posSlotEncoder[lenToPosState].Encode(this._rangeEncoder, posSlot);+ int footerBits = 30;+ int posReduced = (1 << footerBits) - 1;+ this._rangeEncoder.EncodeDirectBits(+ posReduced >> Base.kNumAlignBits,+ footerBits - Base.kNumAlignBits);+ this._posAlignEncoder.ReverseEncode(this._rangeEncoder, posReduced & Base.kAlignMask);+ }++ class LenEncoder {++ private short[] _choice = new short[2];+ private BitTreeEncoder[] _lowCoder = new BitTreeEncoder[Base.kNumPosStatesEncodingMax];+ private BitTreeEncoder[] _midCoder = new BitTreeEncoder[Base.kNumPosStatesEncodingMax];+ private BitTreeEncoder _highCoder = new BitTreeEncoder(Base.kNumHighLenBits);++ public LenEncoder() {+ for (int posState = 0; posState < Base.kNumPosStatesEncodingMax; posState++) {+ this._lowCoder[posState] = new BitTreeEncoder(Base.kNumLowLenBits);+ this._midCoder[posState] = new BitTreeEncoder(Base.kNumMidLenBits);+ }+ }++ public void Encode(+ SevenZip.Compression.RangeCoder.Encoder rangeEncoder,+ int symbol,+ int posState) throws IOException {+ if (symbol < Base.kNumLowLenSymbols) {+ rangeEncoder.Encode(this._choice, 0, 0);+ this._lowCoder[posState].Encode(rangeEncoder, symbol);+ } else {+ symbol -= Base.kNumLowLenSymbols;+ rangeEncoder.Encode(this._choice, 0, 1);+ if (symbol < Base.kNumMidLenSymbols) {+ rangeEncoder.Encode(this._choice, 1, 0);+ this._midCoder[posState].Encode(rangeEncoder, symbol);+ } else {+ rangeEncoder.Encode(this._choice, 1, 1);+ this._highCoder.Encode(rangeEncoder, symbol - Base.kNumMidLenSymbols);+ }+ }+ }++ public void Init(int numPosStates) {+ SevenZip.Compression.RangeCoder.Encoder.InitBitModels(this._choice);+ for (int posState = 0; posState < numPosStates; posState++) {+ this._lowCoder[posState].Init();+ this._midCoder[posState].Init();+ }+ this._highCoder.Init();+ }++ public void SetPrices(int posState, int numSymbols, int[] prices, int st) {+ int a0 = SevenZip.Compression.RangeCoder.Encoder.GetPrice0(this._choice[0]);+ int a1 = SevenZip.Compression.RangeCoder.Encoder.GetPrice1(this._choice[0]);+ int b0 = a1 + SevenZip.Compression.RangeCoder.Encoder.GetPrice0(this._choice[1]);+ int b1 = a1 + SevenZip.Compression.RangeCoder.Encoder.GetPrice1(this._choice[1]);+ int i = 0;+ for (; i < Base.kNumLowLenSymbols; i++) {+ if (i >= numSymbols)+ return;+ prices[st + i] = a0 + this._lowCoder[posState].GetPrice(i);+ }+ for (; i < Base.kNumLowLenSymbols + Base.kNumMidLenSymbols; i++) {+ if (i >= numSymbols)+ return;+ prices[st + i] = b0 + this._midCoder[posState].GetPrice(i - Base.kNumLowLenSymbols);+ }+ for (; i < numSymbols; i++)+ prices[st + i] = b1 + this._highCoder.GetPrice(i - Base.kNumLowLenSymbols - Base.kNumMidLenSymbols);+ }+ }++ class LenPriceTableEncoder extends LenEncoder {++ private int[] _prices = new int[Base.kNumLenSymbols << Base.kNumPosStatesBitsEncodingMax];+ private int[] _counters = new int[Base.kNumPosStatesEncodingMax];+ private int _tableSize;++ public void Encode(+ SevenZip.Compression.RangeCoder.Encoder rangeEncoder,+ int symbol,+ int posState) throws IOException {+ super.Encode(rangeEncoder, symbol, posState);+ if (--this._counters[posState] == 0) UpdateTable(posState);+ }++ public int GetPrice(int symbol, int posState) {+ return this._prices[posState * Base.kNumLenSymbols + symbol];+ }++ public void SetTableSize(int tableSize) {+ this._tableSize = tableSize;+ }++ private void UpdateTable(int posState) {+ SetPrices(posState, this._tableSize, this._prices, posState * Base.kNumLenSymbols);+ this._counters[posState] = this._tableSize;+ }++ public void UpdateTables(int numPosStates) {+ for (int posState = 0; posState < numPosStates; posState++)+ UpdateTable(posState);+ }+ }++ private class LiteralEncoder {++ private Encoder2[] m_Coders;+ private int m_NumPrevBits;+ private int m_NumPosBits;+ private int m_PosMask;++ public void Create(int numPosBits, int numPrevBits) {+ if (this.m_Coders != null && this.m_NumPrevBits == numPrevBits && this.m_NumPosBits == numPosBits)+ return;+ this.m_NumPosBits = numPosBits;+ this.m_PosMask = (1 << numPosBits) - 1;+ this.m_NumPrevBits = numPrevBits;+ int numStates = 1 << (this.m_NumPrevBits + this.m_NumPosBits);+ this.m_Coders = new Encoder2[numStates];+ for (int i = 0; i < numStates; i++)+ this.m_Coders[i] = new Encoder2();+ }++ public Encoder2 GetSubCoder(int pos, byte prevByte) {+ final int index = ((pos & this.m_PosMask) << this.m_NumPrevBits) + ((prevByte & 0xFF) >>> (8 - this.m_NumPrevBits));+ return this.m_Coders[index];+ }++ public void Init() {+ int numStates = 1 << (this.m_NumPrevBits + this.m_NumPosBits);+ for (int i = 0; i < numStates; i++)+ this.m_Coders[i].Init();+ }++ private class Encoder2 {++ short[] m_Encoders = new short[0x300];++ public void Encode(+ SevenZip.Compression.RangeCoder.Encoder rangeEncoder,+ byte symbol) throws IOException {+ int context = 1;+ for (int i = 7; i >= 0; i--) {+ int bit = ((symbol >> i) & 1);+ rangeEncoder.Encode(this.m_Encoders, context, bit);+ context = (context << 1) | bit;+ }+ }++ public void EncodeMatched(+ SevenZip.Compression.RangeCoder.Encoder rangeEncoder,+ byte matchByte,+ byte symbol) throws IOException {+ int context = 1;+ boolean same = true;+ for (int i = 7; i >= 0; i--) {+ int bit = ((symbol >> i) & 1);+ int state = context;+ if (same) {+ int matchBit = ((matchByte >> i) & 1);+ state += ((1 + matchBit) << 8);+ same = (matchBit == bit);+ }+ rangeEncoder.Encode(this.m_Encoders, state, bit);+ context = (context << 1) | bit;+ }+ }++ public int GetPrice(boolean matchMode, byte matchByte, byte symbol) {+ int price = 0;+ int context = 1;+ int i = 7;+ if (matchMode) {+ for (; i >= 0; i--) {+ int matchBit = (matchByte >> i) & 1;+ int bit = (symbol >> i) & 1;+ price += SevenZip.Compression.RangeCoder.Encoder.GetPrice(+ this.m_Encoders[((1 + matchBit) << 8) + context],+ bit);+ context = (context << 1) | bit;+ if (matchBit != bit) {+ i--;+ break;+ }+ }+ }+ for (; i >= 0; i--) {+ int bit = (symbol >> i) & 1;+ price += SevenZip.Compression.RangeCoder.Encoder.GetPrice(this.m_Encoders[context], bit);+ context = (context << 1) | bit;+ }+ return price;+ }++ public void Init() {+ SevenZip.Compression.RangeCoder.Encoder+ .InitBitModels(this.m_Encoders);+ }+ }+ }++ private class Optimal {++ public int State;+ public boolean Prev1IsChar;+ public boolean Prev2;+ public int PosPrev2;+ public int BackPrev2;+ public int Price;+ public int PosPrev;+ public int BackPrev;+ public int Backs0;+ public int Backs1;+ public int Backs2;+ public int Backs3;++ public boolean IsShortRep() {+ return (this.BackPrev == 0);+ }++ public void MakeAsChar() {+ this.BackPrev = -1;+ this.Prev1IsChar = false;+ }++ public void MakeAsShortRep() {+ this.BackPrev = 0;;+ this.Prev1IsChar = false;+ }+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitDecoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitDecoder.javanew file mode 100644index 000000000..0e325301b--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitDecoder.java@@ -0,0 +1,38 @@+package SevenZip.Compression.RangeCoder;++import SevenZip.Compression.RangeCoder.Decoder;+++public class BitDecoder extends BitModel+{+ public BitDecoder(int num) {+ super(num);+ }+ public int Decode(Decoder decoder) throws java.io.IOException+ {+ int newBound = (decoder.Range >>> kNumBitModelTotalBits) * this.Prob;+ if ((decoder.Code ^ 0x80000000) < (newBound ^ 0x80000000))+ {+ decoder.Range = newBound;+ this.Prob += (kBitModelTotal - this.Prob) >>> numMoveBits;+ if ((decoder.Range & kTopMask) == 0)+ {+ decoder.Code = (decoder.Code << 8) | decoder.bufferedStream.read();+ decoder.Range <<= 8;+ }+ return 0;+ }+ else+ {+ decoder.Range -= newBound;+ decoder.Code -= newBound;+ this.Prob -= (this.Prob) >>> numMoveBits;+ if ((decoder.Range & kTopMask) == 0)+ {+ decoder.Code = (decoder.Code << 8) | decoder.bufferedStream.read();+ decoder.Range <<= 8;+ }+ return 1;+ }+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitModel.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitModel.javanew file mode 100644index 000000000..053ff1c5d--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitModel.java@@ -0,0 +1,29 @@+package SevenZip.Compression.RangeCoder;+++public class BitModel+{++ public static final int kTopMask = ~((1 << 24) - 1);+ public static final int kNumBitModelTotalBits = 11;+ public static final int kBitModelTotal = (1 << kNumBitModelTotalBits);++ int numMoveBits;++ int Prob;++ public BitModel(int num) {+ numMoveBits = num;+ }+ /*+ public void UpdateModel(UInt32 symbol)+ {+ if (symbol == 0)+ Prob += (kBitModelTotal - Prob) >> numMoveBits;+ else+ Prob -= (Prob) >> numMoveBits;+ }+ */+ public void Init() { Prob = kBitModelTotal / 2; }++}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitTreeDecoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitTreeDecoder.javanew file mode 100644index 000000000..0db672227--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitTreeDecoder.java@@ -0,0 +1,57 @@+package SevenZip.Compression.RangeCoder;++import SevenZip.Compression.RangeCoder.Decoder;++public class BitTreeDecoder+{+ short[] Models;+ int NumBitLevels;++ public BitTreeDecoder(int numBitLevels)+ {+ NumBitLevels = numBitLevels;+ Models = new short[1 << numBitLevels];+ }++ public void Init()+ {+ Decoder.InitBitModels(Models);+ }++ public int Decode(Decoder rangeDecoder) throws java.io.IOException+ {+ int m = 1;+ for (int bitIndex = NumBitLevels; bitIndex != 0; bitIndex--)+ m = (m << 1) + rangeDecoder.DecodeBit(Models, m);+ return m - (1 << NumBitLevels);+ }++ public int ReverseDecode(Decoder rangeDecoder) throws java.io.IOException+ {+ int m = 1;+ int symbol = 0;+ for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)+ {+ int bit = rangeDecoder.DecodeBit(Models, m);+ m <<= 1;+ m += bit;+ symbol |= (bit << bitIndex);+ }+ return symbol;+ }++ public static int ReverseDecode(short[] Models, int startIndex,+ Decoder rangeDecoder, int NumBitLevels) throws java.io.IOException+ {+ int m = 1;+ int symbol = 0;+ for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)+ {+ int bit = rangeDecoder.DecodeBit(Models, startIndex + m);+ m <<= 1;+ m += bit;+ symbol |= (bit << bitIndex);+ }+ return symbol;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitTreeEncoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitTreeEncoder.javanew file mode 100644index 000000000..067c8bf16--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/BitTreeEncoder.java@@ -0,0 +1,102 @@+package SevenZip.Compression.RangeCoder;+import java.io.IOException;++import SevenZip.Compression.RangeCoder.Decoder;+import SevenZip.Compression.RangeCoder.Encoder;++public class BitTreeEncoder+{+ short[] Models;+ int NumBitLevels;++ public BitTreeEncoder(int numBitLevels)+ {+ NumBitLevels = numBitLevels;+ Models = new short[1 << numBitLevels];+ }++ public void Init()+ {+ Decoder.InitBitModels(Models);+ }++ public void Encode(Encoder rangeEncoder, int symbol) throws IOException+ {+ int m = 1;+ for (int bitIndex = NumBitLevels; bitIndex != 0; )+ {+ bitIndex--;+ int bit = (symbol >>> bitIndex) & 1;+ rangeEncoder.Encode(Models, m, bit);+ m = (m << 1) | bit;+ }+ }++ public void ReverseEncode(Encoder rangeEncoder, int symbol) throws IOException+ {+ int m = 1;+ for (int i = 0; i < NumBitLevels; i++)+ {+ int bit = symbol & 1;+ rangeEncoder.Encode(Models, m, bit);+ m = (m << 1) | bit;+ symbol >>= 1;+ }+ }++ public int GetPrice(int symbol)+ {+ int price = 0;+ int m = 1;+ for (int bitIndex = NumBitLevels; bitIndex != 0; )+ {+ bitIndex--;+ int bit = (symbol >>> bitIndex) & 1;+ price += Encoder.GetPrice(Models[m], bit);+ m = (m << 1) + bit;+ }+ return price;+ }++ public int ReverseGetPrice(int symbol)+ {+ int price = 0;+ int m = 1;+ for (int i = NumBitLevels; i != 0; i--)+ {+ int bit = symbol & 1;+ symbol >>>= 1;+ price += Encoder.GetPrice(Models[m], bit);+ m = (m << 1) | bit;+ }+ return price;+ }++ public static int ReverseGetPrice(short[] Models, int startIndex,+ int NumBitLevels, int symbol)+ {+ int price = 0;+ int m = 1;+ for (int i = NumBitLevels; i != 0; i--)+ {+ int bit = symbol & 1;+ symbol >>>= 1;+ price += Encoder.GetPrice(Models[startIndex + m], bit);+ m = (m << 1) | bit;+ }+ return price;+ }++ public static void ReverseEncode(short[] Models, int startIndex,+ Encoder rangeEncoder, int NumBitLevels, int symbol) throws IOException+ {+ int m = 1;+ for (int i = 0; i < NumBitLevels; i++)+ {+ int bit = symbol & 1;+ rangeEncoder.Encode(Models, startIndex + m, bit);+ m = (m << 1) | bit;+ symbol >>= 1;+ }+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/Decoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/Decoder.javanew file mode 100644index 000000000..3cc0223a2--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/Decoder.java@@ -0,0 +1,101 @@+package SevenZip.Compression.RangeCoder;+import java.io.IOException;++public class Decoder+{+ static final int kTopMask = ~((1 << 24) - 1);++ static final int kNumBitModelTotalBits = 11;+ static final int kBitModelTotal = (1 << kNumBitModelTotalBits);+ static final int kNumMoveBits = 5;++ int Range;+ int Code;++ // boolean _wasFinished;+ // long _processedSize;++ // public boolean WasFinished() { return _wasFinished; }++ // public java.io.InputStream Stream;++ public SevenZip.Common.InBuffer bufferedStream = new SevenZip.Common.InBuffer();++ int read() throws IOException {+ return bufferedStream.read();+ }++ public void Create(int bufferSize) { bufferedStream.Create(bufferSize); }++ public long GetProcessedSize() {+ return bufferedStream.GetProcessedSize();+ }++ public final void SetStream(java.io.InputStream stream)+ {+ bufferedStream.SetStream(stream);+ }++ public final void ReleaseStream() throws IOException+ {+ bufferedStream.ReleaseStream();+ }++ public final void Init() throws IOException+ {+ bufferedStream.Init();+ Code = 0;+ Range = -1;+ for (int i = 0; i < 5; i++) {+ Code = (Code << 8) | this.read();+ }++ }++ public final int DecodeDirectBits(int numTotalBits) throws IOException+ {+ int result = 0;+ for (int i = numTotalBits; i != 0; i--)+ {+ Range >>>= 1;+ int t = ((Code - Range) >>> 31);+ Code -= Range & (t - 1);+ result = (result << 1) | (1 - t);++ if ((Range & kTopMask) == 0)+ {+ Code = (Code << 8) | this.read();+ Range <<= 8;+ }+ }+ return result;+ }++ public int DecodeBit(short []probs, int index) throws IOException {+ int prob = probs[index];+ int newBound = (Range >>> kNumBitModelTotalBits) * prob;+ if ((Code ^ 0x80000000) < (newBound ^ 0x80000000)) {+ Range = newBound;+ probs[index] = (short)(prob + ((kBitModelTotal - prob) >>> kNumMoveBits));+ if ((Range & kTopMask) == 0) {+ Code = (Code << 8) | this.read();+ Range <<= 8;+ }+ return 0;+ } else {+ Range -= newBound;+ Code -= newBound;+ probs[index] = (short)(prob - ((prob) >>> kNumMoveBits));+ if ((Range & kTopMask) == 0) {+ Code = (Code << 8) | this.read();+ Range <<= 8;+ }+ return 1;+ }+ }++ public static void InitBitModels(short[] probs) {+ for (int i = 0; i < probs.length; i++)+ probs[i] = (kBitModelTotal >>> 1);+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/Encoder.java b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/Encoder.javanew file mode 100644index 000000000..48485aba6--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/Compression/RangeCoder/Encoder.java@@ -0,0 +1,153 @@+package SevenZip.Compression.RangeCoder;+import java.io.IOException;++import SevenZip.Compression.RangeCoder.Encoder;++public class Encoder+{+ static final int kTopMask = ~((1 << 24) - 1);++ static final int kNumBitModelTotalBits = 11;+ static final int kBitModelTotal = (1 << kNumBitModelTotalBits);+ static final int kNumMoveBits = 5;++ java.io.OutputStream Stream;++ long Low;+ int Range;+ int _cacheSize;+ int _cache;++ long _position;++ public void SetStream(java.io.OutputStream stream)+ {+ Stream = stream;+ }++ public void ReleaseStream()+ {+ Stream = null;+ }++ public void Init()+ {+ _position = 0;+ Low = 0;+ Range = -1;+ _cacheSize = 1;+ _cache = 0;+ }++ public void FlushData() throws IOException+ {+ for (int i = 0; i < 5; i++)+ ShiftLow();+ }++ public void FlushStream() throws IOException+ {+ Stream.flush();+ }++ public void ShiftLow() throws IOException+ {+ int LowHi = (int)(Low >>> 32);+ if (LowHi != 0 || Low < 0xFF000000L)+ {+ _position += _cacheSize;+ int temp = _cache;+ do+ {+ Stream.write(temp + LowHi);+ temp = 0xFF;+ }+ while(--_cacheSize != 0);+ _cache = (((int)Low) >>> 24);+ }+ _cacheSize++;+ Low = (Low & 0xFFFFFF) << 8;+ }++ public void EncodeDirectBits(int v, int numTotalBits) throws IOException+ {+ for (int i = numTotalBits - 1; i >= 0; i--)+ {+ Range >>>= 1;+ if (((v >>> i) & 1) == 1)+ Low += Range;+ if ((Range & Encoder.kTopMask) == 0)+ {+ Range <<= 8;+ ShiftLow();+ }+ }+ }+++ public long GetProcessedSizeAdd()+ {+ return _cacheSize + _position + 4;+ }++++ static final int kNumMoveReducingBits = 2;+ public static final int kNumBitPriceShiftBits = 6;++ public static void InitBitModels(short []probs)+ {+ for (int i = 0; i < probs.length; i++)+ probs[i] = (kBitModelTotal >>> 1);+ }++ public void Encode(short []probs, int index, int symbol) throws IOException+ {+ int prob = probs[index];+ int newBound = (Range >>> kNumBitModelTotalBits) * prob;+ if (symbol == 0)+ {+ Range = newBound;+ probs[index] = (short)(prob + ((kBitModelTotal - prob) >>> kNumMoveBits));+ }+ else+ {+ Low += (newBound & 0xFFFFFFFFL);+ Range -= newBound;+ probs[index] = (short)(prob - ((prob) >>> kNumMoveBits));+ }+ if ((Range & kTopMask) == 0)+ {+ Range <<= 8;+ ShiftLow();+ }+ }++ private static int[] ProbPrices = new int[kBitModelTotal >>> kNumMoveReducingBits];++ static+ {+ int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits);+ for (int i = kNumBits - 1; i >= 0; i--)+ {+ int start = 1 << (kNumBits - i - 1);+ int end = 1 << (kNumBits - i);+ for (int j = start; j < end; j++)+ ProbPrices[j] = (i << kNumBitPriceShiftBits) ++ (((end - j) << kNumBitPriceShiftBits) >>> (kNumBits - i - 1));+ }+ }++ static public int GetPrice(int Prob, int symbol)+ {+ return ProbPrices[(((Prob - symbol) ^ ((-symbol))) & (kBitModelTotal - 1)) >>> kNumMoveReducingBits];+ }+ static public int GetPrice0(int Prob)+ {+ return ProbPrices[Prob >>> kNumMoveReducingBits];+ }+ static public int GetPrice1(int Prob)+ {+ return ProbPrices[(kBitModelTotal - Prob) >>> kNumMoveReducingBits];+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/HRESULT.java b/libbuild/J7Zip-modified/src/SevenZip/HRESULT.javanew file mode 100644index 000000000..2836542df--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/HRESULT.java@@ -0,0 +1,11 @@+package SevenZip;++public class HRESULT {+ public static final int S_OK = 0;+ public static final int S_FALSE = 1;++ public static final int E_NOTIMPL = 0x80004001;+ public static final int E_FAIL = 0x80004005;+ public static final int E_INVALIDARG = 0x80070057;+}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICodeProgress.java b/libbuild/J7Zip-modified/src/SevenZip/ICodeProgress.javanew file mode 100644index 000000000..290bd2d02--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICodeProgress.java@@ -0,0 +1,6 @@+package SevenZip;++public interface ICodeProgress+{+ public void SetProgress(long inSize, long outSize);+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICompressCoder.java b/libbuild/J7Zip-modified/src/SevenZip/ICompressCoder.javanew file mode 100644index 000000000..dbab994e6--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICompressCoder.java@@ -0,0 +1,13 @@+package SevenZip;++import java.io.IOException;+import java.io.InputStream;+import java.io.OutputStream;++public interface ICompressCoder {++ void Code(+ InputStream inStream, // , ISequentialInStream+ OutputStream outStream, // ISequentialOutStream+ long outSize, ICompressProgressInfo progress) throws IOException;+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICompressCoder2.java b/libbuild/J7Zip-modified/src/SevenZip/ICompressCoder2.javanew file mode 100644index 000000000..08493c032--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICompressCoder2.java@@ -0,0 +1,18 @@+package SevenZip;++import java.io.IOException;+import java.util.Vector;++public interface ICompressCoder2 {++ public void Code(+ Vector inStreams,+ Object useless1, // const UInt64 ** /* inSizes */,+ int numInStreams,+ Vector outStreams,+ Object useless2, // const UInt64 ** /* outSizes */,+ int numOutStreams,+ ICompressProgressInfo progress) throws IOException;++ public void close() throws java.io.IOException ; // destructor+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICompressFilter.java b/libbuild/J7Zip-modified/src/SevenZip/ICompressFilter.javanew file mode 100644index 000000000..514b3f541--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICompressFilter.java@@ -0,0 +1,12 @@+package SevenZip;++public interface ICompressFilter {+ int Init();+ int Filter(byte [] data, int size);+ // Filter return outSize (UInt32)+ // if (outSize <= size): Filter have converted outSize bytes+ // if (outSize > size): Filter have not converted anything.+ // and it needs at least outSize bytes to convert one block+ // (it's for crypto block algorithms).++}diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICompressGetInStreamProcessedSize.java b/libbuild/J7Zip-modified/src/SevenZip/ICompressGetInStreamProcessedSize.javanew file mode 100644index 000000000..4f2901a94--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICompressGetInStreamProcessedSize.java@@ -0,0 +1,6 @@+package SevenZip;++public interface ICompressGetInStreamProcessedSize {+ public long GetInStreamProcessedSize();+}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICompressProgressInfo.java b/libbuild/J7Zip-modified/src/SevenZip/ICompressProgressInfo.javanew file mode 100644index 000000000..8702418fa--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICompressProgressInfo.java@@ -0,0 +1,6 @@+package SevenZip;++public interface ICompressProgressInfo {+ public static final long INVALID = -1;+ void SetRatioInfo(long inSize, long outSize);+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICompressSetInStream.java b/libbuild/J7Zip-modified/src/SevenZip/ICompressSetInStream.javanew file mode 100644index 000000000..56a0ddc2d--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICompressSetInStream.java@@ -0,0 +1,7 @@+package SevenZip;++public interface ICompressSetInStream {+ public void SetInStream(java.io.InputStream inStream);+ public void ReleaseInStream() throws java.io.IOException ;+}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICompressSetOutStream.java b/libbuild/J7Zip-modified/src/SevenZip/ICompressSetOutStream.javanew file mode 100644index 000000000..91675a2ed--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICompressSetOutStream.java@@ -0,0 +1,7 @@+package SevenZip;++public interface ICompressSetOutStream {+ public int SetOutStream(java.io.OutputStream inStream);+ public int ReleaseOutStream() throws java.io.IOException;+}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/ICompressSetOutStreamSize.java b/libbuild/J7Zip-modified/src/SevenZip/ICompressSetOutStreamSize.javanew file mode 100644index 000000000..998242b25--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/ICompressSetOutStreamSize.java@@ -0,0 +1,7 @@+package SevenZip;++public interface ICompressSetOutStreamSize {+ public static final int INVALID_OUTSIZE=-1;+ public void SetOutStreamSize(long outSize);+}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/IInStream.java b/libbuild/J7Zip-modified/src/SevenZip/IInStream.javanew file mode 100644index 000000000..bc3c3f4c3--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/IInStream.java@@ -0,0 +1,11 @@+package SevenZip;++public abstract class IInStream extends java.io.InputStream+{+ static public final int STREAM_SEEK_SET = 0;+ static public final int STREAM_SEEK_CUR = 1;+ // static public final int STREAM_SEEK_END = 2;+ public abstract long Seek(long offset, int seekOrigin) throws java.io.IOException ;++}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/IProgress.java b/libbuild/J7Zip-modified/src/SevenZip/IProgress.javanew file mode 100644index 000000000..9d3df4f41--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/IProgress.java@@ -0,0 +1,7 @@+package SevenZip;++public interface IProgress {+ public void SetTotal(long total);+ public void SetCompleted(long completeValue);+}+diff --git a/libbuild/J7Zip-modified/src/SevenZip/J7zip.java b/libbuild/J7Zip-modified/src/SevenZip/J7zip.javanew file mode 100644index 000000000..6edec7814--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/J7zip.java@@ -0,0 +1,162 @@+package SevenZip;++import SevenZip.Archive.SevenZip.Handler;+import SevenZip.Archive.SevenZipEntry;+import SevenZip.Archive.IArchiveExtractCallback;+import SevenZip.Archive.IInArchive;++import java.io.IOException;+import java.text.DateFormat;++import java.util.Vector;++public class J7zip {++ static void PrintHelp() {+ System.out.println(+ "\nUsage: JZip <l|t|x> <archive_name> [<file_names>...]\n" ++ " l : Lists files\n" ++ " t : Tests archive.7z\n" ++ " x : eXtracts files\n");+ }++ static void listing(IInArchive archive,Vector listOfNames,boolean techMode) {++ if (!techMode) {+ System.out.println(" Date Time Attr Size Compressed Name");+ System.out.println("-------------- ----- ------------ ------------ ------------");+ }++ long size = 0;+ long packSize = 0;+ long nbFiles = 0;++ for(int i = 0; i < archive.size() ; i++) {+ SevenZipEntry item = archive.getEntry(i);++ DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT , DateFormat.SHORT );+ String str_tm = formatter.format(new java.util.Date(item.getTime()));++ if (listOfNames.contains(item.getName())) {+ if (techMode) {+ System.out.println("Path = " + item.getName());+ System.out.println("Size = " + item.getSize());+ System.out.println("Packed Size = " + item.getCompressedSize());+ System.out.println("Modified = " + str_tm);+ System.out.println(" Attributes : " + item.getAttributesString());+ long crc = item.getCrc();+ if (crc != -1)+ System.out.println("CRC = " + Long.toHexString(crc).toUpperCase());+ else+ System.out.println("CRC =");+ System.out.println("Method = " + item.getMethods() );+ System.out.println("" );++ } else {+ System.out.print(str_tm + " " + item.getAttributesString());++ System.out.print(item.getSize());++ System.out.print(item.getCompressedSize());++ System.out.println(" " + item.getName());+ }++ size += item.getSize();+ packSize += item.getCompressedSize();+ nbFiles ++;+ }+ }++ if (!techMode) {+ System.out.println("-------------- ----- ------------ ------------ ------------");+ System.out.print(" " + size + packSize + " " + nbFiles);+ }+ }++ static void testOrExtract(IInArchive archive, Vector listOfNames,int mode) throws Exception {++ ArchiveExtractCallback extractCallbackSpec = new ArchiveExtractCallback();+ IArchiveExtractCallback extractCallback = extractCallbackSpec;+ extractCallbackSpec.Init(archive);+ extractCallbackSpec.PasswordIsDefined = false;++ try {+ int len = 0;+ int arrays [] = null;++ if (listOfNames.size() >= 1) {+ arrays = new int[listOfNames.size()];+ for(int i = 0 ; i < archive.size() ; i++) {+ if (listOfNames.contains(archive.getEntry(i).getName())) {+ arrays[len++] = i;+ }+ }+ }++ if (len == 0) {+ archive.Extract(null, -1, mode , extractCallback);+ } else {+ archive.Extract(arrays, len, mode, extractCallback);+ }++ if (extractCallbackSpec.NumErrors == 0)+ System.out.println("Ok Done");+ else+ System.out.println(" " + extractCallbackSpec.NumErrors + " errors");+ } catch (IOException e) {+ System.out.println("IO error : " + e.getLocalizedMessage());+ }+ }++ public static void main(String[] args) throws Exception {+ System.out.println("\nJ7zip 4.43 ALPHA 2 (" + Runtime.getRuntime().availableProcessors() + " CPUs)");++ if (args.length < 2) {+ PrintHelp();+ return ;+ }++ final int MODE_LISTING = 0;+ final int MODE_TESTING = 1;+ final int MODE_EXTRACT = 2;++ int mode = -1;++ Vector listOfNames = new Vector();+ for (int i = 2;i < args.length ; i++)+ listOfNames.add(args[i]);++ if (args[0].equals("l")) {+ mode = MODE_LISTING;+ } else if (args[0].equals("t")) {+ mode = MODE_TESTING;+ } else if (args[0].equals("x")) {+ mode = MODE_EXTRACT;+ } else {+ PrintHelp();+ return ;+ }++ String filename = args[1];++ MyRandomAccessFile istream = new MyRandomAccessFile(filename,"r");++ IInArchive archive = new Handler(istream);+++ switch(mode) {+ case MODE_LISTING:+ listing(archive,listOfNames,false);+ break;+ case MODE_TESTING:+ testOrExtract(archive,listOfNames,IInArchive.NExtract_NAskMode_kTest);+ break;+ case MODE_EXTRACT:+ testOrExtract(archive,listOfNames,IInArchive.NExtract_NAskMode_kExtract);+ break;+ }++ archive.close();+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/LzmaAlone.java b/libbuild/J7Zip-modified/src/SevenZip/LzmaAlone.javanew file mode 100644index 000000000..2731610e7--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/LzmaAlone.java@@ -0,0 +1,250 @@+package SevenZip;++public class LzmaAlone+{+ static public class CommandLine+ {+ public static final int kEncode = 0;+ public static final int kDecode = 1;+ public static final int kBenchmak = 2;++ public int Command = -1;+ public int NumBenchmarkPasses = 10;++ public int DictionarySize = 1 << 23;+ public boolean DictionarySizeIsDefined = false;++ public int Lc = 3;+ public int Lp = 0;+ public int Pb = 2;++ public int Fb = 128;+ public boolean FbIsDefined = false;++ public boolean Eos = false;++ public int Algorithm = 2;+ public int MatchFinder = 1;++ public String InFile;+ public String OutFile;++ boolean ParseSwitch(String s)+ {+ if (s.startsWith("d"))+ {+ DictionarySize = 1 << Integer.parseInt(s.substring(1));+ DictionarySizeIsDefined = true;+ }+ else if (s.startsWith("fb"))+ {+ Fb = Integer.parseInt(s.substring(2));+ FbIsDefined = true;+ }+ else if (s.startsWith("a"))+ Algorithm = Integer.parseInt(s.substring(1));+ else if (s.startsWith("lc"))+ Lc = Integer.parseInt(s.substring(2));+ else if (s.startsWith("lp"))+ Lp = Integer.parseInt(s.substring(2));+ else if (s.startsWith("pb"))+ Pb = Integer.parseInt(s.substring(2));+ else if (s.startsWith("eos"))+ Eos = true;+ else if (s.startsWith("mf"))+ {+ String mfs = s.substring(2);+ if (mfs.equals("bt2"))+ MatchFinder = 0;+ else if (mfs.equals("bt4"))+ MatchFinder = 1;+ else if (mfs.equals("bt4b"))+ MatchFinder = 2;+ else+ return false;+ }+ else+ return false;+ return true;+ }++ public boolean Parse(String[] args) throws Exception+ {+ int pos = 0;+ boolean switchMode = true;+ for (int i = 0; i < args.length; i++)+ {+ String s = args[i];+ if (s.length() == 0)+ return false;+ if (switchMode)+ {+ if (s.compareTo("--") == 0)+ {+ switchMode = false;+ continue;+ }+ if (s.charAt(0) == '-')+ {+ String sw = s.substring(1).toLowerCase();+ if (sw.length() == 0)+ return false;+ try+ {+ if (!ParseSwitch(sw))+ return false;+ }+ catch (NumberFormatException e)+ {+ return false;+ }+ continue;+ }+ }+ if (pos == 0)+ {+ if (s.equalsIgnoreCase("e"))+ Command = kEncode;+ else if (s.equalsIgnoreCase("d"))+ Command = kDecode;+ else if (s.equalsIgnoreCase("b"))+ Command = kBenchmak;+ else+ return false;+ }+ else if(pos == 1)+ {+ if (Command == kBenchmak)+ {+ try+ {+ NumBenchmarkPasses = Integer.parseInt(s);+ if (NumBenchmarkPasses < 1)+ return false;+ }+ catch (NumberFormatException e)+ {+ return false;+ }+ }+ else+ InFile = s;+ }+ else if(pos == 2)+ OutFile = s;+ else+ return false;+ pos++;+ continue;+ }+ return true;+ }+ }+++ static void PrintHelp()+ {+ System.out.println(+ "\nUsage: LZMA <e|d> [<switches>...] inputFile outputFile\n" ++ " e: encode file\n" ++ " d: decode file\n" ++ " b: Benchmark\n" ++ "<Switches>\n" ++ // " -a{N}: set compression mode - [0, 1], default: 1 (max)\n" ++ " -d{N}: set dictionary - [0,28], default: 23 (8MB)\n" ++ " -fb{N}: set number of fast bytes - [5, 273], default: 128\n" ++ " -lc{N}: set number of literal context bits - [0, 8], default: 3\n" ++ " -lp{N}: set number of literal pos bits - [0, 4], default: 0\n" ++ " -pb{N}: set number of pos bits - [0, 4], default: 2\n" ++ " -mf{MF_ID}: set Match Finder: [bt2, bt4], default: bt4\n" ++ " -eos: write End Of Stream marker\n"+ );+ }++ public static void main(String[] args) throws Exception+ {+ System.out.println("\nLZMA (Java) 4.42 Copyright (c) 1999-2006 Igor Pavlov 2006-05-15\n");++ if (args.length < 1)+ {+ PrintHelp();+ return;+ }++ CommandLine params = new CommandLine();+ if (!params.Parse(args))+ {+ System.out.println("\nIncorrect command");+ return;+ }++ if (params.Command == CommandLine.kBenchmak)+ {+ int dictionary = (1 << 21);+ if (params.DictionarySizeIsDefined)+ dictionary = params.DictionarySize;+ if (params.MatchFinder > 1)+ throw new Exception("Unsupported match finder");+ SevenZip.LzmaBench.LzmaBenchmark(params.NumBenchmarkPasses, dictionary);+ }+ else if (params.Command == CommandLine.kEncode || params.Command == CommandLine.kDecode)+ {+ java.io.File inFile = new java.io.File(params.InFile);+ java.io.File outFile = new java.io.File(params.OutFile);++ java.io.BufferedInputStream inStream = new java.io.BufferedInputStream(new java.io.FileInputStream(inFile));+ java.io.BufferedOutputStream outStream = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outFile));++ boolean eos = false;+ if (params.Eos)+ eos = true;+ if (params.Command == CommandLine.kEncode)+ {+ SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder();+ if (!encoder.SetAlgorithm(params.Algorithm))+ throw new Exception("Incorrect compression mode");+ if (!encoder.SetDictionarySize(params.DictionarySize))+ throw new Exception("Incorrect dictionary size");+ if (!encoder.SetNumFastBytes(params.Fb))+ throw new Exception("Incorrect -fb value");+ if (!encoder.SetMatchFinder(params.MatchFinder))+ throw new Exception("Incorrect -mf value");+ if (!encoder.SetLcLpPb(params.Lc, params.Lp, params.Pb))+ throw new Exception("Incorrect -lc or -lp or -pb value");+ encoder.SetEndMarkerMode(eos);+ encoder.WriteCoderProperties(outStream);+ long fileSize;+ if (eos)+ fileSize = -1;+ else+ fileSize = inFile.length();+ for (int i = 0; i < 8; i++)+ outStream.write((int)(fileSize >>> (8 * i)) & 0xFF);+ encoder.Code(inStream, outStream, -1, -1, null);+ }+ else+ {+ int propertiesSize = 5;+ byte[] properties = new byte[propertiesSize];+ if (inStream.read(properties, 0, propertiesSize) != propertiesSize)+ throw new Exception("input .lzma file is too short");+ SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(properties);+ long outSize = 0;+ for (int i = 0; i < 8; i++)+ {+ int v = inStream.read();+ if (v < 0)+ throw new Exception("Can't read stream size");+ outSize |= ((long)v) << (8 * i);+ }+ decoder.Code(inStream, outStream, outSize, null);+ }+ outStream.flush();+ outStream.close();+ inStream.close();+ }+ else+ throw new Exception("Incorrect command");+ return;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/LzmaBench.java b/libbuild/J7Zip-modified/src/SevenZip/LzmaBench.javanew file mode 100644index 000000000..9310fc592--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/LzmaBench.java@@ -0,0 +1,388 @@+package SevenZip;++import java.io.ByteArrayOutputStream;+import java.io.IOException;++public class LzmaBench+{+ static final int kAdditionalSize = (1 << 21);+ static final int kCompressedAdditionalSize = (1 << 10);++ static class CRandomGenerator+ {+ int A1;+ int A2;+ public CRandomGenerator() { Init(); }+ public void Init() { A1 = 362436069; A2 = 521288629; }+ public int GetRnd()+ {+ return+ ((A1 = 36969 * (A1 & 0xffff) + (A1 >>> 16)) << 16) ^+ ((A2 = 18000 * (A2 & 0xffff) + (A2 >>> 16)));+ }+ };++ static class CBitRandomGenerator+ {+ CRandomGenerator RG = new CRandomGenerator();+ int Value;+ int NumBits;+ public void Init()+ {+ Value = 0;+ NumBits = 0;+ }+ public int GetRnd(int numBits)+ {+ int result;+ if (NumBits > numBits)+ {+ result = Value & ((1 << numBits) - 1);+ Value >>>= numBits;+ NumBits -= numBits;+ return result;+ }+ numBits -= NumBits;+ result = (Value << numBits);+ Value = RG.GetRnd();+ result |= Value & (((int)1 << numBits) - 1);+ Value >>>= numBits;+ NumBits = 32 - numBits;+ return result;+ }+ };++ static class CBenchRandomGenerator+ {+ CBitRandomGenerator RG = new CBitRandomGenerator();+ int Pos;+ int Rep0;++ public int BufferSize;+ public byte[] Buffer = null;++ public CBenchRandomGenerator() { }+ public void Set(int bufferSize)+ {+ Buffer = new byte[bufferSize];+ Pos = 0;+ BufferSize = bufferSize;+ }+ int GetRndBit() { return RG.GetRnd(1); }+ int GetLogRandBits(int numBits)+ {+ int len = RG.GetRnd(numBits);+ return RG.GetRnd((int)len);+ }+ int GetOffset()+ {+ if (GetRndBit() == 0)+ return GetLogRandBits(4);+ return (GetLogRandBits(4) << 10) | RG.GetRnd(10);+ }+ int GetLen1() { return RG.GetRnd(1 + (int)RG.GetRnd(2)); }+ int GetLen2() { return RG.GetRnd(2 + (int)RG.GetRnd(2)); }+ public void Generate()+ {+ RG.Init();+ Rep0 = 1;+ while (Pos < BufferSize)+ {+ if (GetRndBit() == 0 || Pos < 1)+ Buffer[Pos++] = (byte)(RG.GetRnd(8));+ else+ {+ int len;+ if (RG.GetRnd(3) == 0)+ len = 1 + GetLen1();+ else+ {+ do+ Rep0 = GetOffset();+ while (Rep0 >= Pos);+ Rep0++;+ len = 2 + GetLen2();+ }+ for (int i = 0; i < len && Pos < BufferSize; i++, Pos++)+ Buffer[Pos] = Buffer[Pos - Rep0];+ }+ }+ }+ };++ static class CrcOutStream extends java.io.OutputStream+ {+ public CRC CRC = new CRC();++ public void Init()+ {+ CRC.Init();+ }+ public int GetDigest()+ {+ return CRC.GetDigest();+ }+ public void write(byte[] b)+ {+ CRC.Update(b);+ }+ public void write(byte[] b, int off, int len)+ {+ CRC.Update(b, off, len);+ }+ public void write(int b)+ {+ CRC.UpdateByte(b);+ }+ };++ static class MyOutputStream extends java.io.OutputStream+ {+ byte[] _buffer;+ int _size;+ int _pos;++ public MyOutputStream(byte[] buffer)+ {+ _buffer = buffer;+ _size = _buffer.length;+ }++ public void reset()+ {+ _pos = 0;+ }++ public void write(int b) throws IOException+ {+ if (_pos >= _size)+ throw new IOException("Error");+ _buffer[_pos++] = (byte)b;+ }++ public int size()+ {+ return _pos;+ }+ };++ static class MyInputStream extends java.io.InputStream+ {+ byte[] _buffer;+ int _size;+ int _pos;++ public MyInputStream(byte[] buffer, int size)+ {+ _buffer = buffer;+ _size = size;+ }++ public void reset()+ {+ _pos = 0;+ }++ public int read()+ {+ if (_pos >= _size)+ return -1;+ return _buffer[_pos++] & 0xFF;+ }+ };++ static class CProgressInfo implements ICodeProgress+ {+ public long ApprovedStart;+ public long InSize;+ public long Time;+ public void Init()+ { InSize = 0; }+ public void SetProgress(long inSize, long outSize)+ {+ if (inSize >= ApprovedStart && InSize == 0)+ {+ Time = System.currentTimeMillis();+ InSize = inSize;+ }+ }+ }+ static final int kSubBits = 8;++ static int GetLogSize(int size)+ {+ for (int i = kSubBits; i < 32; i++)+ for (int j = 0; j < (1 << kSubBits); j++)+ if (size <= ((1) << i) + (j << (i - kSubBits)))+ return (i << kSubBits) + j;+ return (32 << kSubBits);+ }++ static long MyMultDiv64(long value, long elapsedTime)+ {+ long freq = 1000; // ms+ long elTime = elapsedTime;+ while (freq > 1000000)+ {+ freq >>>= 1;+ elTime >>>= 1;+ }+ if (elTime == 0)+ elTime = 1;+ return value * freq / elTime;+ }++ static long GetCompressRating(int dictionarySize, long elapsedTime, long size)+ {+ long t = GetLogSize(dictionarySize) - (18 << kSubBits);+ long numCommandsForOne = 1060 + ((t * t * 10) >> (2 * kSubBits));+ long numCommands = (long)(size) * numCommandsForOne;+ return MyMultDiv64(numCommands, elapsedTime);+ }++ static long GetDecompressRating(long elapsedTime, long outSize, long inSize)+ {+ long numCommands = inSize * 220 + outSize * 20;+ return MyMultDiv64(numCommands, elapsedTime);+ }++ static long GetTotalRating(+ int dictionarySize,+ long elapsedTimeEn, long sizeEn,+ long elapsedTimeDe,+ long inSizeDe, long outSizeDe)+ {+ return (GetCompressRating(dictionarySize, elapsedTimeEn, sizeEn) ++ GetDecompressRating(elapsedTimeDe, inSizeDe, outSizeDe)) / 2;+ }++ static void PrintValue(long v)+ {+ String s = "";+ s += v;+ for (int i = 0; i + s.length() < 6; i++)+ System.out.print(" ");+ System.out.print(s);+ }++ static void PrintRating(long rating)+ {+ PrintValue(rating / 1000000);+ System.out.print(" MIPS");+ }++ static void PrintResults(+ int dictionarySize,+ long elapsedTime,+ long size,+ boolean decompressMode, long secondSize)+ {+ long speed = MyMultDiv64(size, elapsedTime);+ PrintValue(speed / 1024);+ System.out.print(" KB/s ");+ long rating;+ if (decompressMode)+ rating = GetDecompressRating(elapsedTime, size, secondSize);+ else+ rating = GetCompressRating(dictionarySize, elapsedTime, size);+ PrintRating(rating);+ }++ static public int LzmaBenchmark(int numIterations, int dictionarySize) throws Exception+ {+ if (numIterations <= 0)+ return 0;+ if (dictionarySize < (1 << 18))+ {+ System.out.println("\nError: dictionary size for benchmark must be >= 18 (256 KB)");+ return 1;+ }+ System.out.print("\n Compressing Decompressing\n\n");++ SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder();++ if (!encoder.SetDictionarySize(dictionarySize))+ throw new Exception("Incorrect dictionary size");++ int kBufferSize = dictionarySize + kAdditionalSize;+ int kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;++ ByteArrayOutputStream propStream = new ByteArrayOutputStream();+ encoder.WriteCoderProperties(propStream);+ SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(propStream.toByteArray());++ CBenchRandomGenerator rg = new CBenchRandomGenerator();++ rg.Set(kBufferSize);+ rg.Generate();+ CRC crc = new CRC();+ crc.Init();+ crc.Update(rg.Buffer, 0, rg.BufferSize);++ CProgressInfo progressInfo = new CProgressInfo();+ progressInfo.ApprovedStart = dictionarySize;++ long totalBenchSize = 0;+ long totalEncodeTime = 0;+ long totalDecodeTime = 0;+ long totalCompressedSize = 0;++ MyInputStream inStream = new MyInputStream(rg.Buffer, rg.BufferSize);++ byte[] compressedBuffer = new byte[kCompressedBufferSize];+ MyOutputStream compressedStream = new MyOutputStream(compressedBuffer);+ CrcOutStream crcOutStream = new CrcOutStream();+ MyInputStream inputCompressedStream = null;+ int compressedSize = 0;+ for (int i = 0; i < numIterations; i++)+ {+ progressInfo.Init();+ inStream.reset();+ compressedStream.reset();+ encoder.Code(inStream, compressedStream, -1, -1, progressInfo);+ long encodeTime = System.currentTimeMillis() - progressInfo.Time;++ if (i == 0)+ {+ compressedSize = compressedStream.size();+ inputCompressedStream = new MyInputStream(compressedBuffer, compressedSize);+ }+ else if (compressedSize != compressedStream.size())+ throw (new Exception("Encoding error"));++ if (progressInfo.InSize == 0)+ throw (new Exception("Internal ERROR 1282"));++ long decodeTime = 0;+ for (int j = 0; j < 2; j++)+ {+ inputCompressedStream.reset();+ crcOutStream.Init();++ long outSize = kBufferSize;+ long startTime = System.currentTimeMillis();+ decoder.Code(inputCompressedStream, crcOutStream, outSize, null);+ decodeTime = System.currentTimeMillis() - startTime;+ if (crcOutStream.GetDigest() != crc.GetDigest())+ throw (new Exception("CRC Error"));+ }+ long benchSize = kBufferSize - (long)progressInfo.InSize;+ PrintResults(dictionarySize, encodeTime, benchSize, false, 0);+ System.out.print(" ");+ PrintResults(dictionarySize, decodeTime, kBufferSize, true, compressedSize);+ System.out.println();++ totalBenchSize += benchSize;+ totalEncodeTime += encodeTime;+ totalDecodeTime += decodeTime;+ totalCompressedSize += compressedSize;+ }+ System.out.println("---------------------------------------------------");+ PrintResults(dictionarySize, totalEncodeTime, totalBenchSize, false, 0);+ System.out.print(" ");+ PrintResults(dictionarySize, totalDecodeTime,+ kBufferSize * (long)numIterations, true, totalCompressedSize);+ System.out.println(" Average");+ return 0;+ }+}diff --git a/libbuild/J7Zip-modified/src/SevenZip/MyRandomAccessFile.java b/libbuild/J7Zip-modified/src/SevenZip/MyRandomAccessFile.javanew file mode 100644index 000000000..f3a88b8b0--- /dev/null+++ b/libbuild/J7Zip-modified/src/SevenZip/MyRandomAccessFile.java@@ -0,0 +1,45 @@+package SevenZip;++import java.io.File;+import java.io.IOException;+import java.io.RandomAccessFile;++public class MyRandomAccessFile extends SevenZip.IInStream {++ RandomAccessFile _file;++ public MyRandomAccessFile(File file, String mode) throws IOException {+ this(file.getAbsolutePath(), mode);+ }++ public MyRandomAccessFile(String filename,String mode) throws IOException {+ _file = new RandomAccessFile(filename,mode);+ }++ public long Seek(long offset, int seekOrigin) throws IOException {+ if (seekOrigin == STREAM_SEEK_SET) {+ _file.seek(offset);+ }+ else if (seekOrigin == STREAM_SEEK_CUR) {+ _file.seek(offset + _file.getFilePointer());+ }+ return _file.getFilePointer();+ }++ public int read() throws IOException {+ return _file.read();+ }++ public int read(byte [] data, int off, int size) throws IOException {+ return _file.read(data,off,size);+ }++ public int read(byte [] data, int size) throws IOException {+ return _file.read(data,0,size);+ }++ public void close() throws IOException {+ _file.close();+ _file = null;+ }+}\ No newline at end of filediff --git a/libbuild/pom.xml b/libbuild/pom.xmlindex 0ffe00837..c4791c012 100644--- a/libbuild/pom.xml+++ b/libbuild/pom.xml@@ -19,6 +19,7 @@<modules><module>GitRevMavenTask</module><module>WebCat-swf</module>+ <module>J7Zip-modified</module><!-- hack to include YaCy as module<module>..</module>-->diff --git a/pom.xml b/pom.xmlindex 5f5de3704..303b333b7 100644--- a/pom.xml+++ b/pom.xml@@ -236,31 +236,7 @@</configuration></plugin>-->- <plugin>- <!-- install jars not found in maven repository to local repository -->- <groupId>org.apache.maven.plugins</groupId>- <artifactId>maven-install-plugin</artifactId>- <version>2.5.2</version>- <executions>-- <execution>- <id>install-J7Zip-jar</id>- <phase>validate</phase>- <goals>- <goal>install-file</goal>- </goals>- <configuration>- <file>${basedir}/lib/J7Zip-modified.jar</file>- <groupId>net.yacy.extlib</groupId>- <artifactId>J7Zip-modified</artifactId>- <version>1.02</version>- <packaging>jar</packaging>- <generatePom>true</generatePom>- </configuration>- </execution>- </executions>- </plugin></plugins></build>