FZip has been around for some time now, and people seem to like it. However one feature has been asked for repeatedly: In addition to reading ZIP archive, people want to be able to create new (and modify existing) archives.
So i finally sat down this weekend and added that.
The code is not tested very well (it works for me but may not work for you) and has no ASDocs yet, so i release it as an alpha version, with the hope of massive bug feedback.. :)
New methods in class FZip:
- addFile(name:String, date:Date, content:ByteArray)
- addFileAt(index:uint, name:String, date:Date, content:ByteArray)
// Create file contents var ba:ByteArray = new ByteArray(); ba.writeUTFBytes("Hello World!"); // Create ZIP archive and add file var zip:FZip = new FZip(); zip.addFile("hello.txt", null, ba); // Serialize ZIP into a new file // (we use the Adobe AIR specific class FileStream here, // but you can as well use ByteArray
or anything that
// implements IDataOutput) var file:File = File.applicationStorageDirectory; file = file.resolvePath("hello.zip"); var stream:FileStream = new FileStream(); stream.open(file, FileMode.WRITE); zip.serialize(stream); stream.close();