tags:

views:

5

answers:

0

this code allows you to unzip file and create a folder in documents lets say List and this List folder is having all the unzip data now how to access that List content??

     NSArray *paths = 
     NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

     NSString *documentsDirectory = [paths objectAtIndex:0];

     NSString *saveLocation = 
     [documentsDirectory stringByAppendingString:@"myfile.zip"];

     NSFileManager* fileManager = [NSFileManager defaultManager];

     if ([fileManager fileExistsAtPath:saveLocation]) {
         [fileManager removeItemAtPath:saveLocation error:nil];
         NSLog(@" file path %@",fileManager);
     }

     NSURLRequest *theRequest = 
     [NSURLRequest requestWithURL:
      [NSURL URLWithString:@"http://localhost/list.zip"]
                      cachePolicy:NSURLRequestUseProtocolCachePolicy
                  timeoutInterval:60.0];    

     NSData *received = 
     [NSURLConnection sendSynchronousRequest:theRequest
                           returningResponse:nil error:nil];    

     if ([received writeToFile:saveLocation atomically:TRUE]) {      
         NSString *cmd = 
         [NSString stringWithFormat:@"unzip \"%@\" -d\"%@\"", 
          saveLocation, documentsDirectory];       

         // Here comes the magic...
         system([cmd UTF8String]);       
     }


     NSLog(@"loca is %@", saveLocation);


      NSLog(@"%@", [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil]);  // i can see list folder but how to get the content outside??