commit
898f6c5891
@ -1,19 +1,20 @@
|
||||
*.class
|
||||
*.*~
|
||||
lib/yacycore.jar
|
||||
libbuild/svnRevNr.jar
|
||||
libbuild/GitRevTask.jar
|
||||
gen/**
|
||||
/DATA
|
||||
classes/
|
||||
RELEASE/
|
||||
/yacy.pid
|
||||
.DS_Store
|
||||
lib/yacy-cora.jar
|
||||
/DATA.bkp
|
||||
/DATA.1
|
||||
/gen
|
||||
/api
|
||||
/winDATA.bkp/
|
||||
/DATA.cloud/
|
||||
yacy.log
|
||||
*.class
|
||||
*.*~
|
||||
lib/yacycore.jar
|
||||
libbuild/svnRevNr.jar
|
||||
libbuild/GitRevTask.jar
|
||||
gen/**
|
||||
/DATA
|
||||
classes/
|
||||
RELEASE/
|
||||
/yacy.pid
|
||||
.DS_Store
|
||||
lib/yacy-cora.jar
|
||||
/DATA.bkp
|
||||
/DATA.1
|
||||
/gen
|
||||
/api
|
||||
/winDATA.bkp/
|
||||
/DATA.cloud/
|
||||
yacy.log
|
||||
/target/
|
@ -0,0 +1,78 @@
|
||||
# Network definition file for the freeworld network
|
||||
# this is the default standard network for fresh YaCy Peers
|
||||
|
||||
# -----------------------------------------------------------------#
|
||||
# for an explanation please see the file yacy.network.readme #
|
||||
# this is a work in progress. disabled properties are not yet used #
|
||||
# -----------------------------------------------------------------#
|
||||
|
||||
# define the name of the nework
|
||||
# this nickname is also used to identifiy network requests
|
||||
network.unit.name = zeronet
|
||||
|
||||
# the visible name of the network
|
||||
network.unit.description = ZeroNet Search Index
|
||||
|
||||
# definition of the content domain: possible values are:
|
||||
# global, local, any
|
||||
network.unit.domain = any
|
||||
|
||||
# maximum search time for remote queries (milliseconds)
|
||||
network.unit.remotesearch.maxtime = 3000
|
||||
|
||||
# maximum number of results per remote query
|
||||
network.unit.remotesearch.maxcount = 10
|
||||
|
||||
# flag to switch on dht transmission
|
||||
# if the dht transmission is set to 'false' then for a global
|
||||
# query all targets are accessed
|
||||
network.unit.dht = false
|
||||
|
||||
# the number of redundant target peers:
|
||||
# redundant peers get a copy of the original dht target information
|
||||
network.unit.dhtredundancy.junior = 1
|
||||
network.unit.dhtredundancy.senior = 3
|
||||
|
||||
# the vertical partition of the dht: this applies a division
|
||||
# of the dht into 2^^<partitionExponent> fragments which get
|
||||
# all the same word-partition targets but a document-dht computed
|
||||
# fragment of all documents
|
||||
network.unit.dht.partitionExponent = 4
|
||||
|
||||
# network request burst attributes: this enables non-dht target
|
||||
# positions for certain situations. This is not a 'traditional' burst-mode
|
||||
# since it does not refer to a handshake to a single client but it refers
|
||||
# to not-handshaking in a distributed way. It means to get data without using
|
||||
# a dht transmission logic.
|
||||
|
||||
# switch to enable verification of search results
|
||||
# must be set to true in untrusted networks and can be
|
||||
# set to false in completely trusted networks
|
||||
network.unit.inspection.searchverify = false
|
||||
|
||||
# speed of remote crawl de-queueing. this is the number of milliseconds
|
||||
# as a pause between two requests
|
||||
network.unit.remotecrawl.speed = 300
|
||||
|
||||
# addresses of seed-list bootstrap locations
|
||||
network.unit.bootstrap.seedlist0 = http://search.yacy.net:7050/share/seed.txt
|
||||
|
||||
# each network may use different yacy distributions.
|
||||
# the auto-updater can access network-specific update locations
|
||||
network.unit.update.location0 = http://yacy.net/en/index.html
|
||||
network.unit.update.location0.key = MIIBtzCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoDgYQAAoGAbGeo21lW3Ost86RxSrCLIHaYaaj/68jFrTMjAORGJqUTgnvYCd4T1HmD/pCYrW8sQtN4KFPbm8M/MbDWeojQpy+qVqewBilYIdNpArGknvFkw4jpDPu7aR6FRz56zcZTnBiOpqAbBXDB3o6D1w9zVDPd4LBSTLgedt0joZeVAVk=
|
||||
network.unit.update.location1 = http://kaskelix.de/update/
|
||||
network.unit.update.location1.key = MIIBtzCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoDgYQAAoGAbGeo21lW3Ost86RxSrCLIHaYaaj/68jFrTMjAORGJqUTgnvYCd4T1HmD/pCYrW8sQtN4KFPbm8M/MbDWeojQpy+qVqewBilYIdNpArGknvFkw4jpDPu7aR6FRz56zcZTnBiOpqAbBXDB3o6D1w9zVDPd4LBSTLgedt0joZeVAVk=
|
||||
network.unit.update.location2 = http://latest.yacy.de/
|
||||
network.unit.update.location2.key = MIIBtzCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoDgYQAAoGAbGeo21lW3Ost86RxSrCLIHaYaaj/68jFrTMjAORGJqUTgnvYCd4T1HmD/pCYrW8sQtN4KFPbm8M/MbDWeojQpy+qVqewBilYIdNpArGknvFkw4jpDPu7aR6FRz56zcZTnBiOpqAbBXDB3o6D1w9zVDPd4LBSTLgedt0joZeVAVk=
|
||||
|
||||
# properties for in-protocol response authentication:
|
||||
network.unit.protocol.control = uncontrolled
|
||||
|
||||
# white/blacklists
|
||||
network.unit.access.whitelist = 10\..*,127\..*,172\.(1[6-9]|2[0-9]|3[0-1])\..*,169\.254\..*,192\.168\..*,localhost
|
||||
network.unit.access.blacklist =
|
||||
|
||||
# greedy learning: fast information acquisition heuristic for new peers
|
||||
greedylearning.enabled = false
|
||||
greedylearning.limit.doccount = 1000
|
@ -0,0 +1,20 @@
|
||||
<?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>
|
||||
<groupId>net.yacy</groupId>
|
||||
<artifactId>SimpleSearchClient</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>Simple search client example to query YaCy and receive search results as RSS feed</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,47 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h1>File Share</h1>
|
||||
#(mode)#
|
||||
<!-- mode = 0 - display an upload form -->
|
||||
<p>This form can be used to share a (index) file</p>
|
||||
<form id="push" action="share.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
|
||||
<dl>
|
||||
<dt>Files to process:<dt>
|
||||
<dt> <dt><dd> </dd>
|
||||
<dd>
|
||||
<dl>
|
||||
<dt>data=</dt>
|
||||
<dd><input name="data" type="file"></dd>
|
||||
</dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
::
|
||||
<!-- mode 1 - display the push results -->
|
||||
Result for the recently submitted file(s). You can also submit the same form using the servlet share.json to get push confirmations in json format.
|
||||
<dl>
|
||||
<dt>successall</dt><dd>#(successall)#false::true#(/successall)#</dd>
|
||||
<dt>countsuccess</dt><dd>#[countsuccess]#</dd>
|
||||
<dt>countfail</dt><dd>#[countfail]#</dd>
|
||||
</dl>
|
||||
<table border="1">
|
||||
<tr><th>Item</th><th>URL</th><th>Success</th><th>Message</th></tr>
|
||||
<tr>
|
||||
<td>#[item]#</td>
|
||||
<td><a href="#[url]#">#[url]#</a></td>
|
||||
<td>#(success)#fail::ok#(/success)#</td>
|
||||
<td>#(success)##[message]#::<a href="#[message]#" target="_blank">#[message]#</a>#(/success)#</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
If you want to push again files, use this form to pre-define a number of upload forms:
|
||||
<form id="push" action="share.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
|
||||
<input name="c" type="text" value="1" size="4" maxlength="8"><input type="submit" value="Submit">
|
||||
</form>
|
||||
</p>
|
||||
#(/mode)#
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* share
|
||||
* Copyright 2016 by Michael Peter Christen, mc@yacy.net, Frankfurt a. M., Germany
|
||||
* First released 24.02.2016 at http://yacy.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program in the file lgpl21.txt
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import net.yacy.yacy;
|
||||
import net.yacy.cora.document.encoding.UTF8;
|
||||
import net.yacy.cora.order.Base64Order;
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.cora.util.ConcurrentLog;
|
||||
import net.yacy.search.Switchboard;
|
||||
import net.yacy.search.index.Fulltext;
|
||||
import net.yacy.server.serverObjects;
|
||||
import net.yacy.server.serverSwitch;
|
||||
|
||||
public class share {
|
||||
|
||||
/**
|
||||
* Servlet to share any kind of binary to this peer.
|
||||
* That mean you can upload 'things'. While this is the generic view,
|
||||
* it will operate in the beginning only for full solr export files.
|
||||
* The servlet will decide if it wants that kind of data and if the sender is valid,
|
||||
* i.e. if the sender is within the own network and known.
|
||||
* Index dumps which are uploaded are placed to a specific folder
|
||||
* where they can be downloaded again by peers.
|
||||
* An optional operation is the immediate indexing of the shared index.
|
||||
* @param header
|
||||
* @param post
|
||||
* @param env
|
||||
* @return
|
||||
*/
|
||||
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
||||
final serverObjects prop = new serverObjects();
|
||||
|
||||
// display mode: this only helps to display a nice input form for test cases
|
||||
int c = post == null ? 1 : post.getInt("c", 0);
|
||||
if (c > 0) {
|
||||
prop.put("mode", 0);
|
||||
return prop;
|
||||
}
|
||||
|
||||
// push mode: this does a document upload
|
||||
prop.put("mode", 1);
|
||||
prop.put("success", 0);
|
||||
if (post == null) return prop;
|
||||
|
||||
// check file name
|
||||
String filename = post.get("data", "");
|
||||
if (!filename.startsWith(Fulltext.yacy_dump_prefix) || !filename.endsWith(".xml.gz")) return prop;
|
||||
|
||||
// check data
|
||||
String dataString = post.get("data$file", "");
|
||||
if (dataString.length() == 0) return prop;
|
||||
byte[] data;
|
||||
if (filename.endsWith(".base64")) {
|
||||
data = Base64Order.standardCoder.decode(dataString);
|
||||
filename = filename.substring(0, filename.length() - 7);
|
||||
} else {
|
||||
data = UTF8.getBytes(dataString);
|
||||
}
|
||||
if (data == null || data.length == 0) return prop;
|
||||
|
||||
// modify the file name; ignore and replace the used transaction token
|
||||
int ttp = filename.indexOf("_t");
|
||||
if (ttp < 0) return prop;
|
||||
if (filename.charAt(ttp + 3) != '.') return prop;
|
||||
filename = filename.substring(0, ttp) + "_ts" + filename.substring(ttp + 3); // transaction token: 's' as 'shared'.
|
||||
|
||||
// process the data
|
||||
File tmpFile = new File(yacy.shareDumpDefaultPath, filename + ".tmp");
|
||||
File finalFile = new File(yacy.shareDumpDefaultPath, filename);
|
||||
try {
|
||||
Files.copy(new ByteArrayInputStream(data), tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
tmpFile.renameTo(finalFile);
|
||||
} catch (IOException e) {
|
||||
ConcurrentLog.logException(e);
|
||||
return prop;
|
||||
}
|
||||
|
||||
prop.put("success", 1);
|
||||
return prop;
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
<div class="SubMenu">
|
||||
<h3>System Administration</h3>
|
||||
<ul class="SubMenu">
|
||||
<li><a href="Tables_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Viewer and administration for database tables</a></li>
|
||||
<li><a href="PerformanceQueues_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Performance Settings of Busy Queues</a></li>
|
||||
<li><a href="Settings_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Advanced Settings</a></li>
|
||||
<li><a href="PerformanceQueues_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Performance Settings of Busy Queues</a></li>
|
||||
<li><a href="Tables_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Viewer and administration for database tables</a></li>
|
||||
<li><a href="ConfigProperties_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Advanced Properties</a></li>
|
||||
</ul>
|
||||
</div>
|
Binary file not shown.
@ -1,45 +0,0 @@
|
||||
list of library-dependencies:
|
||||
|
||||
* jetty (these files were taken from the solr 3.6.0 example)
|
||||
jetty-6.1.26-patched-JETTY-1340.jar
|
||||
jetty-util-6.1.26-patched-JETTY-1340.jar
|
||||
servlet-api-2.5-20081211.jar
|
||||
|
||||
* apache-solr-solrj-3.4.0.jar depends on:
|
||||
commons-codec-1.4.jar
|
||||
commons-httpclient-3.1.jar
|
||||
commons-io-1.4.jar
|
||||
geronimo-stax-api_1.0_spec-1.0.1.jar
|
||||
jcl-over-slf4j-1.6.1.jar
|
||||
slf4j-api-1.6.1.jar
|
||||
wstx-asl-3.2.7.jar
|
||||
|
||||
* apache-solr-core-3.6.0.jar depends on
|
||||
commons-codec-1.6.jar
|
||||
commons-fileupload-1.2.1.jar
|
||||
commons-httpclient-3.1.jar
|
||||
commons-io-2.1.jar
|
||||
commons-lang-2.6.jar
|
||||
geronimo-stax-api_1.0_spec-1.0.1.jar
|
||||
guava-r05.jar
|
||||
httpclient-4.3.6.jar
|
||||
httpcore-4.3.3.jar
|
||||
jcl-over-slf4j-1.6.1.jar
|
||||
log4j-over-slf4j-1.6.1.jar
|
||||
lucene-analyzers-3.6.0.jar
|
||||
lucene-core-3.6.0.jar
|
||||
lucene-highlighter-3.6.0.jar
|
||||
lucene-phonetic-3.6.0.jar
|
||||
lucene-spatial-3.6.0.jar
|
||||
lucene-spellchecker-3.6.0.jar
|
||||
slf4j-api-1.6.1.jar
|
||||
slf4j-jdk14-1.6.1.jar
|
||||
wstx-asl-3.2.7.jar
|
||||
|
||||
* pdfbox-1.8.5.jar depends on:
|
||||
(see http://pdfbox.apache.org/dependencies.html)
|
||||
fontbox-1.8.5.jar
|
||||
jempbox-1.8.5.jar
|
||||
bcprov-jdk15-1.44.jar
|
||||
bcmail-jdk15-1.44.jar
|
||||
icu4j.jar
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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>
|
@ -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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package SevenZip.Archive.Common;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import Common.IntVector;
|
||||
|
||||
public class BindInfo {
|
||||
|
||||
public Vector<CoderStreamsInfo> Coders = new Vector();
|
||||
public Vector<BindPair> 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 the coder index number
|
||||
*/
|
||||
public int FindInStream(int streamIndex) {
|
||||
for (int i=0; i<Coders.size(); i++) {
|
||||
int curSize = ((CoderStreamsInfo)Coders.get(i)).NumInStreams;
|
||||
if (streamIndex < curSize) {
|
||||
return i;
|
||||
}
|
||||
streamIndex -= curSize;
|
||||
}
|
||||
return -1; //throw new UnknownError("1");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param streamIndex
|
||||
* @return the coder index number
|
||||
*/
|
||||
public int FindOutStream(int streamIndex) {
|
||||
for (int i=0; i<Coders.size(); i++) {
|
||||
int curSize = ((CoderStreamsInfo)Coders.get(i)).NumOutStreams;
|
||||
if (streamIndex < curSize)
|
||||
return i;
|
||||
streamIndex -= curSize;
|
||||
}
|
||||
return -1; //throw new UnknownError("1");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
@ -0,0 +1,270 @@
|
||||
package SevenZip.Archive.Common;
|
||||
|
||||
import SevenZip.HRESULT;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Vector;
|
||||
|
||||
import Common.LongVector;
|
||||
import SevenZip.ICompressCoder2;
|
||||
import SevenZip.ICompressCoder;
|
||||
import SevenZip.ICompressSetInStream;
|
||||
import SevenZip.ICompressSetOutStream;
|
||||
import SevenZip.ICompressSetOutStreamSize;
|
||||
import SevenZip.ICompressProgressInfo;
|
||||
|
||||
|
||||
public class CoderMixer2ST implements ICompressCoder2 , CoderMixer2 {
|
||||
|
||||
BindInfo _bindInfo = new BindInfo();
|
||||
Vector<STCoderInfo> _coders = new Vector<STCoderInfo>();
|
||||
int _mainCoderIndex;
|
||||
|
||||
public CoderMixer2ST(BindInfo bindInfo) {
|
||||
this._bindInfo = bindInfo;
|
||||
}
|
||||
|
||||
public void AddCoderCommon(boolean isMain) {
|
||||
CoderStreamsInfo csi = _bindInfo.Coders.get(_coders.size());
|
||||
_coders.add(new STCoderInfo(csi.NumInStreams, csi.NumOutStreams, isMain));
|
||||
}
|
||||
|
||||
public void AddCoder2(ICompressCoder2 coder, boolean isMain) {
|
||||
AddCoderCommon(isMain);
|
||||
_coders.lastElement().Coder2 = coder;
|
||||
}
|
||||
|
||||
public void AddCoder(ICompressCoder coder, boolean isMain) {
|
||||
AddCoderCommon(isMain);
|
||||
_coders.lastElement().Coder = coder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ReInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetCoderInfo(int coderIndex,LongVector inSizes, LongVector outSizes) {
|
||||
// _coders[coderIndex].SetCoderInfo(inSizes, outSizes);
|
||||
_coders.get(coderIndex).SetCoderInfo(inSizes, outSizes);
|
||||
}
|
||||
|
||||
public int GetInStream(
|
||||
Vector<InputStream> inStreams,
|
||||
//Object useless_inSizes, // const UInt64 **inSizes,
|
||||
int streamIndex,
|
||||
InputStream [] inStreamRes) {
|
||||
InputStream seqInStream;
|
||||
int i;
|
||||
for(i = 0; i < _bindInfo.InStreams.size(); i++)
|
||||
if (_bindInfo.InStreams.get(i) == streamIndex) {
|
||||
seqInStream = inStreams.get(i);
|
||||
inStreamRes[0] = seqInStream; // seqInStream.Detach();
|
||||
return HRESULT.S_OK;
|
||||
}
|
||||
int binderIndex = _bindInfo.FindBinderForInStream(streamIndex);
|
||||
if (binderIndex < 0)
|
||||
return HRESULT.E_INVALIDARG;
|
||||
|
||||
int coderIndex = _bindInfo.FindOutStream(_bindInfo.BindPairs.get(binderIndex).OutIndex);
|
||||
if (coderIndex < 0)
|
||||
return HRESULT.E_INVALIDARG;
|
||||
|
||||
CoderInfo coder = _coders.get(coderIndex);
|
||||
if (coder.Coder == null)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
|
||||
seqInStream = (InputStream)coder.Coder; // coder.Coder.QueryInterface(IID_ISequentialInStream, &seqInStream);
|
||||
if (seqInStream == null)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
|
||||
int startIndex = _bindInfo.GetCoderInStreamIndex(coderIndex);
|
||||
|
||||
if (coder.Coder == null)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
|
||||
ICompressSetInStream setInStream = (ICompressSetInStream)coder.Coder; // coder.Coder.QueryInterface(IID_ICompressSetInStream, &setInStream);
|
||||
if (setInStream == null)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
|
||||
if (coder.NumInStreams > 1)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
for (i = 0; i < (int)coder.NumInStreams; i++) {
|
||||
InputStream [] tmp = new InputStream[1];
|
||||
int res = GetInStream(inStreams, /*useless_inSizes,*/ startIndex + i, tmp /* &seqInStream2 */ );
|
||||
if (res != HRESULT.S_OK) return res;
|
||||
InputStream seqInStream2 = tmp[0];
|
||||
setInStream.SetInStream(seqInStream2);
|
||||
//if (res != HRESULT.S_OK) return res;
|
||||
}
|
||||
inStreamRes[0] = seqInStream; // seqInStream.Detach();
|
||||
return HRESULT.S_OK;
|
||||
}
|
||||
|
||||
public int GetOutStream(
|
||||
Vector<OutputStream> outStreams,
|
||||
//Object useless_outSizes, // const UInt64 **outSizes,
|
||||
int streamIndex,
|
||||
OutputStream [] outStreamRes) {
|
||||
OutputStream seqOutStream;
|
||||
int i;
|
||||
for(i = 0; i < _bindInfo.OutStreams.size(); i++)
|
||||
if (_bindInfo.OutStreams.get(i) == streamIndex) {
|
||||
seqOutStream = outStreams.get(i);
|
||||
outStreamRes[0] = seqOutStream; // seqOutStream.Detach();
|
||||
return HRESULT.S_OK;
|
||||
}
|
||||
int binderIndex = _bindInfo.FindBinderForOutStream(streamIndex);
|
||||
if (binderIndex < 0)
|
||||
return HRESULT.E_INVALIDARG;
|
||||
|
||||
int coderIndex = _bindInfo.FindInStream(_bindInfo.BindPairs.get(binderIndex).InIndex);
|
||||
if (coderIndex < 0 )
|
||||
return HRESULT.E_INVALIDARG;
|
||||
|
||||
CoderInfo coder = _coders.get(coderIndex);
|
||||
if (coder.Coder == null)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
|
||||
try
|
||||
{
|
||||
seqOutStream = (OutputStream)coder.Coder; // coder.Coder.QueryInterface(IID_ISequentialOutStream, &seqOutStream);
|
||||
} catch (java.lang.ClassCastException e) {
|
||||
return HRESULT.E_NOTIMPL;
|
||||
}
|
||||
|
||||
int startIndex = _bindInfo.GetCoderOutStreamIndex(coderIndex);
|
||||
|
||||
if (coder.Coder == null)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
|
||||
ICompressSetOutStream setOutStream = null;
|
||||
try {
|
||||
setOutStream = (ICompressSetOutStream)coder.Coder; // coder.Coder.QueryInterface(IID_ICompressSetOutStream, &setOutStream);
|
||||
} catch (java.lang.ClassCastException e) {
|
||||
return HRESULT.E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (coder.NumOutStreams > 1)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
for (i = 0; i < (int)coder.NumOutStreams; i++) {
|
||||
OutputStream [] tmp = new OutputStream[1];
|
||||
int res = GetOutStream(outStreams, /*useless_outSizes,*/ startIndex + i, tmp /* &seqOutStream2 */ );
|
||||
if (res != HRESULT.S_OK) return res;
|
||||
OutputStream seqOutStream2 = tmp[0];
|
||||
res = setOutStream.SetOutStream(seqOutStream2);
|
||||
if (res != HRESULT.S_OK) return res;
|
||||
}
|
||||
outStreamRes[0] = seqOutStream; // seqOutStream.Detach();
|
||||
return HRESULT.S_OK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int Code(
|
||||
Vector<InputStream> inStreams,
|
||||
//Object useless_inSizes, // const UInt64 ** inSizes ,
|
||||
int numInStreams,
|
||||
Vector<OutputStream> outStreams,
|
||||
//Object useless_outSizes, // const UInt64 ** /* outSizes */,
|
||||
int numOutStreams,
|
||||
ICompressProgressInfo progress) throws IOException {
|
||||
if (numInStreams != _bindInfo.InStreams.size() ||
|
||||
numOutStreams != _bindInfo.OutStreams.size())
|
||||
return HRESULT.E_INVALIDARG;
|
||||
|
||||
// Find main coder
|
||||
int _mainCoderIndex = -1;
|
||||
int i;
|
||||
for (i = 0; i < _coders.size(); i++)
|
||||
if (_coders.get(i).IsMain) {
|
||||
_mainCoderIndex = i;
|
||||
break;
|
||||
}
|
||||
if (_mainCoderIndex < 0)
|
||||
for (i = 0; i < _coders.size(); i++)
|
||||
if (_coders.get(i).NumInStreams > 1) {
|
||||
if (_mainCoderIndex >= 0)
|
||||
return HRESULT.E_NOTIMPL;
|
||||
_mainCoderIndex = i;
|
||||
}
|
||||
if (_mainCoderIndex < 0)
|
||||
_mainCoderIndex = 0;
|
||||
|
||||
// _mainCoderIndex = 0;
|
||||
// _mainCoderIndex = _coders.Size() - 1;
|
||||
CoderInfo mainCoder = _coders.get(_mainCoderIndex);
|
||||
|
||||
Vector<InputStream> seqInStreams = new Vector<InputStream>(); // CObjectVector< CMyComPtr<ISequentialInStream> >
|
||||
Vector<OutputStream> seqOutStreams = new Vector<OutputStream>(); // CObjectVector< CMyComPtr<ISequentialOutStream> >
|
||||
int startInIndex = _bindInfo.GetCoderInStreamIndex(_mainCoderIndex);
|
||||
int startOutIndex = _bindInfo.GetCoderOutStreamIndex(_mainCoderIndex);
|
||||
for (i = 0; i < (int)mainCoder.NumInStreams; i++) {
|
||||
InputStream tmp [] = new InputStream[1];
|
||||
int res = GetInStream(inStreams, /*useless_inSizes,*/ startInIndex + i, tmp /* &seqInStream */ );
|
||||
if (res != HRESULT.S_OK) return res;
|
||||
InputStream seqInStream = tmp[0];
|
||||
seqInStreams.add(seqInStream);
|
||||
}
|
||||
for (i = 0; i < (int)mainCoder.NumOutStreams; i++) {
|
||||
OutputStream tmp [] = new OutputStream[1];
|
||||
int res = GetOutStream(outStreams, /*useless_outSizes,*/ startOutIndex + i, tmp);
|
||||
if (res != HRESULT.S_OK) return res;
|
||||
OutputStream seqOutStream = tmp[0];
|
||||
seqOutStreams.add(seqOutStream);
|
||||
}
|
||||
Vector<InputStream> seqInStreamsSpec = new Vector<InputStream>();
|
||||
Vector<OutputStream> seqOutStreamsSpec = new Vector<OutputStream>();
|
||||
for (i = 0; i < (int)mainCoder.NumInStreams; i++)
|
||||
seqInStreamsSpec.add(seqInStreams.get(i));
|
||||
for (i = 0; i < (int)mainCoder.NumOutStreams; i++)
|
||||
seqOutStreamsSpec.add(seqOutStreams.get(i));
|
||||
|
||||
for (i = 0; i < _coders.size(); i++) {
|
||||
if (i == _mainCoderIndex)
|
||||
continue;
|
||||
CoderInfo coder = _coders.get(i);
|
||||
|
||||
ICompressSetOutStreamSize setOutStreamSize = null;
|
||||
try
|
||||
{
|
||||
setOutStreamSize = (ICompressSetOutStreamSize)coder.Coder;
|
||||
|
||||
/*int res =*/ setOutStreamSize.SetOutStreamSize(coder.OutSizePointers.get(0));
|
||||
//if (res != HRESULT.S_OK) return res;
|
||||
} catch (java.lang.ClassCastException e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
if (mainCoder.Coder != null) {
|
||||
/*int res =*/ mainCoder.Coder.Code(
|
||||
seqInStreamsSpec.get(0),
|
||||
seqOutStreamsSpec.get(0),
|
||||
// TBD mainCoder.InSizePointers.get(0),
|
||||
mainCoder.OutSizePointers.get(0),
|
||||
progress);
|
||||
//if (res != HRESULT.S_OK) return res;
|
||||
} else {
|
||||
/*int res =*/ mainCoder.Coder2.Code(
|
||||
seqInStreamsSpec, // &seqInStreamsSpec.Front(
|
||||
//mainCoder.InSizePointers.Front(), // &mainCoder.InSizePointers.Front()
|
||||
mainCoder.NumInStreams,
|
||||
seqOutStreamsSpec, // &seqOutStreamsSpec.Front()
|
||||
//mainCoder.OutSizePointers.Front(), // &mainCoder.OutSizePointers.Front()
|
||||
mainCoder.NumOutStreams,
|
||||
progress);
|
||||
//if (res != HRESULT.S_OK) return res;
|
||||
}
|
||||
|
||||
OutputStream stream = seqOutStreams.firstElement();
|
||||
stream.flush();
|
||||
|
||||
return HRESULT.S_OK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue