Advertisement
Guest User

KennyTM

a guest
Aug 24th, 2009
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <Foundation/Foundation.h>
  2.  
  3. // From iWorkImport:
  4.  
  5. @interface GQZEntry : NSObject
  6. -(NSData*)data;
  7. @end
  8.  
  9. @interface GQZArchive : NSObject
  10. -(id)initWithPath:(NSString*)path collapseCommonRootDirectory:(BOOL)directory;
  11. -(id)initWithData:(NSData*)data collapseCommonRootDirectory:(BOOL)directory;
  12. -(GQZEntry*)entryWithName:(NSString*)name;
  13. -(NSArray*)entryNames;
  14. -(BOOL)isEncrypted;
  15. @end
  16.  
  17. int main (int argc, const char* argv[]) {
  18.     if (argc < 2) {
  19.         printf("Usage: show-zip-content <zipfile>\n\n");
  20.         return 0;
  21.     }
  22.    
  23.     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
  24.    
  25.     Class GQZArchive_ = objc_getClass("GQZArchive");
  26.     GQZArchive* zip = [[GQZArchive_ alloc] initWithPath:[NSString stringWithUTF8String:argv[1]] collapseCommonRootDirectory:NO];
  27.    
  28.     if ([zip isEncrypted]) {
  29.         printf("Encrypted ZIP files are not supported with GQZArchive.");
  30.     } else {
  31.  
  32.         for (NSString* path in [zip entryNames]) {
  33.             printf("[%s]:\n", [path UTF8String]);
  34.             char buf[64];
  35.             memset(buf, 0, sizeof(buf));
  36.             [[[zip entryWithName:path] data] getBytes:buf length:64];
  37.             // Print the first 64-bytes.
  38.             printf("%s\n", buf);
  39.         }
  40.     }
  41.  
  42.     [zip release];
  43.        
  44.     [pool drain];
  45.    
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement