![]() |
Ignite Tools
|
00001 // 00002 // UA_ASIDataDecompressor.h 00003 // Part of UA_ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 00004 // 00005 // Created by Ben Copsey on 17/08/2010. 00006 // Copyright 2010 All-Seeing Interactive. All rights reserved. 00007 // 00008 00009 // This is a helper class used by UA_ASIHTTPRequest to handle inflating (decompressing) data in memory and on disk 00010 // You may also find it helpful if you need to inflate data and files yourself - see the class methods below 00011 // Most of the zlib stuff is based on the sample code by Mark Adler available at http://zlib.net 00012 00013 #import <Foundation/Foundation.h> 00014 #import <zlib.h> 00015 00016 @interface UA_ASIDataDecompressor : NSObject { 00017 BOOL streamReady; 00018 z_stream zStream; 00019 } 00020 00021 // Convenience constructor will call setupStream for you 00022 + (id)decompressor; 00023 00024 // Uncompress the passed chunk of data 00025 - (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err; 00026 00027 // Convenience method - pass it some deflated data, and you'll get inflated data back 00028 + (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err; 00029 00030 // Convenience method - pass it a file containing deflated data in sourcePath, and it will write inflated data to destinationPath 00031 + (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err; 00032 00033 // Sets up zlib to handle the inflating. You only need to call this yourself if you aren't using the convenience constructor 'decompressor' 00034 - (NSError *)setupStream; 00035 00036 // Tells zlib to clean up. You need to call this if you need to cancel inflating part way through 00037 // If inflating finishes or fails, this method will be called automatically 00038 - (NSError *)closeStream; 00039 00040 @property (assign, readonly) BOOL streamReady; 00041 @end