[tcobrowser-cvs] SF.net SVN: tcobrowser: [656] trunk/bibdesk/vendorsrc/amaxwell/FileView
Status: Beta
Brought to you by:
amaxwell
From: <ama...@us...> - 2008-03-31 20:29:49
|
Revision: 656 http://tcobrowser.svn.sourceforge.net/tcobrowser/?rev=656&view=rev Author: amaxwell Date: 2008-03-31 13:29:55 -0700 (Mon, 31 Mar 2008) Log Message: ----------- get rid of NSData category Modified Paths: -------------- trunk/bibdesk/vendorsrc/amaxwell/FileView/FVUtilities.h trunk/bibdesk/vendorsrc/amaxwell/FileView/FVUtilities.m Modified: trunk/bibdesk/vendorsrc/amaxwell/FileView/FVUtilities.h =================================================================== --- trunk/bibdesk/vendorsrc/amaxwell/FileView/FVUtilities.h 2008-03-31 18:13:38 UTC (rev 655) +++ trunk/bibdesk/vendorsrc/amaxwell/FileView/FVUtilities.h 2008-03-31 20:29:55 UTC (rev 656) @@ -61,10 +61,3 @@ @interface NSBezierPath (RoundRect) + (NSBezierPath*)fv_bezierPathWithRoundRect:(NSRect)rect xRadius:(CGFloat)xRadius yRadius:(CGFloat)yRadius; @end - -@interface NSData (FVZip) - -- (NSData *)fv_zlibCompress; -- (NSData *)fv_zlibDecompress; - -@end Modified: trunk/bibdesk/vendorsrc/amaxwell/FileView/FVUtilities.m =================================================================== --- trunk/bibdesk/vendorsrc/amaxwell/FileView/FVUtilities.m 2008-03-31 18:13:38 UTC (rev 655) +++ trunk/bibdesk/vendorsrc/amaxwell/FileView/FVUtilities.m 2008-03-31 20:29:55 UTC (rev 656) @@ -368,98 +368,3 @@ } @end - -@implementation NSData (FVZip) - -// -// implementation modified after http://www.cocoadev.com/index.pl?NSDataCategory -// - -- (NSData *)fv_zlibDecompress -{ - if ([self length] == 0) return [[self retain] autorelease]; - - unsigned full_length = [self length]; - unsigned half_length = [self length] / 2; - - NSMutableData *decompressed = [NSMutableData dataWithLength: full_length + half_length]; - BOOL done = NO; - int status; - - z_stream strm; - strm.next_in = (Bytef *)[self bytes]; - strm.avail_in = [self length]; - strm.total_out = 0; - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - - if (inflateInit (&strm) != Z_OK) return nil; - - while (!done) - { - // Make sure we have enough room and reset the lengths. - if (strm.total_out >= [decompressed length]) - [decompressed increaseLengthBy: half_length]; - strm.next_out = (Bytef *)[decompressed mutableBytes] + strm.total_out; - strm.avail_out = [decompressed length] - strm.total_out; - - // Inflate another chunk. - status = inflate (&strm, Z_SYNC_FLUSH); - if (status == Z_STREAM_END) done = YES; - else if (status != Z_OK) break; - } - if (inflateEnd (&strm) != Z_OK) return nil; - - // Set real length. - if (done) - { - [decompressed setLength: strm.total_out]; - return decompressed; - } - else return nil; -} - -- (NSData *)fv_zlibCompress -{ - if ([self length] == 0) return [[self retain] autorelease]; - - z_stream strm; - - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - strm.total_out = 0; - strm.next_in=(Bytef *)[self bytes]; - strm.avail_in = [self length]; - - // Compresssion Levels: - // Z_NO_COMPRESSION - // Z_BEST_SPEED - // Z_BEST_COMPRESSION - // Z_DEFAULT_COMPRESSION - - if (deflateInit(&strm, Z_BEST_SPEED) != Z_OK) return nil; - - // preallocate a fairly large data instance to avoid calling increaseLength: too frequently and blocking on malloc - NSMutableData *compressed = [NSMutableData dataWithLength:([self length] * 0.8)]; - - do { - - if (strm.total_out >= [compressed length]) - [compressed increaseLengthBy: 16384]; // 16K chunks for expansion - - strm.next_out = (Bytef *)[compressed mutableBytes] + strm.total_out; - strm.avail_out = [compressed length] - strm.total_out; - - deflate(&strm, Z_FINISH); - - } while (strm.avail_out == 0); - - deflateEnd(&strm); - - [compressed setLength: strm.total_out]; - return compressed; -} - -@end - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |