Giter VIP home page Giter VIP logo

ddminizip's Introduction

#About this project providers a wrapper around libz for iOS5 and OSX.

Based on code from [email protected] for iOS I expanded and modified it to work as a 'drop-in' static library for OSX 10.7 and IOS 5. You have to link against libzib dylib still.

I split the code into a Writer and a Reader, added a proper Delegate that gets asked about what to extract and and made the original framework compile as a separate lib and use ARC.

#example usage there is a simple CLI tool included, that shows the usage of DDZipWriter and DDZipReader.

apart from that, below you find info on how to use the classes in your app as well as info on the available unzip delegate that enables you to determine what files to extract

##zip DDZipWriter *w = [[DDZipWriter alloc] init]; [w newZipFile:@"testfile.zip"]; for(NSString *file in files) { BOOL res = [w addFileToZip:file newname:[NSString stringWithFormat:@"modified_%@", file]];

    if(res) {
        NSString *n = [file lastPathComponent];
        NSLog(@"added file to zip: %@", n);
    }       
}
[w closeZipFile];

##unzip DDZipReader *z = [[DDZipReader alloc] init]; z.delegate = self; for(NSString *zip in zips) { [z openZipFile:zip]; BOOL res = [z unzipFileTo:path flattenStructure:NO]; [z closeZipFile];

    if(res) {
        NSString *n = [zip lastPathComponent];
        NSLog(@"Extracted zip file: %@", n);
    }       
}
...
- (BOOL)zipArchive:(DDZipReader *)zip shouldExtractFile:(NSString *)file {
    return ([file rangeOfString:@"__MACOSX"].location==NSNotFound);
}

- (BOOL)zipArchive:(DDZipReader *)zip shouldOverwriteFile:(NSString *)file {
    id fileDate = [[[NSFileManager defaultManager] attributesOfItemAtPath:file error:nil] fileModificationDate];
    id fileInfoDate = fileInfo.date;

    return ([fileDate compare:fileInfoDate]==NSOrderedAscending);
}

#DDMinizip is available under the original libz license

ddminizip's People

Contributors

coeur avatar daij-djan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.