Coder Social home page Coder Social logo

christofferqa / archive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brendan-duncan/archive

0.0 3.0 0.0 965 KB

Dart library to encode and decode various archive and compression formats, such as Zip and Tar.

License: Other

Dart 99.86% HTML 0.14%

archive's Introduction

archive

Build Status

##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:

  • Zip (Archive)
  • Tar (Archive)
  • ZLib [Inflate decompression]
  • GZip [Inflate decompression]
  • BZip2 [decompression]

And the following encoders:

  • Zip (Archive)
  • Tar (Archive)
  • ZLib [Deflate compression]
  • GZip [Deflate compression]
  • BZip2 [compression]

##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);
}

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.