Skip to content
forked from lzfse/lzfse

Java bindings for the LZFSE C reference implementation

License

Notifications You must be signed in to change notification settings

blackbeard334/lzfse47j

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 

Repository files navigation

What is this?

Java bindings for the LZFSE C reference implementation.

How to use..

Add to your project

Include the following dependency in your pom.xml, and you're good to go.

<dependencies>
    <dependency>
        <groupId>io.github.blackbeard334</groupId>
        <artifactId>lzfse47j</artifactId>
        <version>0.1</version>
        <classifier>natives-linux</classifier> 
 <!--or <classifier>natives-windows</classifier> --> 
    </dependency> 
</dependencies>

Code example

class Bla {
    long decompressLzfse(final byte[] srcArray, final byte[] dstArray) {
        return LzfseUtil.decodeBuffer(srcArray, srcArray.length, dstArray, dstArray.length);
    }
}

Caveat

LZFSE headers do not contain the decompressed length of the compressed file(s), so you need to provide them.

What if I don't know the length of the decompressed file?

The LzfseUtil.decodeBuffer() method will decompress bytes until:

  • EOF reached
  • DST buffer is full

Then we suggest something like:

class Bla {
    byte[] decompressLzfseWithUnknownLength(final byte[] srcArray) {
        final byte[] dstArray = new byte[srcArray.length * 2];

        while (true) {
            final long l = LzfseUtil.decodeBuffer(srcArray, srcArray.length, dstArray, dstArray.length);

            // is the dst buffer full?
            if (l == dstArray.length) {
                // then double dst buffer size
                dstArray = new byte[dstArray.length * 2];
            } else {
                // else EOF reached
                break;
            }
        }

        // return the decompressed bytes range
        return Arrays.copyOfRange(dstArray, 0, l);
    }
}

Development

Requirements

Build

run mvn -clean verify pom.xml -Pnatives-linux || -Pnatives-windows

About

Java bindings for the LZFSE C reference implementation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 92.8%
  • CMake 2.9%
  • Java 2.1%
  • Makefile 1.4%
  • C++ 0.8%