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 12-29-2008, 02:56 PM   #8 (permalink)
lbendlin
Registered Member
 
Join Date: Dec 2008
Posts: 429
Default

For what it's worth, here is the code to unpack the physical zip file into a NSData structure. Caveat: will only work correctly if the ZIP contains one file.

Code:
-(NSData*) UnzipFileToData {
	NSMutableData* data = [[NSMutableData alloc] init];
	int ret = unzGoToFirstFile( _unzFile );
	unsigned char		buffer[4096] = {0};
	if( ret!=UNZ_OK )
	{
		[self OutputErrorMessage:@"Failed to go to first file"];
		return data;
	}
	
	ret = unzOpenCurrentFile( _unzFile );
	if( ret!=UNZ_OK )
	{
		[self OutputErrorMessage:@"Error opening file"];
		return data;
	}
	// reading data and write to data object
	int read = 1 ;
	while( read > 0 )
	{
		read=unzReadCurrentFile(_unzFile, buffer, 4096);
		if( read > 0 )
		{
			[data appendBytes:buffer length:read];
		}
		else if( read<0 )
		{
			[self OutputErrorMessage:@"Failed to reading zip file"];
			break;
		}
		else 
			break;				
	}
	unzCloseCurrentFile( _unzFile );
	ret = unzGoToNextFile( _unzFile );
	return data;
}
lbendlin is offline   Reply With Quote
 

» Advertisements
» Online Users: 636
15 members and 621 guests
aijo, alphy, apatsufas, brianmethod, ckgni, Dani77, devangvyas, Domele, drewrico, handmachine, hiddendemo, JamesCahall, mistergreen2011, Oral B, rrlemoine
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,786
Threads: 89,205
Posts: 380,601
Top Poster: BrianSlick (7,129)
Welcome to our newest member, lilianprice
Powered by vBadvanced CMPS v3.1.0

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