GithubHelp home page GithubHelp logo

ziparchive's People

Watchers

James Cloos avatar

ziparchive's Issues

Memory leak in unzip.c of minizip.

Although I know minizip is not your project I am sharing this issue at your 
page, since zipArchive uses minizip as its engine to unzip the files. I am 
attaching a screenshot of the memory leak as shown at the Instruments of Xcode. 
Please verify or not. Thank you. 

Sincerely,
Alex 

Original issue reported on code.google.com by [email protected] on 21 Aug 2010 at 12:37

Attachments:

UnzipOpenFile always failed

Hi,

I am developing a phonegap plugin which download a zip file and unzip it.
But when I try to open the downloaded zip file by "UnzipOpenFile", it always 
fails to open it.
Can somebody help me?

Thank you in advance.



Original issue reported on code.google.com by [email protected] on 12 Apr 2012 at 6:50

Creating a zip file with a password crashes tha pp

What steps will reproduce the problem?
1. Call CreateZipFile2:Password:
2. Call addFileToZip:newname:
3. See bad access crash

What is the expected output? What do you see instead?
I am expecting to be able to add files to the zip archive without it crashing.

What version of the product are you using? On what operating system?
The latest, on the iPhone 4 using iOS4.1

Please provide any additional information below.

The problem is that you are not retaining the password that is being set. So 
when _password is trying to be read later it crashes. Make password a property 
that you retain and release and it works.

Original issue reported on code.google.com by [email protected] on 16 Sep 2010 at 4:37

error in selectors calls

What steps will reproduce the problem?

simply placea brakpoint on selectors / add NSLog

What is the expected output? What do you see instead?
selectors are never called.



    if( _delegate && [_delegate respondsToSelector:@selector(ErrorMessage)] )
        [_delegate ErrorMessage:msg];



    if( _delegate && [_delegate respondsToSelector:@selector(OverWriteOperation)] )
        return [_delegate OverWriteOperation:file];


You missed a semicolon, so selector are never called.

it must be:



    if( _delegate && [_delegate respondsToSelector:@selector(ErrorMessage:)] )
        [_delegate ErrorMessage:msg];



    if( _delegate && [_delegate respondsToSelector:@selector(OverWriteOperation:)] )
        return [_delegate OverWriteOperation:file];

I added a semicolon and it works VERY nice.

Hope this can help.


Original issue reported on code.google.com by [email protected] on 25 Aug 2010 at 5:38

Memory footprint issues when unzipping large archives

When unzipping large archives, the footprint of -[ZipArchive 
UnzipFileTo:overwrite:] can become very large, because there are autoreleased 
objects created for each individual file during the unzip.  These don't get 
released until after the call returns, when the autorelease pool is next 
drained.

To fix the problem, add another pool inside the do{}while in -[ZipArchive 
UnzipFileTo:overwrite:] :



    do{
        NSAutoreleasePool *internalPool = [[NSAutoreleasePool alloc] init];

        if( [_password length]==0 )
...
        ret = unzGoToNextFile( _unzFile );

        [internalPool drain];
    }while( ret==UNZ_OK && UNZ_OK!=UNZ_END_OF_LIST_OF_FILE );

Original issue reported on code.google.com by [email protected] on 14 Feb 2011 at 3:40

If ZipArchive had some limit of the size of the package and the number of the package when unzipping?

What steps will reproduce the problem?
1.  I downloaded a package which named "*.zip" from server.
2.  When the package is less than 2G, the library worked well.
3.  but when the file size is bigger than 2G, the library can't open the 
package.  The function "UnzipOpenFile" return false instead. I'm not sure if 
the library has some limit of the size of the file or the number of the file.

What is the expected output? What do you see instead?

I thought it war the library's error, If there is something I can do to unzip 
my package easily. Or it‘s just my fault of my code in some place caused the 
error?

What version of the product are you using? On what operating system?
I am using version 1.2 of ZipArchive on iPad.

Please provide any additional information below.

This is my function:

-(void)unzipFile
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString  * docpaths= [[NSString alloc] initWithFormat:@"%@",[paths objectAtIndex:0]];
    unzipPath = [docpaths stringByAppendingPathComponent:@""];
    NSLog(@"%@",unzipPath);
    ZipArchive * unzip = [[ZipArchive alloc]init];
    if ([unzip UnzipOpenFile:downloadPath]) {
        BOOL result = [unzip UnzipFileTo:unzipPath overWrite:YES];
        if (result) {
            NSLog(@"解压成功");
            [self deleteFile];
        }else{
            NSLog(@"解压失败");
            UIAlertView * alertView = [[UIAlertView alloc]initWithTitle:@"解压失败" message:@"磁盘空间不足,请保留足够空间重新解压" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
            alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
            [alertView setTag:1];
            [alertView show];
            [alertView release];
        }
        [unzip UnzipCloseFile];
    }
    [docpaths release];
    [unzip release];    
}

    I'm sure the path is correctly, and I search the answers on stackoverflow, google, and some BBS, but I couldn't find my answer of the question. So I'm here to ask if you had the answer.
    At last, I must apologize for my poor English. If my words made you difficult to understand, I must say "I'm sorry". Thank you!

Original issue reported on code.google.com by [email protected] on 4 Jan 2014 at 2:53

Compile ziparchive on a static library in an iPhone project

This is not an issue, just letting you know of my experience in compiling the 
software as a static 
library.

What steps will reproduce the problem?
1. Generate a static library project with Xcode 
2. Include all the files of the ZipArchive Project.
3. Build the static library, everything is ok.
4. Include the static library project as a reference in another iPhone 
application project.
5. Build the application project. 

What is the expected output? What do you see instead?

When compiling, there is a  undefined reference to `__gxx_personality_v0' error.
Did some research on this, and found the answer at http://www.network-
theory.co.uk/docs/gccintro/gccintro_54.html. Seems that Xcode does not use g++ 
instead of 
gcc to compile the source. Don't know why everything without modifications 
works when trying 
to compile ZipArchive as a standalone project.

To compile it as a static library, all it takes is to change the extension of 
ZipArchive.mm from 
.mm to .m.

What version of the product are you using? On what operating system?
Mac OS X 10.6, Xcode 3.2

I am attaching a sample Xcode project to compile ZipArchive as a static library.
Thanks for this useful software!


Original issue reported on code.google.com by [email protected] on 1 Mar 2010 at 6:38

Attachments:

unable to unzip zipped file when supplying password at zip creation

What steps will reproduce the problem?
1. [zip CreateZipFile2:zipFilePath Password:zipPassword] 
2. drag created zip to Desktop 
3. double click to unzip

What is the expected output? What do you see instead?

I would expect to be prompted to enter a password to unzip the file, however I 
receive an error message "Error 1 operation not permitted"

What version of the product are you using? On what operating system?
ZipArchive version 1.2 just downloaed from this site.
Mac OSX Snow Leopard

Please provide any additional information below.

If the line: [zip CreateZipFile2:zipFilePath Password:zipPassword]  is run when 
zipPassword is nil I can drag the zip file to desktop and unzip with error so 
the password is the issue


Original issue reported on code.google.com by [email protected] on 5 Jan 2012 at 7:11

ZIP folder addition

I needed to zip an entire folder tree...


// 2010-12-22, Michael Burford ([email protected])
// "pathPrefix" should be nil or @"" the first call; lets the recursive calls 
store in subfolders in the zip file.
-(NSInteger) addFolderToZip:(NSString*)path pathPrefix:(NSString*)prefix {
    NSInteger   fileCount = 0;
    NSArray     *dirArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];

    for (int i=0; i<[dirArray count]; i++) {
        NSString        *dirItem = [dirArray objectAtIndex:i];
        NSDictionary    *dict = [[NSFileManager defaultManager] attributesOfItemAtPath:[path stringByAppendingPathComponent:dirItem] error:nil];

        if ([[dict fileType] isEqualToString:NSFileTypeDirectory] || [[dict fileType] isEqualToString:NSFileTypeSymbolicLink]) { 
            //Recursively do subfolders.
            fileCount += [self addFolderToZip:[path stringByAppendingPathComponent:dirItem] pathPrefix:([prefix length]>0 ? [prefix stringByAppendingPathComponent:dirItem] : dirItem)];
        } else {
            //Count if added OK.
            if ([self addFileToZip:[path stringByAppendingPathComponent:dirItem] newname:([prefix length]>0 ? [prefix stringByAppendingPathComponent:dirItem] : dirItem)]) {
                fileCount++;
            }
        }
    }
    return fileCount;
}

Original issue reported on code.google.com by [email protected] on 22 Dec 2010 at 8:46

ARC compliance, analyzer warnings, code semantics, etc.

This code is not ARC compliant, contains memory leaks, throws dozens of 
warnings to the analyzer, has many semantic flaws, etc.

It is dated beyond being useful without a fair amount of effort with current 
versions of iOS, XCode and the latest of Apple's best practices for new 
projects.

Are you interested in receiving some help in getting it up to date to match the 
current state of things? Is work being done to do so? Is the project dead?

I have been working on changing it so that I have a workable version for a new 
project, but it is proving to be a fair amount of work, and there are several 
sections in the code where I don't understand the details of what I am changing 
well enough to be doing any better than coding by coincidence. That makes me 
nervous. However, I would be happy to be part of an official effort to get this 
code up to date.


Original issue reported on code.google.com by [email protected] on 5 Jul 2013 at 7:12

stringWithCString deprecated

If you compile, you will get a warning about the line in ZipArchive.mm:

NSString * strPath = [NSString  stringWithCString:filename];

To fix it, just change it to include the encoding:


NSString * strPath = [NSString  stringWithCString:filename 
encoding:NSASCIIStringEncoding];

Original issue reported on code.google.com by [email protected] on 22 Jun 2010 at 1:53

Problems trying to add the libz.1.2.3.dylib

What steps will reproduce the problem?
1. Create a project.
2. Add the ZipArchive folder with their files.
3. Add the libz.1.2.3.dylib

What is the expected output? What do you see instead?
I have all the code (about ziparchive) commented, so i only have the #import 
"ZipArchive/ZipArchive.h" in my viewcontroller, and i expect to build the 
project without errors.

I see the following error in the compiler:

ld: warning: ignoring file 
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2/Symbols/usr/lib/libSyst
em.dylib, missing required architecture i386 in file
ld: in 
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2/Symbols/usr/lib/libobjc
.A.dylib, missing required architecture i386 in file for architecture i386
collect2: ld returned 1 exit status
Command 
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 
failed with exit code 1


What version of the product are you using? On what operating system?
I'm using xcode 4 a project for the ipad with the 4.2 ipad simulator on a Mac 
os X version 10.6.7

Please provide any additional information below.
I think the problem is with the libz.1.2.3.dylib library, and I have some guest 
of where might be the problem:

1. The libz.1.2.3.dylib path error is on iPhoneSimulator.platform, it is valid 
for ipad too?? If is not, which lib could i use for the same purpose with the 
ipad??

2. I'm not sure i'm adding the libz.1.2.3.dylib lib correctly. What I have done 
is: right-click on Resources folder -> add files to "myproject" -> search for 
the libz.1.2.3.dylib and add the 4.2 version of it from the path u could see in 
the compiler errors. I also try to add to the frameworks folder with the same 
results.

I'm reading lots of posts about how to fix similar problems but no one could 
help me.

Any idea of what I have to do to fix my problem?? I imagine is the path but 
dont know which lib i could use then for the ipad.

Really thanks

Original issue reported on code.google.com by [email protected] on 14 Apr 2011 at 11:33

not able to unzip files zipped with pkzip on mac

What steps will reproduce the problem?
1. zip a folder using pkzip encoding.
2. Try to unzip using ziparchive it will unzip files with all files inside 
folder of zero bytes.
3. While if we unzip on wimdows,mac and android it unzips succesfully.

What is the expected output? What do you see instead?
Expected output:- Should inzip succesfully.
Current output:-Data error while inflate is called.err=-3.


What version of the product are you using? On what operating system?
latest versio  with ios 7.


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 1 Apr 2014 at 3:14

Error Handling Issue

Hi,

When I am using your library in my project and I received some security flaws 
in Veracode scan report related to error handling.

Class Name: zip.c
Line Number: 777
Code: zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader);

Here we are allocating object and used it without checking whether memory is 
properly allocated or not.
Please suggest me the proper solution of the issue.

Thanks in advance.

Original issue reported on code.google.com by [email protected] on 7 Apr 2015 at 12:11

ZIPX

What steps will reproduce the problem?
1. Pass the filename including "zipx" extension to UnzipOpenFile.
2. It just wont unzip it with no error.
3.

What is the expected output? What do you see instead?
I expect it to be able to unzip the "zipx".

What version of the product are you using? On what operating system?
MAC Leopard with XCode

Please provide any additional information below.
I believe this ziparchive does not support "zipx".  It needs to be mentioned on 
project home page. Otherwise, please let me know what I did wrong.

Original issue reported on code.google.com by [email protected] on 25 Aug 2010 at 4:15

No idea on changing creation time of extracted files.

I still didn't find the way to change creation time of file on iPhone,
because the key 'NSCreationDate' is not valid for iPhone, but ok for
desktop OSX. If anyone knows how to modify the creation datetime, please
let me know. thanks.

Original issue reported on code.google.com by [email protected] on 6 Feb 2009 at 1:17

Insufficient Entropy (CWE ID 331)

Hi,

When I am using your lib (code) in my project and preform VeraCode scan for 
security testing then found many flaws. One of the common flaw is "Insufficient 
Entropy (CWE ID 331)".

This flaw comes in class: crypt.h on line no: 113 and 118.

Code is below:

    if (++calls == 1)
    {
        srand((unsigned)(time(NULL) ^ ZCR_SEED2));
    }
    init_keys(passwd, pkeys, pcrc_32_tab);
    for (n = 0; n < RAND_HEAD_LEN-2; n++)
    {
        c = (rand() >> 7) & 0xff;
        header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
    }


Please update me if any resolution is available for security flaws or suggest 
me if any correction is required.

Thanks in Advance.

Original issue reported on code.google.com by [email protected] on 7 Apr 2015 at 11:16

License terms?

This is great software.  Thank you for writing it.  

I noticed that the project site (https://code.google.com/p/ziparchive) says the 
software is available under the MIT License, but when I download the source I 
don't see the MIT license mentioned in the source code or a LICENSE.txt file or 
anything along those lines.

The files ZipArchive.h and ZipArchive.mm contain:
//
//  ZipArchive.mm
//  
//
//  Created by aish on 08-9-11.
//  [email protected]
//  Copyright 2008  Inc. All rights reserved.
//

and the files in the minizip/ directory are marked as being made available 
under the zLib license.  

Can you confirm that ZipArchive.h and ZipArchive.mm are being published here 
under the MIT License?

Thank you!

Original issue reported on code.google.com by [email protected] on 3 Dec 2014 at 4:24

@property (nonatomic, retain) id delegate???????

//
//  ZipArchive.h
//  
//
//  Created by aish on 08-9-11.
//  [email protected]
//  Copyright 2008  Inc. All rights reserved.
//
// History: 
//    09-11-2008 version 1.0    release
//    10-18-2009 version 1.1    support password protected zip files
//    10-21-2009 version 1.2    fix date bug

.....................
@interface ZipArchive : NSObject {
.................
@property (nonatomic, retain) id delegate;

...................
@end

You retained delegate???????????? Are you continuing to develop this framework?

Original issue reported on code.google.com by ngtviethung on 11 Jul 2013 at 4:04

Number of Files Limited in ZIP file

What steps will reproduce the problem?
1. I have a ZIP file which includes 140K small txt files. (ZIP file is 40MB)
2. I try to extract them in ApplicationDidFinishLaunching.
3. In the log it says: "8386 entries in the zip file"

What is the expected output? What do you see instead?
I get a list of files in the directory and it seems only 8K is there. So 
library sees only the 8K of them.

What version of the product are you using? On what operating system?
Xcode 3.2.2 on Mac OS X for iPhone Development

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 5 Jan 2011 at 2:38

Deprecated warning for attributesOfItemAtPath

in ZipArchive.mm, the following gives a deprecated warning:

    NSDictionary* attr = [[NSFileManager defaultManager] fileAttributesAtPath:file traverseLink:YES];


to fix it, change the code to:

    NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[file stringByResolvingSymlinksInPath] error:nil];

Original issue reported on code.google.com by [email protected] on 14 Jul 2010 at 11:39

Zip a folder 2 Gb on Ipad crash the app (Problem Memory)

What steps will reproduce the problem?
1. Zip a big folder (2 Gb) function AddFolder
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?

The version for Xamarin 1.0.0.1


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 9 Dec 2014 at 11:42

Wiki page is badly mangled

What steps will reproduce the problem?
1. view http://code.google.com/p/ziparchive/wiki/PageName


consider bracketing code samples with {{{
}}} so it isn't mangled by the wiki formatter.


Original issue reported on code.google.com by [email protected] on 2 May 2009 at 5:13

Unzip error

When i download a file from server, after 100 % downloading,is unable to unzip 
the file.
For second attempt is successfully unzip the file.
Is any one have solution for that.


Original issue reported on code.google.com by [email protected] on 24 Apr 2011 at 6:09

Unzip cannot handle unicode filenames

What steps will reproduce the problem?
1. Create a zip with file called 'чух0334.png' in it
2. Unzip the archive using ZipArchive
3. It would unzip successfully but the files name would be changed to strange 
looking characters

What is the expected output? What do you see instead?
Name of the file should 'чух0334.png'


What version of the product are you using? On what operating system?
Name of the file is not 'чух0334.png'

Original issue reported on code.google.com by [email protected] on 10 Feb 2012 at 1:51

If folder is empty the folder is not added in the zip file

What steps will reproduce the problem?
1.Have a folder Structure like A(Folder1)->B(Folder 2(Empty))
2. Now zip Folder A
3. Unzip Folder A

Notice the Folder A is empty as there are no files in Folder B.

What is the expected output? What do you see instead?
Folder A and Folder B should be zipped.



What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 17 Dec 2013 at 4:45

Zip Error

Hi,

I am trying to create a zip file using your class. It does create a zip file, 
however double clicking 
will just cause another zip file with a cpgz ending to be created. So if I 
double click Example.zip, 
Example.zip.cpgz will be created. If I double click that Example 1.zip will be 
created, its just 
looping. Why is this?

this is the code I am using:

    ZipArchive*archive = [[ZipArchive alloc] init]; 
    [archive addFileToZip:[self fileName] newname:[docwindow title]];
    [archive CloseZipFile2];        
    [archive CreateZipFile2:@"/Users/David/Desktop/Archive.zip"];   
    //my error handler
    if( ![archive CloseZipFile2] )
    {
        NSLog(@"Error while attemtping to ZIP file.");
    }       
    [archive release];  

Original issue reported on code.google.com by [email protected] on 22 Apr 2010 at 6:37

ARC, compiler warnings, minor bug fixes, and documentation

I've put a fork to ZipArchive on github which addresses the following issues:

1. Support both ARC and non-ARC.

2. Upgrade Minizip from 1.01e to 1.01h.

3. Replace deprecated methods.

4. Made a couple of minor code corrections to remedy unnecessary compiler 
warnings that were generated when using Xcode 5.

5. Documented code.

6. Minor corrections.

See https://github.com/robertmryan/ZipArchive. I'm happy to integrate these as 
a commit to this project here if you want. Let me know.

Original issue reported on code.google.com by [email protected] on 21 Oct 2013 at 7:57

minizip - zip.c Value stored to 'err' is never read, unzip.c Value stored to 'lSeek' is never read and Value stored to 'err' is never read

What steps will reproduce the problem?

- Fix the warnings, fixes shown from searching here.
- Run analyser on the latest release of ArchiveZip using xcode 4.2.

What is the expected output? What do you see instead?

Value stored to 'err' is never read
Value stored to 'lSeek' is never read
Value stored to 'lSeek' is never read
Value stored to 'err' is never read

What version of the product are you using? On what operating system?

0.7.3 on Snow Leopard


Original issue reported on code.google.com by [email protected] on 30 Nov 2011 at 8:07

unzip file bigger than 20MB will crash the app on iphone 3G


1. i download a zip file to an external server
2. when executing the code to unzip it crashes
3. i can tell it crashes because even when i perform the unzip process on a 
separate thread the app wont respond making the iphone reboot by itself after 
10 seconds.


I know if I try to download multiple smaller zip file rather than one big file 
will solve the issue. but i would like to know if there is any possible 
solution for this so i dont have to change the architecture of downloadable 
packages in my app.

Thanks... 

Original issue reported on code.google.com by [email protected] on 23 Aug 2010 at 2:57

  • Merged into: #18

Adding large filles problem

1. On some devices (iPad in my case) trying to add a large file in 
     -(BOOL) addFileToZip:(NSString*) file newname:(NSString*) newname;
     will crash the app because the method
     [NSData dataWithContentsOfFile:] 
     will use up all the memory.

I fixed the issue for my particular problem with zip files that have no 
password by changing the addFileToZip method a bit. You might want to take a 
look at it and change it universally... Also there is no internal autorelease 
pool needed when adding multiple files.

The methode:

#define M_FRAGMENT_SIZE 10000000
-(BOOL) addFileToZip:(NSString*) file newname:(NSString*) newname;
{
    if( !_zipFile )
        return NO;

//  tm_zip filetime;
    time_t current;
    time( &current );

    zip_fileinfo zipInfo = {0};
//  zipInfo.dosDate = (unsigned long) current;

    NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:file error:nil];
    if( attr )
    {
        NSDate* fileDate = (NSDate*)[attr objectForKey:NSFileModificationDate];
        if( fileDate )
        {
            // some application does use dosDate, but tmz_date instead
        //  zipInfo.dosDate = [fileDate timeIntervalSinceDate:[self Date1980] ];
            NSCalendar* currCalendar = [NSCalendar currentCalendar];
            uint flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | 
                NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit ;
            NSDateComponents* dc = [currCalendar components:flags fromDate:fileDate];
            zipInfo.tmz_date.tm_sec = [dc second];
            zipInfo.tmz_date.tm_min = [dc minute];
            zipInfo.tmz_date.tm_hour = [dc hour];
            zipInfo.tmz_date.tm_mday = [dc day];
            zipInfo.tmz_date.tm_mon = [dc month] - 1;
            zipInfo.tmz_date.tm_year = [dc year];
        }
    }

    int ret ;
    NSData* data = nil;
    if( [_password length] == 0 )
    {
        ret = zipOpenNewFileInZip( _zipFile,
                                  (const char*) [newname UTF8String],
                                  &zipInfo,
                                  NULL,0,
                                  NULL,0,
                                  NULL,//comment
                                  Z_DEFLATED,
                                  Z_DEFAULT_COMPRESSION );
    }
    else
    {
        FILE *f = fopen([file cStringUsingEncoding:NSUTF8StringEncoding], "r");
        fseek(f, 0, SEEK_END);
        long fLenght = ftell(f);
        void *fBuffer = malloc(fLenght);
        fread(fBuffer, 1, fLenght, f);
        fclose(f);
        data = [[NSData alloc] initWithBytesNoCopy:fBuffer length:fLenght];
        uLong crcValue = crc32( 0L,NULL, 0L );
        crcValue = crc32( crcValue, (const Bytef*)[data bytes], [data length] );
        ret = zipOpenNewFileInZip3( _zipFile,
                                  (const char*) [newname UTF8String],
                                  &zipInfo,
                                  NULL,0,
                                  NULL,0,
                                  NULL,//comment
                                  Z_DEFLATED,
                                  Z_DEFAULT_COMPRESSION,
                                  0,
                                  15,
                                  8,
                                  Z_DEFAULT_STRATEGY,
                                  [_password cStringUsingEncoding:NSASCIIStringEncoding],
                                  crcValue );
    }
    if( ret!=Z_OK )
    {
        [data release];
        return NO;
    }

// M_FRAGMENT_SIZE 10000000 (10MB)
    FILE *f = fopen([file cStringUsingEncoding:NSUTF8StringEncoding], "r");
    if(!f)
        return NO;

    fseek(f, 0, SEEK_END);
    long fLenght = ftell(f);
    rewind(f);
    void *fBuffer = malloc(M_FRAGMENT_SIZE);

    for (;fLenght > M_FRAGMENT_SIZE; fLenght-=M_FRAGMENT_SIZE) {        
        fread(fBuffer, 1, M_FRAGMENT_SIZE, f);
        ret = zipWriteInFileInZip( _zipFile, (const void*)fBuffer, M_FRAGMENT_SIZE);
    }   
    if(fLenght) {
        fread(fBuffer, 1, fLenght, f);
        ret = zipWriteInFileInZip( _zipFile, (const void*)fBuffer, fLenght);
        if( ret!=Z_OK )
        {
            free(fBuffer);
            fclose(f);
            return NO;
        }
    }
    free(fBuffer);
    fclose(f);

    if( ret!=Z_OK )
    {
        return NO;
    }
    ret = zipCloseFileInZip( _zipFile );
    if( ret!=Z_OK )
        return NO;
    return YES;
}

Now the memory consumption is restricted by M_FRAGMENT_SIZE in bytes, currently 
10MB and it seems to work great...



Original issue reported on code.google.com by [email protected] on 21 Apr 2011 at 10:02

Archiving and Unarchiving Directories

What steps will reproduce the problem?
1. Place a directory in the zip file.
2. Close the zip file and write it.
3. Open the zip file where you wrote it.

What is the expected output? What do you see instead?
To see a directory inside of the archive. A file with the directory's name.

What version of the product are you using? On what operating system?
Current version. Xcode 4. iOS 4.3.

Please provide any additional information below.


Original issue reported on code.google.com by megacron1 on 5 Mar 2011 at 5:42

Use of deprecated NSString call in ZipArchive class

What version of the product are you using? On what operating system?

ZipArchive 1.2

Mac OS X 10.6.8/ iOS SDK 4.3

Please provide any additional information below.

On line 210 (approx.) of ZipArchive.mm the line


NSString * strPath = [NSString  stringWithCString:filename];

should be changed to 

NSString * strPath = [NSString  stringWithCString:filename 
encoding:NSUTF8StringEncoding];

as the first call is deprecated in Mac OS 10.4

Original issue reported on code.google.com by [email protected] on 1 Jul 2011 at 10:43

Compile error:invalid deployment target for -stdlib=libc++ (requires iOS 5.0 or later)

What steps will reproduce the problem?
1. download ziparchive here
2. create a new xcode project (just use single view template), select ios4.3 
simulator
3. drag the download unzipped folder to project, and select "copy item..." 
,"create group", and check the "add to targets" 

What is the expected output? What do you see instead?
Compiled error with error message : invalid deployment target for 
-stdlib=libc++ (requires iOS 5.0 or later)

What version of the product are you using? On what operating system?
mac, xcode4.5.1, iphone4.3 simulator

Original issue reported on code.google.com by [email protected] on 10 Dec 2012 at 6:05

NSLog Usage incorrect

When you compile the source, you will get warnings about ZipArchive.mm:

NSLog([NSString stringWithFormat:@"%d entries in the zip 
file",globalInfo.number_entry] );


NSLog actually takes at least 2 parameters, and the first one is the format. So 
for that line you can just do:


NSLog(@"%d entries in the zip file",globalInfo.number_entry );

The other NSLog calls if they are just a single string should actually be:

NSLog(@"%@", @"String Here");

Original issue reported on code.google.com by [email protected] on 22 Jun 2010 at 1:47

Extracted files lose permissions

What steps will reproduce the problem?
1. Zip archives extracted with this seem to loose permissions, especially the 
executable bit.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
version 1.1 on 10.6.x

Please provide any additional information below.


Original issue reported on code.google.com by gil%[email protected] on 11 Nov 2009 at 11:03

Small issue in Wiki

Just a small issue with the section on adding a zip file, you need to add:

ZipArchive* za = [[ZipArchive alloc] init];

after the header inclusion. Though this is probably really obvious to a mac 
developer, it might confuse newbs!

Original issue reported on code.google.com by [email protected] on 30 Sep 2010 at 8:18

Problem with image

Hello.

I've downloaded the ZipArchive library and I've added to my project. I use the 
method CreateZipFile2: , I add the file to the zip with addFileToZip:newname: 
and I close the zip calling back the method CloseZipFile2.

Then the zip is done in the finder, but in its inside I've an image that I 
can't open because it's empity (it's 0kb).

Someone knows why?

In attachment I put the portion of code that I use to do the zip.

        NSString* zipName = @"archivio.zip";
    NSMutableArray* array = [[NSMutableArray alloc]init];
    [array addObject:@"photo1.jpg"];

    ZipArchive* zip = [[ZipArchive alloc] init];

     [zip CreateZipFile2:zipName];
     [zip addFileToZip:[array objectAtIndex:0] newname:[array objectAtIndex:0]];
     [zip CloseZipFile2];

    [zip release];

Original issue reported on code.google.com by [email protected] on 8 Nov 2010 at 5:04

Assigning a ZipArchiveDelegate to grab the error messages does not work

What steps will reproduce the problem?
1. Create and assigning a ZipArchiveDelegate to grab the error messages:


@interface MyZipArchiveDelegate:NSObject <ZipArchiveDelegate>
@end


@implementation MyZipArchiveDelegate
- (void) ErrorMessage:(NSString *) msg {
    NSLog(@"%@",msg);
};
@end


.....

then use it:


    self.zip = [[ZipArchive alloc] init];
    MyZipArchiveDelegate * zipdelegate=[[MyZipArchiveDelegate alloc]init];
    self.zip.delegate =zipdelegate;


.....

now the if statement in ZipArchive.mm 

 [ self.zip.delegate respondsToSelector:@selector(ErrorMessage)] returns NO, but should return YES.

the condition has an error in it (it lacks the :)

using the ErrorMessage: 
 [ self.zip.delegate respondsToSelector:@selector(ErrorMessage:)] 

returns YES.

The same counts for the OverWrite

The fixed methods in ZipArchive.mm (line 200-212) look like this:

#pragma mark wrapper for delegate
-(void) OutputErrorMessage:(NSString*) msg
{
    if( _delegate && [_delegate respondsToSelector:@selector(ErrorMessage:)] )
        [_delegate ErrorMessage:msg];
}

-(BOOL) OverWrite:(NSString*) file
{
    if( _delegate && [_delegate respondsToSelector:@selector(OverWriteOperation:)] )
        return [_delegate OverWriteOperation:file];
    return YES;
}

Original issue reported on code.google.com by [email protected] on 15 Oct 2012 at 11:27

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.