Permalink
Browse files

lzma bug partial fixed, no special encoder properties in use

  • Loading branch information...
1 parent 48640d2 commit 88c416e8ee76ed7708157ca520c683f3425b01eb @Danny02 committed Jul 16, 2012
@@ -14,5 +14,6 @@ That way multiple projects can share the same settings (useful for formatting ru
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.license>lgpl30</netbeans.hint.license>
+ <netbeans.compile.on.save>all</netbeans.compile.on.save>
</properties>
-</project-shared-configuration>
+</project-shared-configuration>
View
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+ <action>
+ <actionName>run</actionName>
+ <goals>
+ <goal>process-classes</goal>
+ <goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal>
+ </goals>
+ <properties>
+ <exec.args>-Xms512m -classpath %classpath ${packageClassName}</exec.args>
+ <exec.executable>java</exec.executable>
+ <exec.classpathScope>runtime</exec.classpathScope>
+ </properties>
+ </action>
+ <action>
+ <actionName>debug</actionName>
+ <goals>
+ <goal>process-classes</goal>
+ <goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal>
+ </goals>
+ <properties>
+ <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Xms512m -classpath %classpath ${packageClassName}</exec.args>
+ <exec.executable>java</exec.executable>
+ <exec.classpathScope>runtime</exec.classpathScope>
+ <jpda.listen>true</jpda.listen>
+ </properties>
+ </action>
+ <action>
+ <actionName>profile</actionName>
+ <goals>
+ <goal>process-classes</goal>
+ <goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal>
+ </goals>
+ <properties>
+ <exec.args>${profiler.args} -Xms512m -classpath %classpath ${packageClassName}</exec.args>
+ <exec.executable>${profiler.java}</exec.executable>
+ </properties>
+ </action>
+ </actions>
View
@@ -90,6 +90,11 @@
<artifactId>AnnotationsProcessing</artifactId>
<version>1.0</version>
</dependency>
+ <dependency>
+ <groupId>com.github.jponge</groupId>
+ <artifactId>lzma-java</artifactId>
+ <version>1.2</version>
+ </dependency>
</dependencies>
<pluginRepositories>
@@ -1,93 +0,0 @@
-package darwin.jlzmaio;
-
-// ConcurrentBufferInputStream.java -- read bytes from blocking queue
-// Copyright (c)2007 Christopher League <league@contrapunctus.net>
-// modifyed by Daniel Heinrich <DannyNullZwo@gmail.com>
-// This is free software, but it comes with ABSOLUTELY NO WARRANTY.
-// GNU Lesser General Public License 2.1 or Common Public License 1.0
-import java.io.*;
-import java.util.concurrent.BlockingQueue;
-
-class ConcurrentBufferInputStream extends InputStream
-{
-
- private BlockingQueue<byte[]> q;
- private byte[] buf = null;
- private int next = 0;
- private boolean eof = false;
-
- ConcurrentBufferInputStream(BlockingQueue<byte[]> q)
- {
- this.q = q;
- this.eof = false;
- }
-
- public void makeReady() throws IOException
- {
- if (buf == null) {
- buf = guarded_take();
- }
- }
-
- private byte[] guarded_take() throws IOException
- {
- try {
- return q.take();
- } catch (InterruptedException exn) {
- throw new InterruptedIOException(exn.getMessage());
- }
- }
-
- private boolean prepareAndCheckEOF() throws IOException
- {
- if (eof) {
- return true;
- }
- if (buf == null || next >= buf.length) {
- buf = guarded_take();
- next = 0;
- if (buf.length == 0) {
- eof = true;
- return true;
- }
- }
- return false;
- }
-
- public int read() throws IOException
- {
- if (prepareAndCheckEOF()) {
- return -1;
- }
- int x = buf[next];
- next++;
- return x & 0xff;
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException
- {
- if (prepareAndCheckEOF()) {
- return -1;
- }
- int k = buf.length - next;
- if (len < k) {
- k = len;
- }
- System.arraycopy(buf, next, b, off, k);
- next += k;
- return k;
- }
-
- @Override
- public int available() throws IOException
- {
- return buf.length;
- }
-
- @Override
- public String toString()
- {
- return String.format("cbIn@%x", hashCode());
- }
-}
@@ -1,53 +0,0 @@
-package darwin.jlzmaio;
-
-// ConcurrentBufferOutputStream.java -- write bytes to blocking queue
-// Copyright (c)2007 Christopher League <league@contrapunctus.net>
-// modifyed by Daniel Heinrich <DannyNullZwo@gmail.com>
-
-// This is free software, but it comes with ABSOLUTELY NO WARRANTY.
-// GNU Lesser General Public License 2.1 or Common Public License 1.0
-import java.io.*;
-import java.util.concurrent.BlockingQueue;
-
-class ConcurrentBufferOutputStream extends OutputStream
-{
- private final BlockingQueue<byte[]> q;
- private static final int BUFSIZE = 16384;
-
- private ConcurrentBufferOutputStream(BlockingQueue<byte[]> q) {
- this.q = q;
- }
-
- public static OutputStream create(BlockingQueue<byte[]> q) {
- OutputStream out = new ConcurrentBufferOutputStream(q);
- out = new BufferedOutputStream(out, BUFSIZE);
- return out;
- }
-
- private void guarded_put(byte[] a) throws IOException {
- try {
- q.put(a);
- } catch (InterruptedException exn) {
- throw new InterruptedIOException(exn.getMessage());
- }
- }
-
- public void write(int i) throws IOException {
- byte b[] = new byte[1];
- b[0] = (byte) (i & 0xff);
- guarded_put(b);
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- byte[] a = new byte[len];
- System.arraycopy(b, off, a, 0, len);
- guarded_put(a);
- }
-
- @Override
- public void close() throws IOException {
- byte b[] = new byte[0]; // sentinel
- guarded_put(b);
- }
-}
@@ -1,80 +0,0 @@
-package darwin.jlzmaio;
-
-// DecoderThread.java -- run LZMA decoder in a separate thread
-// Copyright (c)2007 Christopher League <league@contrapunctus.net>
-// modifyed by Daniel Heinrich <DannyNullZwo@gmail.com>
-// This is free software, but it comes with ABSOLUTELY NO WARRANTY.
-// GNU Lesser General Public License 2.1 or Common Public License 1.0
-import lzma.Compression.LZMA.Decoder;
-import java.io.*;
-import java.util.concurrent.BlockingQueue;
-
-class DecoderThread extends Thread
-{
-
- private static final byte[] props = new byte[]{0x5d, 0x00, 0x00, 0x10, 0x00};
- private InputStream in;
- private OutputStream out;
- private Decoder dec;
- private IOException exn;
- private long outSize;
-
- public DecoderThread(InputStream in, BlockingQueue<byte[]> q)
- {
- this.in = in;
- out = ConcurrentBufferOutputStream.create(q);
- dec = new Decoder();
- exn = null;
- }
-
- @Override
- public void run()
- {
- try {
- if (LzmaOutputStream.LZMA_HEADER) {
- int n = in.read(props, 0, props.length);
- if (n != props.length) {
- throw new IOException("input .lzma file is too short");
- }
- dec.SetDecoderProperties(props);
- for (int i = 0; i < 8; i++) {
- int v = in.read();
- if (v < 0) {
- throw new IOException("Can't read stream size");
- }
- outSize |= ((long) v) << (8 * i);
- }
- } else {
- outSize = -1;
- dec.SetDecoderProperties(props);
- }
- dec.Code(in, out, outSize);
- in.close(); //?
- } catch (IOException ex) {
- exn = ex;
- }
- // close either way, so listener can unblock
- try {
- out.close();
- } catch (IOException ex) {
- }
- }
-
- public void maybeThrow() throws IOException
- {
- if (exn != null) {
- throw exn;
- }
- }
-
- public long getSize()
- {
- return outSize;
- }
-
- @Override
- public String toString()
- {
- return String.format("Dec@%x", hashCode());
- }
-}
@@ -1,71 +0,0 @@
-package darwin.jlzmaio;
-
-// EncoderThread.java -- run LZMA encoder in a separate thread
-// Copyright (c)2007 Christopher League <league@contrapunctus.net>
-// modifyed by Daniel Heinrich <DannyNullZwo@gmail.com>
-// This is free software, but it comes with ABSOLUTELY NO WARRANTY.
-// GNU Lesser General Public License 2.1 or Common Public License 1.0
-import java.io.*;
-import java.util.concurrent.BlockingQueue;
-import lzma.Compression.LZMA.Encoder;
-
-class EncoderThread extends Thread
-{
-
- public static final Integer DEFAULT_DICT_SZ_POW2 = new Integer(20);
- private BlockingQueue<byte[]> q;
- private InputStream in;
- private OutputStream out;
- private Encoder enc = new Encoder();
- private IOException exn;
-
- /**
- * @param dictSzPow2 If non-null, equivalent to the N in the -dN arg to
- * LzmaAlone
- * @param fastBytes If non-null, equivalent to the N in the -fbN arg to
- * LzmaAlone
- */
- public EncoderThread(OutputStream out, BlockingQueue<byte[]> q,
- Integer dictSzPow2, Integer fastBytes, int lp)
- {
- in = new ConcurrentBufferInputStream(q);
- this.out = out;
- enc.SetDictionarySize(1 << (dictSzPow2 == null ? DEFAULT_DICT_SZ_POW2 : dictSzPow2).intValue());
- if (fastBytes != null) {
- enc.SetNumFastBytes(fastBytes.intValue());
- }
-
- enc.SetAlgorithm(2);
- enc.SetLcLpPb(3, lp, 2);
- }
-
- @Override
- public void run()
- {
- try {
- enc.SetEndMarkerMode(true);
- if (LzmaOutputStream.LZMA_HEADER) {
- enc.WriteCoderProperties(out);
- // 5d 00 00 10 00
- long fileSize = -1;
- for (int i = 0; i < 8; i++) {
- out.write((int) (fileSize >>> (8 * i)) & 0xFF);
- }
- }
- enc.Code(in, out, -1, -1, null);
- } catch (IOException ex) {
- exn = ex;
- }
- }
-
- public IOException getException()
- {
- return exn;
- }
-
- @Override
- public String toString()
- {
- return String.format("Enc@%x", hashCode());
- }
-}
Oops, something went wrong.

0 comments on commit 88c416e

Please sign in to comment.