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-01-2009, 02:27 PM   #18 (permalink)
skinnytron
New Member
 
Join Date: Jul 2008
Posts: 69
Default

I am trying to download a remote zip file and unzip and open the file.

Here's my code:
Code:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
	NSFileManager *fileManager = [NSFileManager defaultManager];
	NSString *filePath = [NSString stringWithFormat:@"%@/myfile.txt.gz", [Utility getDocumentsPath]];
	[fileManager createFileAtPath:filePath contents:reportData attributes:nil];
	
	if([fileManager fileExistsAtPath:filePath]) {
		NSLog(@"File exists at path: %@", filePath);
	} else {
		NSLog(@"File does not exists at path: %@", filePath);
	}
	
	ZipArchive *zipArchive = [[ZipArchive alloc] init];
	if([zipArchive UnzipOpenFile:filePath]) {
		NSLog(@"Archive Open Success");
	} else  {
		NSLog(@"Failure To Open Archive");
	}
}
Which produces the following output:
2009-04-01 11:17:29.334 myApp[1042:20b] File exists at path: /Users/myname/Library/Application Support/iPhone Simulator/User/Applications/F0DC6BBC-46E7-4067-A399-00DA94FE1EBA/Documents/myfile.txt.gz
2009-04-01 11:17:29.335 myApp[1042:20b] Failure To Open Archive

If I manually go into the apps document directory (in os x) where the file is downloaded to I can unpack it without any problems.

Also if I download myfile.txt.gz using safari, place the file in applications documents directory and comment out the createFileAtPath statement it unpacks fine.

What am I doing wrong? Is there any way to get any debuging information out of zipArchive?
skinnytron is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,862
Threads: 89,223
Posts: 380,685
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:40 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.