Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:21:22+00:00 2026-06-13T06:21:22+00:00

I am using objective zip in a project to unzip and store files to

  • 0

I am using objective zip in a project to unzip and store files to documents directory. Its working fine with iOS 5.0 and below versions. Working fine with 5.1 Simulator. But when working on 5.1 device, only a few files are unzipped. Nothing else is shown in the folder. below is the code used for unzipping and storage.

for (NSString *file in fileArray) {

        // Get the file info/name, prepare the target name/path
        ZipReadStream *readStream = [unzipFile readCurrentFileInZip];
        FileInZipInfo *fileInfo = [unzipFile getCurrentFileInZipInfo];
        fileNameString = [NSString stringWithFormat:@"%@",[fileInfo name]];

        NSLog(@"fileNameString %@",fileNameString);

        NSString *DirName = [targetFolder stringByAppendingPathComponent:moduleName];
        NSLog(@"targetFolder %@",targetFolder);
        NSLog(@"DirName %@",DirName);

        NSLog(@"fileNameString %@",fileNameString);

        if (![fileManager fileExistsAtPath:DirName isDirectory:nil]) {
            [fileManager createDirectoryAtPath:DirName attributes:nil];
            NSLog(@"created directory %@", DirName);
        }

        NSLog(@"fileNameString %@",fileNameString);

        NSString *unzipFilePath = [DirName stringByAppendingPathComponent:fileNameString];

        NSLog(@"unzipFilePath-- %@",unzipFilePath);

        // Create a file handle for writing the unzipped file contents
        if (![fileManager fileExistsAtPath:unzipFilePath]) {

            NSString *dir = unzipFilePath;//[unzipFilePath stringByDeletingLastPathComponent];
            if ([[fileNameString pathExtension] isEqualToString:@""]) {
                [fileManager createDirectoryAtPath:dir attributes:nil];
                NSLog(@"created directory %@", dir);
            }
            [fileManager createFileAtPath:unzipFilePath contents:nil attributes:nil];
        }

        fileHandle = [NSFileHandle fileHandleForWritingAtPath:unzipFilePath];
        // Read-then-write buffered loop to conserve memory
        do {
            // Reset buffer length
            [unzipBuffer setLength:BUFFER_SIZE];
            // Expand next chunk of bytes
            int bytesRead = [readStream readDataWithBuffer:unzipBuffer];
            if (bytesRead > 0) {
                // Write what we have read
                [unzipBuffer setLength:bytesRead];
                [fileHandle writeData:unzipBuffer];
            } else
                break;
        } while (YES);

        [readStream finishedReading];

        // NOTE: Disable iCloud backup for unzipped file if applicable here!
        /*...*/


        //[fileHandle writeData:unZipped];

        [fileHandle closeFile];

        [unzipFile goToNextFileInZip];
    }

    [unzipFile close]; // Be sure to also manage your memory manually if not using ARC!

    // Also delete the zip file here to conserve disk space if applicable!
    [recievedData release];

    NSLog(@"Delete -- %@", documentsDirectory);
    [fileManager removeItemAtPath:documentsDirectory error:nil];

    return YES;

}

Please help ! ! !

thanks in Advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:21:23+00:00Added an answer on June 13, 2026 at 6:21 am

    Use have the following method for unzipping a zip file using Objective-zip. This works fine under iOS 4.3 through 6.0 (and probably earlier and later too). The ‘filename’ parameter is the full path to the zip file.

    - (BOOL)unzipPath:(NSString *)filename toDirectory:(NSString *)directory error:(NSError **)error {
        if (error) {
            *error = nil;
        }
    
        ZipFile *unzipFile = [[ZipFile alloc] initWithFileName:filename mode:ZipFileModeUnzip];
        int cnt = [unzipFile numFilesInZip];
        [unzipFile goToFirstFileInZip];
        for (int i = 0; i < cnt; i++) {
            FileInZipInfo *info = [unzipFile getCurrentFileInZipInfo];
            NSString *name = info.name;
            if (![name hasSuffix:@"/"]) {
                NSString *filePath = [directory stringByAppendingPathComponent:name];
                NSString *basePath = [filePath stringByDeletingLastPathComponent];
                if (![[NSFileManager defaultManager] createDirectoryAtPath:basePath withIntermediateDirectories:YES attributes:nil error:error]) {
                    [unzipFile close];
    
                    return NO;
                }
    
                [[NSData data] writeToFile:filePath options:0 error:nil];
    
                NSFileHandle *handle = [NSFileHandle fileHandleForWritingAtPath:filePath];
                ZipReadStream *read = [unzipFile readCurrentFileInZip];
                NSUInteger count;
                NSMutableData *data = [NSMutableData dataWithLength:2048];
                while ((count = [read readDataWithBuffer:data])) {
                    data.length = count;
                    [handle writeData:data];
                    data.length = 2048;
                }
                [read finishedReading];
                [handle closeFile];
            }
    
            [unzipFile goToNextFileInZip];
        }
    
        [unzipFile close];
    
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working on an ios app using objective c and i have an issue
I have been using objective-C to develop in iOS. Now we want to develop
I want to create a .zip file using Objective-C. Is there is any method
i am using objective-c to develop ios applications i found in the documentations that
I am working on an OSX application using Objective-C, and one of the things
I'm working on an iPhone app using objective C. I've got class A, which
I have created a screen using Objective-C in an iPhone project. In that, there
I am using a library called objective zip to extract a file. the relevant
I'm learning about basic manipulation of UIImage s using Objective-C on iOS. Say I
I'm working on a roguelike using Objective-C/Cocoa to learn more. I've gotten most of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.