tag | 212d543ff8330a6430a17839d6fdd63f89b3c42a | |
---|---|---|
tagger | Brendan Duncan <brendanduncan@gmail.com> | Mon Jun 22 04:18:39 2015 |
object | 4f347df3df50d6031e19332341d6267c107ff600 |
commit | 4f347df3df50d6031e19332341d6267c107ff600 | [log] [tgz] |
---|---|---|
author | Brendan Duncan <brendanduncan@gmail.com> | Mon Jun 22 04:07:55 2015 |
committer | Brendan Duncan <brendanduncan@gmail.com> | Mon Jun 22 04:07:55 2015 |
tree | d00fa6b9c2c83ede3bb952b7c9a2ab6b127b9b54 | |
parent | 390c59b84a54f7d02ea167b8745ff572dd54571c [diff] |
Code cleanup
##Overview
A Dart library to encode and decode various archive and compression formats.
The library has no reliance on dart:io
, so it can be used for both server and web applications.
The archive library currently supports the following decoders:
And the following encoders:
##Sample
Extract the contents of a Zip file, and encode the contents as a BZip2 compressed Tar file:
import 'dart:io' as Io; import 'package:archive/archive.dart'; void main() { // Read the Zip file from disk. List<int> bytes = new Io.File('test.zip').readAsBytesSync(); // Decode the Zip file Archive archive = new ZipDecoder().decodeBytes(bytes); // Extract the contents of the Zip archive to disk. for (ArchiveFile file in archive) { String filename = file.name; List<int> data = file.content; new Io.File('out/' + filename) ..createSync(recursive: true) ..writeAsBytesSync(data); } // Encode the archive as a BZip2 compressed Tar file. List<int> tar_data = new TarEncoder().encode(archive); List<int> tar_bz2 = new BZip2Encoder().encode(tar_data); // Write the compressed tar file to disk. Io.File fp = new Io.File(filename + '.tbz'); fp.writeAsBytesSync(tar_bz2); }