Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Foundation/Foundation.h>
- // From iWorkImport:
- @interface GQZEntry : NSObject
- -(NSData*)data;
- @end
- @interface GQZArchive : NSObject
- -(id)initWithPath:(NSString*)path collapseCommonRootDirectory:(BOOL)directory;
- -(id)initWithData:(NSData*)data collapseCommonRootDirectory:(BOOL)directory;
- -(GQZEntry*)entryWithName:(NSString*)name;
- -(NSArray*)entryNames;
- -(BOOL)isEncrypted;
- @end
- int main (int argc, const char* argv[]) {
- if (argc < 2) {
- printf("Usage: show-zip-content <zipfile>\n\n");
- return 0;
- }
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- Class GQZArchive_ = objc_getClass("GQZArchive");
- GQZArchive* zip = [[GQZArchive_ alloc] initWithPath:[NSString stringWithUTF8String:argv[1]] collapseCommonRootDirectory:NO];
- if ([zip isEncrypted]) {
- printf("Encrypted ZIP files are not supported with GQZArchive.");
- } else {
- for (NSString* path in [zip entryNames]) {
- printf("[%s]:\n", [path UTF8String]);
- char buf[64];
- memset(buf, 0, sizeof(buf));
- [[[zip entryWithName:path] data] getBytes:buf length:64];
- // Print the first 64-bytes.
- printf("%s\n", buf);
- }
- }
- [zip release];
- [pool drain];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement