Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-02-2009, 02:17 PM   #21 (permalink)
skinnytron
New Member
 
Join Date: Jul 2008
Posts: 69
Default

Here is quick easy solution to unzip a gzip file into memory using zlib.

Code:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
	NSString *sourcePath = [NSString stringWithFormat:@"%@/myFile.txt.gz", [Utility getDocumentsPath]];
	
	NSFileManager *fileManager = [NSFileManager defaultManager];
	[fileManager createFileAtPath:sourcePath contents:data attributes:nil];
	
	gzFile file = gzopen([sourcePath UTF8String], "rb");
	
	unsigned char buffer[CHUNK];
	
	int uncompressedLength = gzread(file, buffer, CHUNK);
	
	NSData *uncompressedData = [NSData dataWithBytes:buffer length:uncompressedLength];
	NSString *txtFile = [[NSString alloc] initWithData:uncompressedData encoding:NSASCIIStringEncoding];

	gzclose(file);
	[fileManager removeItemAtPath:sourcePath error:nil];
}
skinnytron is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,862
Threads: 89,223
Posts: 380,684
Top Poster: BrianSlick (7,129)
Welcome to our newest member, higgey
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:36 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.