Giter Site home page Giter Site logo

mattconnolly / ziparchive Goto Github PK

View Code? Open in Web Editor NEW
840.0 48.0 264.0 293 KB

zip archive processing for Cocoa - iPhone and OS X

Home Page: http://code.google.com/p/ziparchive/

License: MIT License

Objective-C 13.07% Ruby 0.37% Makefile 0.17% C 86.04% DIGITAL Command Language 0.34%

ziparchive's Introduction

ZipArchive

ZipArchive lets Mac OS X / iOS apps read and write to ZIP archive files.

Contributors

Thanks to the following contributors to the Objective-C ZipArchive library:

  • acsolu
  • Matt Connolly (@mattconnolly)
  • Edward Patel (@epatel)
  • kajinka13
  • David Keegan (@kgn)
  • Yuri (@Wert1go)
  • Hyunwoo Nam (@namenu)
  • OpenFibers
  • Wiley Kestner (@wileykestner)
  • turenus
  • David Feshbach

Special Thanks to the minizip authors:

  • Gilles Vollant - Original MiniZip author
  • Even Rouault - ZIP64 unzip Support
  • Daniel Borca - BZip Compression method support in unzip
  • Mathias Svensson - ZIP64 zip support
  • Mathias Svensson - BZip Compression method support in zip

License

Portions of ZipArchive are licensed under the original minizip license. See the minizip headers for details. All other parts of this project are licensed under the MIT license, see LICENSE.

ziparchive's People

Contributors

bangtoven avatar epatel avatar ericcj avatar habzy avatar kajinka13 avatar kgn avatar lanbozhang avatar mattconnolly avatar maxsz avatar namenu avatar turenus avatar v01dzer0 avatar wert1go avatar wileykestner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ziparchive's Issues

Swift support

Could you please add swift support code for ZipArchive? Adding the sample code for zipping and unzipping with and without password would be nice. There are many newcomers to iOS development who only know swift (including me).

getZipFileContents does not produce the same filenames as UnzipFileTo:overWrite:

When filenames in the zip file contain non ASCII characters (e.g. ö) , getZipFileContents does not give the same filename as those created by unzipFileTo.
It seems to be caused by the following line:
NSString * strPath = [NSString stringWithCString:filename encoding:NSASCIIStringEncoding];

I think it should be:
NSString * strPath = [NSString stringWithCString:filename encoding:self.stringEncoding];

Create zip file with Standard Zip 2.0 encryption

Hello,
I successfully create zip file with password using ZipArchive. However, as I know, there is only one encryption method used that is aes 256. How to create file zip with password using the Standard Zip 2.0 encryption?

make fails

when i run make i get the following error?

fatal error: 'direct.h' file not found

Convert to straight Objective-C

Find out if there's any compelling reason to use Objective-C++ instead of Obj-C. Going back to Obj-C will enable static analysis, Clang compiler and simplified runtimes.

Cancel ongoing unzipFileTo

Please consider this as a "feature enhancement request" because it seems like currently it doesn't support "cancel" or suspend/resume kind of functionality for unzip operation.

-(BOOL) UnzipFileTo:(NSString*) path overWrite:(BOOL) overwrite;

This is extremely important feature when you have a big zip file (or even small ~20 mb zip but with large number of files in it) that takes time (~30 seconds) to unzip, especially on iOS devices and app goes in background.

Please let me know if I'm missing something or you have further questions.

Thank you.

File not found

Hello,

On 'pod update' I have detect some error on miniunz.h and minizip.h. We trying to call files not find (direct.h and io.h)

ifdef unix
 include <unistd.h>
 include <utime.h>
 include <sys/stat.h>
else
 include <direct.h>
 include <io.h>
endif

I solved the problem by removing both include but regularly i'm doing pod update so if i get this error each time ... it could be a problem
can you fix it ?

UnzipFileToMemory doesn't return files with zero length

When an archive contains files that have zero length, they will not be returned by UnzipFileToMemory.

There are cases where empty files have merit, so I'm submitting a (weak) plea to make it behave in this way.

If you agree, I'll be submitting a patch.

Tom

file modification timestamps not generated correctly

In ZipArchive.m, lines 354 to 356, the library creates an NSDate from the fileInfo.dosDate value.

                NSDate* orgDate = [[NSDate alloc]
                                   initWithTimeInterval:(NSTimeInterval)fileInfo.dosDate
                                   sinceDate:[self Date1980] ];

The value is not a time interval since 1980, it is a bitfield that contains the date components individually:

               http://proger.i-forge.net/MS-DOS_date_and_time_format/OFz

It would be better to use the fileInfo.tmu_date property as follows:

                NSDateComponents* components = [[NSDateComponents alloc] init];
                components.second = fileInfo.tmu_date.tm_sec;
                components.minute = fileInfo.tmu_date.tm_min;
                components.hour = fileInfo.tmu_date.tm_hour;
                components.day = fileInfo.tmu_date.tm_mday;
                components.month = fileInfo.tmu_date.tm_mon;
                components.year = fileInfo.tmu_date.tm_year;

                NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
                NSDate* orgDate = [[gregorianCalendar dateFromComponents:components] retain];
                [components release];
                [gregorianCalendar release];

Unzip encrypted zip

Is there a way to unzip an AES encrypted zip?
Can't unzip properly with this type of zip file...

Will you add UnzipIsEncrypted testing method?

like this:

-(BOOL) UnzipIsEncrypted
{
    int ret = unzGoToFirstFile( _unzFile );
    if (ret == UNZ_OK) {
        do {
            ret = unzOpenCurrentFile( _unzFile );
            if( ret!=UNZ_OK ) {
                return NO;
            }
            unz_file_info   fileInfo ={0};
            ret = unzGetCurrentFileInfo(_unzFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
            if (ret!= UNZ_OK) {
                return NO;
            }
            else if((fileInfo.flag & 1) == 1) {
                return YES;
            }

            unzCloseCurrentFile( _unzFile );
            ret = unzGoToNextFile( _unzFile );
        }while( ret==UNZ_OK && UNZ_OK!=UNZ_END_OF_LIST_OF_FILE );


    }


    return NO;
}

posted in: here

Thanks!

ERR=-3(DATA

When i unzip a file using zip archive on ios i get a err=-3 i.e. DATA ERROR.All file unzipped are of zero bytes.
While the same zip file is successfully unzipped on windows,mac and android.
Note:- The zip file is maded on mac using PKZip.

Xcode 5 Analyze warnings

I get multiple warnings from analyzing this code in Xcode 5. Are there plans to resolve these warnings?

New release

Last released version of ZipArchive (1.2.0) contains bugs in minizip, due to having an old version, which are currently preventing us from using it. Fixes in master fix these issues, but there is not a readily available pod, as that code for ZipArchive has not been officially released yet.

Would it be possible to create a new release from master which contains latest fixes?

how to use ZipArchive

this is not an issue this is help wanted.

if you can please help me with any tutorial or guide
"how to include ZipArchive to another iphone project" ?

i am so appreciative
Note: i am using XCode 3.2.4 and iOS 4.1

Password protected ZipArchive crashes on attempt to add a file to the archive

Screen Shot 2013-02-25 at 7 58 17 PM
STEPS:

  1. Create a test application with a code from the Listing 1 (error handling is omitted for simplicity).
  2. Run the test application.

Actual result:
The test app crashes inside addFileToZip:newname: method. See the attached crash log.

Additional info:
MacOS 10.7.5, Xcode 4.5.1

Listing 1:

ZipArchive theZip = [[[ZipArchive alloc] init] autorelease];
NSString *theZippedFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:
@"archivedFile.zip"];
NSString *theFilePath = /
Path to a file whose size is 300KB or more*/;

if ([[NSFileManager defaultManager] fileExistsAtPath:theZippedFilePath])
{
[[NSFileManager defaultManager] removeItemAtPath:theZippedFilePath error:nil];
}

[theZip CreateZipFile2:theZippedFilePath Password:@"password"];
[theZip addFileToZip:theFilePath newname:[theFilePath lastPathComponent]];
[theZip CloseZipFile2];

Making iOS binary errors

I try to make the iOS binary but I encounter somes problems :

  • the libz library point to OSX SDK directory, I don't have them so I unlink this lib for the targets "ZipArchive ios" and "ZipArchive ios Tests" and link zlib (only for the testing target) with the zlib provided by iOS SDK libraries

UnzipOpenFile fails on empty zips

if you CreateZipFile2 and then immediately CloseZipFile2 it correctly creates a file of 22 bytes, but then UnzipOpenFile on that returns false with errno ESRCH. i believe it should succeed and return you and empty array of entries.

Recognize protected zip file

How to recognize protected zip files to present textfield for user input?
Currently one only gets an general error while unzipping and it's impossible to determine that it's because the zip file was protected....

Analyze/warnings

Not critical obviously but always nice to have zero warnings in your project. When I analyze, I see 3 files with a few never-read warnings:

<root>/Pods/ZipArchive/ZipArchive.m:468:17: warning: Value stored to 'success' is never read
                success = NO;
                ^         ~~
<root>/Pods/ZipArchive/ZipArchive.m:478:17: warning: Value stored to 'success' is never read
                success = NO;
                ^         ~~
<root>/Pods/ZipArchive/ZipArchive.m:508:21: warning: Value stored to 'success' is never read
                    success = NO;
                    ^         ~~
<root>/Pods/ZipArchive/ZipArchive.m:524:21: warning: Value stored to 'success' is never read
                    success = NO;



<root>/Pods/ZipArchive/minizip/unzip.c:1107:9: warning: Value stored to 'lSeek' is never read
        lSeek+=file_info.size_file_comment - uSizeRead;
        ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<root>/Pods/ZipArchive/minizip/unzip.c:1110:9: warning: Value stored to 'lSeek' is never read
        lSeek+=file_info.size_file_comment;
        ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~
<root>/Pods/ZipArchive/minizip/unzip.c:1543:9: warning: Value stored to 'err' is never read
        err=UNZ_BADZIPFILE;
        ^   ~~~~~~~~~~~~~~


<root>/Pods/ZipArchive/minizip/zip.c:1037:7: warning: Value stored to 'err' is never read
      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2);
      ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<root>/Pods/ZipArchive/minizip/zip.c:1038:7: warning: Value stored to 'err' is never read
      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2);
      ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<root>/Pods/ZipArchive/minizip/zip.c:1040:7: warning: Value stored to 'err' is never read
      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
      ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<root>/Pods/ZipArchive/minizip/zip.c:1537:49: warning: Value stored to 'err' is never read
                                                err = ZIP_ERRNO;
                                                ^     ~~~~~~~~~
<root>/Pods/ZipArchive/minizip/zip.c:1682:9: warning: Value stored to 'p' is never read
        p += 8;
        ^    ~


Adding files to archive with newname is Case Insensitive

if I use addFileToZip:newname: to add two files named "Test" and "test", respectively, only one is added.
Identical problem with strings containing diacritics encoded differently: they are considered the same (insensitive diacritic comparison).
Ex:
[zip addFileToZip:path1 newname:"Test"]
[zip addFileToZip:path2 newname:"test"]

UnzipOpenFile doesn't work

I have used ZipArchive to zip and unzip some file, but UnzipOpenFile returns nil.
Please help me on this.

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

                if([[NSFileManager defaultManager] fileExistsAtPath:zipFolder]) {
                    NSLog(@"File exists at path: %@", zipFolder);
                } else {
                    NSLog(@"File does not exists at path: %@", zipFolder);
                }

                if( [za UnzipOpenFile: zipFolder] ) {
                    if( [za UnzipFileTo:outputFolder overWrite:YES] != NO ) {
                        NSLog(@"Pics : unzip successfully");

                        [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationArticleLoadedFromiCloud object:nil];
                    }
                    [za UnzipCloseFile];
                }

Z_DATA_ERROR in arm64bit during inflate

Hi

IOS based code, ziparchive version 1.4.

Before migrating to 64bit (arm64) the code works great. After, no longer able to unzip files:

I am getting -3 (Z_DATA_ERROR) when this line is called
err=inflate(&pfile_in_zip_read_info->stream,flush);

        if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
          err = Z_DATA_ERROR;

(lldb) po pfile_in_zip_read_info->stream.msg
"invalid code lengths set"

This is works nicely until I migrate to 64bit on ios.

Using wrong password to test error case

Hi, great work Matt!

I had a question for you about unzipping with a password.
I am able to zip with a password, and unzip with the password without any problem.

I tried an error case using a wrong password to unzip. I expected to receive an indication that the unzip was unsuccessful, but I get a return of success. As expected, the zipped files are not actually unzipped (which is good), however, the directory now holds a bunch of zero byte files with the correct file names that were in the zip. Seems strange.

Is this expected, or should there be a return somewhere indicating an invalid password?

Thx!
Anthony

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.