A simple rust library for working with ZIP archives
Clone or download
lifthrasiir Merge pull request #9 from seb-odessa/master
Fix build errors on nightly rust
Latest commit cc6fd0e Mar 21, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fix spaces and comments' Mar 21, 2015
.gitignore Update for latest Cargo Aug 20, 2014
.travis.yml fixed .travis.yml. Jan 24, 2015
Cargo.toml language changes: updated deps, expr[..], old_io/path feature flags. Feb 21, 2015
LICENSE Initial version of the library Oct 3, 2013
README.md Update readme to actual status Feb 4, 2015


rust-zip Build Status

A simple rust library to read and write Zip archives, which is also my pet project for learning Rust. At the moment you can list the files in a Zip archive, as well as extracting them if they are either stored (uncompressed) or deflated, but I plan to add write support soon.

A simple example

#![feature(core, os, io, path)]

extern crate zip;

use std::os;
use std::old_io::File;
use zip::ZipReader;
use zip::fileinfo::FileInfo;

fn main() {
    let args = os::args();
    match args.len(){
        2 => list_content(&mut zip_file(&args[1][])),
        3 => extract_file(&mut zip_file(&args[1][]), &args[2][]),
        _ => print_usage(&args[0][])

macro_rules! do_or_die{
    ($expr:expr) => (match $expr {
        Ok(val) => val,
        Err(err) => {println!("{}",err); panic!()}

fn zip_file(file: &str) -> ZipReader<File>{

fn output_file(file: &str)->File{

fn zipped_file_info(zip: &mut ZipReader<File>, file: &str) -> FileInfo{

fn list_content(reader: &mut ZipReader<File>)->(){
    for file in reader.files(){
        let (year, month, day, hour, minute, second) = file.last_modified_datetime;
        let mod_time = format!("{:04}-{:02}-{:02} {:02}:{:02}:{:02}", year, month, day, hour, minute, second);
        println!("{} ({}): bytes: {:10}, compressed: {:10}",
            file.name, mod_time, file.compressed_size, file.uncompressed_size);

fn extract_file(zip: &mut ZipReader<File>, file: &str)->(){
    let mut out = output_file(file);
    let info = zipped_file_info(zip, file);
    do_or_die!(zip.extract(&info, &mut out));

fn print_usage(this: &str)->(){
    println!("Usage: {} [file.zip] [file_to_extract]", this);


  • Learn more Rust
  • Write support
  • Create a proper set of tests
  • Support advanced features (more compression methods, ZIP64, encryption, multiple volumes...)