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?