ASIDataDecompressor.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // ASIDataDecompressor.h
  3. // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
  4. //
  5. // Created by Ben Copsey on 17/08/2010.
  6. // Copyright 2010 All-Seeing Interactive. All rights reserved.
  7. //
  8. // This is a helper class used by ASIHTTPRequest to handle inflating (decompressing) data in memory and on disk
  9. // You may also find it helpful if you need to inflate data and files yourself - see the class methods below
  10. // Most of the zlib stuff is based on the sample code by Mark Adler available at http://zlib.net
  11. #import <Foundation/Foundation.h>
  12. #import <zlib.h>
  13. @interface ASIDataDecompressor : NSObject {
  14. BOOL streamReady;
  15. z_stream zStream;
  16. }
  17. // Convenience constructor will call setupStream for you
  18. + (id)decompressor;
  19. // Uncompress the passed chunk of data
  20. - (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err;
  21. // Convenience method - pass it some deflated data, and you'll get inflated data back
  22. + (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err;
  23. // Convenience method - pass it a file containing deflated data in sourcePath, and it will write inflated data to destinationPath
  24. + (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err;
  25. // Sets up zlib to handle the inflating. You only need to call this yourself if you aren't using the convenience constructor 'decompressor'
  26. - (NSError *)setupStream;
  27. // Tells zlib to clean up. You need to call this if you need to cancel inflating part way through
  28. // If inflating finishes or fails, this method will be called automatically
  29. - (NSError *)closeStream;
  30. @property (atomic, assign, readonly) BOOL streamReady;
  31. @end