Code Monkey home page Code Monkey logo

haxe-zip's Introduction

haxe-zip

Library to provide a cross-platform streaming Zip Writer / Reader experience.

Mainly took haxe.zip.* class from haxe and did some modification.

Also took DeflateStream from PNGEncoder2 and removed flash specific code to add compress support on platform that did not have it natively.

Use pako.js for JS target (sadly although DeflateStream works, it's not optimized)

On flash, use deflate / inflate from ByteArray

If OpenFL is detected then we use lime functions for Compress / Decompress

Pretty much every targets should be compatible with this library although I only tested SWF / JS / OpenFL

I'll write better example eventually

// Compress example:
var zip = new ZipWriter();

zip.addString("This is a compressed text file", "hey.txt", true);
zip.addString("This is a non-compressed text file", "test/you.txt", false);

var bytes = zip.finalize();
// Uncompress example:
var entries = new StringMap<ZipEntry>();

var zip = new ZipReader(bytes);
var entry:ZipEntry;

// Read your Entry info (you could progressively read your zip entries X number per frame)
// Data is not copied nor uncompressed at this stage
while ( (entry = zip.getNextEntry()) != null )
{
  // Do something with your entry
  entries.set(entry.fileName, entry);

  trace("Entry", entry.fileName);
}

// You could get a percentage of task done using this
var percent = (entry == null) ? 1 : zip.progress();

// Read your entry's data, will copy the Data on request (support Deflate even on JS/SWF target)
var myBytes = Zip.getBytes(entries.get("sheets.xml"));
var myText = Zip.getString(entries.get("sheets/159288dc66df51f.xml"));

trace("Bytes", myBytes.length);
trace("Text", myText);

haxe-zip's People

Contributors

starburst997 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

haxe-zip's Issues

openfl backward compatibility

Instead of having just
#if openfl
Maybe put
#if (openfl>4)
So that the extension works with older versions

PS : I'm not sure since which openfl uses lime.utils.compress.Deflate. I know it works in openfl 6 and doesn't work in openfl 3.6.1.

https://github.com/openfl/lime/blob/3.0.2/lime/utils/compress/Deflate.hx It seems to have been implemented in lime 3.0.2 which seems to be openfl 4.5.3

So maybe better something like
#if (openfl && ( lime >= "3.0.2"))

PS2: Thanks for your extension. Really useful :)

Update haxelib version

Thanks for library!

Could you upload new version to haxelib (with lime and other fixes)?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.