• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

pixelglow/ZipZap: zip file I/O library for iOS, macOS and tvOS

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

pixelglow/ZipZap

开源软件地址(OpenSource Url):

https://github.com/pixelglow/ZipZap

开源编程语言(OpenSource Language):

Objective-C 68.2%

开源软件介绍(OpenSource Introduction):

Build Status

ZipZap is a zip file I/O library for iOS, macOS and tvOS.

The zip file is an ideal container for compound Objective-C documents. Zip files are widely used and well understood. You can randomly access their parts. The format compresses decently and has extensive operating system and tool support. So we want to make this format an even easier choice for you. Thus, the library features:

  • Easy-to-use interface: The public API offers just two classes! Yet you can look through zip files using familiar NSArray collections and properties. And you can zip, unzip and rezip zip files through familiar NSData, NSStream and Image I/O classes.
  • Efficient implementation: We've optimized zip file reading and writing to reduce virtual memory pressure and disk file thrashing. Depending on how your compound document is organized, updating a single entry can be faster than writing the same data to a separate file.
  • File format compatibility: Since ZipZap closely follows the zip file format specification, it works with most Mac, Linux and Windows zip tools.

Install

As an independent project:

  • In the Terminal, run git clone https://github.com/pixelglow/ZipZap.git.
  • Within the ZipZap directory, open the ZipZap.xcodeproj Xcode project.
  • In the Xcode project, select either the ZipZap (iOS Framework), ZipZap (iOS Static Library), ZipZap (macOS Framework), ZipZap (macOS Static Library), ZipZap (tvOS Framework) or ZipZap (tvOS Static Library) scheme from the drop down.
  • You can now build, test (macOS only) or analyze with the selected scheme.
  • The built libraries and test cases are in a subdirectory of ~/Library/Developer/Xcode/DerivedData.

As a project integrated with your own workspace:

  • In the Terminal, run cd workspace then git submodule add https://github.com/pixelglow/ZipZap.git.
  • In your Xcode workspace, choose the File > Add Files to "workspace" menu item, then within the ZipZap directory pick the ZipZap.xcodeproj Xcode project.
  • In any project target that will use ZipZap:
    • In Build Phases > Link Binary With Libraries, add the corresponding libZipZap.a and any other library listed in the Require Link section below.
    • Under Build Settings > Search Paths > Header Search Paths, add ../ZipZap.
  • You can now build, test or analyze those project targets.

Use

Header includes:

#import <ZipZap/ZipZap.h>

Reading an existing zip file:

ZZArchive* oldArchive = [ZZArchive archiveWithURL:[NSURL fileURLWithPath:@"/tmp/old.zip"]
                                            error:nil];
ZZArchiveEntry* firstArchiveEntry = oldArchive.entries[0];
NSLog(@"The first entry's uncompressed size is %lu bytes.", (unsigned long)firstArchiveEntry.uncompressedSize);
NSLog(@"The first entry's data is: %@.", [firstArchiveEntry newDataWithError:nil]);

Writing a new zip file:

ZZArchive* newArchive = [[ZZArchive alloc] initWithURL:[NSURL fileURLWithPath:@"/tmp/new.zip"]
                                               options:@{ZZOpenOptionsCreateIfMissingKey : @YES}
                                                 error:nil];
[newArchive updateEntries:
                     @[
                     [ZZArchiveEntry archiveEntryWithFileName:@"first.text"
                                                     compress:YES
                                                    dataBlock:^(NSError** error)
                                                          {
                                                              return [@"hello, world" dataUsingEncoding:NSUTF8StringEncoding];
                                                          }]
                     ]
                    error:nil];

Updating an existing zip file:

ZZArchive* oldArchive = [ZZArchive archiveWithURL:[NSURL fileURLWithPath:@"/tmp/old.zip"]
                                            error:nil];
[oldArchive updateEntries:
 [oldArchive.entries arrayByAddingObject:
  [ZZArchiveEntry archiveEntryWithFileName:@"second.text"
                                  compress:YES
                                 dataBlock:^(NSError** error)
                                       {
                                           return [@"bye, world" dataUsingEncoding:NSUTF8StringEncoding];
                                       }]]
                    error:nil];

Advanced uses: Recipes

API references: References

Require

  • Build: Xcode 7 and later.
  • Link: Only system libraries; no third-party libraries needed.
    • ApplicationServices.framework (macOS) or ImageIO.framework (iOS, tvOS)
    • Foundation.framework
    • libz.dylib
  • Run: macOS 10.11 (El Capitan), iOS 9.3 or tvOS 9.2 and later.

Support

License

ZipZap is licensed with the BSD license.

Donate




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap