Giter Site home page Giter Site logo

gianlucabertani / objective-zip Goto Github PK

View Code? Open in Web Editor NEW
411.0 411.0 133.0 1022 KB

An object-oriented friendly wrapper library for ZLib and MiniZip, in Objective-C for iOS and OS X

License: BSD 3-Clause "New" or "Revised" License

Objective-C 19.17% C 78.27% Ruby 0.46% Swift 2.10%

objective-zip's People

Contributors

andyj-at-aspin avatar deni2s avatar gianlucabertani avatar martinwinter 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

objective-zip's Issues

Error reading in the zipfile in iOS 7.1 on device

Hi,

I'm using ObjectiveZip since a while under iOS 6.1 and iOS 7.0 on simulator and device.
But I experienced something weird since iOS 7.1.

I'm zipping a file with a password with the simulator, then I upload it on a server and then I get it back with the application on the device. And since my device is in iOS 7.1, the app crashes into the "readDataWithBuffer" method and I have the error message : "Error reading '%@' in the zipfile"

I didn't change a single line of code since then.

After that, I tried to go further and I remove the password protection on the zip file and it works well. Is there something in the encryption of the zip file with password ince iOS 7.1 ?

Thanks for your answer

zip error 2 - no such file or directory

hi,my code can't be unzipped using the standard unzipper tool (Archive Utility).
ZipArchive* zip = [[ZipArchive alloc] init];
BOOL ok;
ok = [zip CreateZipFile2:zipPath];
ok = [zip addFileToZip:@"1" newname:@"1"];// this's a file not directory
ok = [zip CloseZipFile2];

can u help me? thanks!

OZZip Stream access in Swift 3 Fails

The most recent change to the Swift 3 language (as delivered in XCode 8 beta 6) has made some further changes to the way ObjectiveC interacts with Swift.

Once the code in Objective-Zip_Swift_Tests.swift has been brought up to "current" Swift syntax, the tests segfault with EXC_BAD_ACCESS (code=-1, address=0x3) on line 143 when the NSData buffer is populated using OZZipReadStream.readData():

        NSLog("Test 1: reading from first file's stream...")

        let data1 = NSMutableData(length:256)!
        let bytesRead1 = try read1.readData(withBuffer: data1) <<< FAIL HERE!

This code passed without any issue using XCode 7.3 and Swift 2.x. I really can't help but think there is some link here between the expected return value of 3 (bytes read) and the reported address of 0x3 in the EXC_BAD_ACCESS.

MiniZip unzip.c hava some bug, it need to be make modifications

// if (len > UINT16_MAX)
// return UNZ_PARAMERROR;

s->pfile_in_zip_read->stream.next_out = (Bytef*)buf;
s->pfile_in_zip_read->stream.avail_out = (uInt)len;

if (s->pfile_in_zip_read->raw)
{
    if (len > s->pfile_in_zip_read->rest_read_compressed + s->pfile_in_zip_read->stream.avail_in)
        s->pfile_in_zip_read->stream.avail_out = (uInt)s->pfile_in_zip_read->rest_read_compressed +
            s->pfile_in_zip_read->stream.avail_in;
}
else
{
    if (len > s->pfile_in_zip_read->rest_read_uncompressed)
        s->pfile_in_zip_read->stream.avail_out = (uInt)s->pfile_in_zip_read->rest_read_uncompressed;
}

How to zip file with password

Hey. Im trying to zip file with password. It seems like zip operation ends with no any error, but when i unzip file on MacOSX or Windows i get wrong password error.
My code:

ZipFile * zipFile = [[ZipFile alloc] initWithFileName:zipFilePath mode:ZipFileModeCreate];
ZipWriteStream * stream = [zipFile writeFileInZipWithName:@"test.txt"
                                                         fileDate:[NSDate date]
                                                 compressionLevel:ZipCompressionLevelBest
                                                         password:@"123"
                                                            crc32:0];
NSString * someString = @"This is contents of file";
[stream writeData:[someString dataUsingEncoding:NSUTF8StringEncoding]];
[stream finishedWriting];
[zipFile close];

Well, the project is not documented so good. I can't understand does error cause by crc32=0, or something else. Please help me.
I found the same question on stackoverflow, with no answer: http://stackoverflow.com/questions/17872565/ios-objective-zip-password-wrong

How to UNZIP using readCurrentFileInZipWithPassword:(NSString *)password;

I am trying to unzip. However, if I do following, resulting readSize is 0 and contentsData contains 0 length of data. My unzip snippet is following the instruction shown in https://github.com/flyingdolphinstudio/Objective-Zip/blob/master/GETTING_STARTED.md , using password. If I try same file in other environment, I can open it with password.

ZipFile *importedZip = [[ZipFile alloc] initWithFileName:importedFilename mode:ZipFileModeUnzip];
    FXDLog(@"importedZip fileName: %@ numFilesInZip: %u", [importedZip fileName], [importedZip numFilesInZip]);
    FXDLog(@"importedZip listFileInZipInfos:\n%@", [importedZip listFileInZipInfos]);

    [importedZip goToFirstFileInZip];


    BOOL fileLocated = [importedZip locateFileInZip:filenameMainExported];
    FXDLog(@"fileLocated: %d", fileLocated);

    if (fileLocated == NO) {
        //TODO: shouldAlert
    }


    ZipReadStream *importingStream = [importedZip readCurrentFileInZipWithPassword:textField.text];
    FXDLog(@"importingStream: %@", importingStream);

    if (importingStream == nil) {
        //TODO: shouldAlert
    }


    NSMutableData *contentsData = [[NSMutableData alloc] initWithCapacity:256];

    NSUInteger readSize = [importingStream readDataWithBuffer:contentsData];
    FXDLog(@"readSize: %u", readSize);
    FXDLog(@"contentsData length: %u", [contentsData length]);

    [importingStream finishedReading];

    [importedZip close];


    if ([contentsData length] == 0) {
        //TODO: shouldAlert;
    }

readCurrentFileInZipWithPassword now taking password

Hi I am trying to unzip password protected file. But it gives me expections
here is my sample code

OZZipFile *unzipFile= [[OZZipFile alloc] initWithFileName:filePath mode:OZZipFileModeUnzip];

[unzipFile goToFirstFileInZip];
BOOL keepReading = YES;

@try {
    while(keepReading){
        OZFileInZipInfo *fInfo = [unzipFile getCurrentFileInZipInfo];
        OZZipReadStream *readStream = [unzipFile readCurrentFileInZipWithPassword:@"password"];
        NSMutableData *data = [[NSMutableData alloc] initWithLength:fInfo.length];

        [readStream readDataWithBuffer:data];
        [readStream finishedReading];

        NSString* unzippedFilename = [self validFilePathForFilename:fInfo.name atPath:path];
        [data writeToFile:unzippedFilename atomically:YES];
        keepReading = [unzipFile goToNextFileInZip];
    }
}
@catch (NSException *exception) {
    NSLog(@"unzip file %@ failed:%@", filePath, exception.reason);
}
@finally {
    [unzipFile close];
}

Can you please let me know whats problem

Buffer length too short

What is the point of case if (len > UINT16_MAX) return UNZ_PARAMERROR; in unzReadCurrentFile?
It fails on any file more than 65kb.

Moving password-protected zips between 64 & 32 bit platforms

Hi

Love this library, but I’m having problems with password-protected zip files. I can create them and open them fine when building as a 64 bit Mac app. However when trying to open them in the 32 bit iOS simulator I have problems. The zip opens fine, but the password-protected file cannot be extracted and it gives an error:

Error reading ‘file’ in the zipfile

The zip that is created on the 64 bit Mac app also has the same problems when attempting to be opened by 7-zip on Windows:

Data error in encrypted file ‘file’. Wrong password?

There are no problems if I don’t password-protect the zip and in this case they can be passed between 64 bit and 32 bit iOS and Mac systems and also Windows. Although, curiously, I cannot double-click and extract the zips in the Finder - I get a .cpgz file created instead.

There were many compiler warnings about loss of precision from longs to ints when using XCode 5.1. I can silence the compiler with casts in the code, but the issues above remain whether I add the casts or leave the code as it is.

I am using XCode 5.1 on OS X 10.9.2 and version 0.8.3 of Objective-Zip.

Hope you can help
Thanks

iOS app crash if I try to zip more than 2 300 small thumbnail files by 2kB each

Hello, first of all thanks for the library.

I trying to zip 2 300 or more thumbnail files with size of 2kB each and my iOS application is crash without any errors.
My code looks like this:

@try {
        OZZipFile *zipFile= [[OZZipFile alloc] initWithFileName: zipPath
                                                           mode: OZZipFileModeCreate
                                                legacy32BitMode:YES];

        for(int i = 0; i<filesArray.count; i++){
            NSString *path = [filesArray  objectAtIndex:i];

            OZZipWriteStream *stream= [zipFile
                                       writeFileInZipWithName: path
                                                  compressionLevel: OZZipCompressionLevelBest];
            NSError *error;
            NSData *data = [NSData dataWithContentsOfFile: path
                                                  options: NSDataReadingMappedIfSafe
                                                    error: &error];
            if (data == nil) {
                NSLog(@"\n Error to read file(zipSource): %@ \n", error);
            }

            [stream writeData: data];
            [stream finishedWriting];
        }
        [zipFile close];
     } @catch (OZZipException *ze) {
           NSLog(@"OZZipException : %@",[ze reason]);
      } @finally {

      }

If I want to archive for example 2 000 files or less all is OK and application not crash.

How can find where is the problem?
De we have limitation for number of files that can be zipped with this library?

Thanks in advance!

Password not valid when opening zip file

Hello all,
I am using Objective-zip library in my project However when I create zip file with password I am not able to open it. It always says that password is not valid. This is my code:
OZZipFile *zipFile= [[OZZipFile alloc] initWithFileName:fullPath mode:OZZipFileModeCreate]; uint32_t crc= [errorLogData crc32]; NSError* myerror = nil; OZZipWriteStream *zipWriteStream = [zipFile writeFileInZipWithName:baseNameLog fileDate:[NSDate date] compressionLevel:OZZipCompressionLevelBest password:@"bla" crc32:crc error:&myerror];

I have printed value of myerror, which is nil and crc which is not zero.
I think this is a problem in the library. Could you check it?
I am using macOS 10.12.6 for development
Regards

Crash when trying to unzip file

Hello, first of all thanks for the library.

When trying to unzip a zip file, it always crash for me on this step:

OZZipFile *unzipFile= [[OZZipFile alloc] initWithFileName:@"test.zip" mode:OZZipFileModeUnzip];

I double checked and the zip file is exist and can be unzipped correctly by OSX archiver. Zip file is created by OSX archiver.

It always crash on:
unzip.c > unzOpenInternal() line 577 unzGoToFirstFile((unzFile)s);

#0  0x00000001842bb7b8 in flockfile ()
#1  0x00000001842c7488 in fseek ()
#2  0x0000000100371ca0 in unzlocal_GetCurrentFileInfoInternal ()
#3  0x0000000100372d08 in unzGoToFirstFile ()
#4  0x000000010013a4bc in unzOpenInternal at /Users/Est/tiramisu/Pods/objective-zip/MiniZip/unzip.c:577
#5  0x000000010013a500 in unzOpen64 at /Users/Est/tiramisu/Pods/objective-zip/MiniZip/unzip.c:613
#6  0x0000000100130ff4 in -[OZZipFile initWithFileName:mode:legacy32BitMode:] at /Users/Est/tiramisu/Pods/objective-zip/Objective-Zip/OZZipFile.m:98
#7  0x0000000100130e20 in -[OZZipFile initWithFileName:mode:] at /Users/Est/tiramisu/Pods/objective-zip/Objective-Zip/OZZipFile.m:83
#8  0x0000000100131320 in -[OZZipFile initWithFileName:mode:error:] at /Users/Est/tiramisu/Pods/objective-zip/Objective-Zip/OZZipFile.m:134

Any idea why it crash when initializing the OZZipFile ? Thanks in advance.

Silencing implicit conversion warnings.

In Xcode 6.1.1 Product > Analyse shows lots of implicit conversion warnings in ZipFile.m. Those could be easily fixed with explicit casting.

screen shot 2015-02-16 at 10 24 05 am

As you can see on screenshot, line 102 is fixed. You can check on updated ZipFile.m.

If you think this is good idea, I can push my changes to the project.

Objective-zip cannot support "*.zip" files that are larger than 1GB?

I posted my issue on code.google.com site, but noticed github is the new site. Here is the original post I placed at code.google.com.

What steps will reproduce the problem?

  1. Zip content to have a zip file exceeding 1.5GB. I was using a 2.06GB zipped file.
  2. Open the file via:
    ZipFile* zippedFile = [[ZipFile Alloc] initWithFileName:filePath mode:ZipFileModeUnzip];
  3. You will now get a ZipException error "Cannot open file..."
  4. A ZipException occurs for both iOS Simulator and Device support.

What is the expected output? What do you see instead?
We need to acquire a valid handle to the zipped file. Instead, an exception occurs.

What version of the product are you using? On what operating system?
I downloaded the most recent (Version 0.8) which contains Minizip v1.1
I am using a Mac OS X Lion with Xcode v4.3.1

Please provide any additional information below.

  • I would put Step 2 above (opening the ZipFile) in a try-catch statement.
  • Tracing through Minizip, the error occurs in unzip.c Line 623 and 685 "central_pos = unz64local_SearchCentralDir(&us.z_filefunc, us.filestream);"
    The check for if(centrao_pos==0) results to true. Thus, an error occurs.

Packing XLSX files

Hi, first of all I would like to thank you for this great library.

I am trying to write an Excel (XLSX) parser/writer. I successfully integrated Objective-Zip to my project and I am using it to unzip and zip the XLSX file. For testing purposes, for now, I am only modifying one of the XML files inside the XLSX file.

The problem is, after updating the XLSX file, it becomes corrupt. I double checked if there is a problem with my XML generation and there is not. I am pretty much sure, because I tried the following:

  • I run my project, which unzips the XLSX, modifies an XML file inside and puts the XML back into the XLSX file.
  • When I try to open the XLSX file, I see that it is corrupt.
  • Then, I unzip this corrupt file manually and re-zip it. (I am using Unarchiver)
  • When I try to open this new file, it opens without any errors!

I am wondering if I am doing something wrong or if there is a problem with the library with respect to zipping of XLSX files.

Here is my code:
ZipFile *zipFile = [[ZipFile alloc] initWithFileName:XLSXDocumentsFilePath mode:ZipFileModeAppend]; ZipWriteStream *stream= [zipFile writeFileInZipWithName:XLSX_WORKSHEET_XML_SUBPATH compressionLevel:ZipCompressionLevelNone]; [stream writeData:data]; [stream finishedWriting]; [zipFile close];

By the way, I tried all of the compressionLevel's available.

Read from InputStream

Would it be possible to add the possibility to read from InputStream as well?

Thanks

Conflict with OpenSSL

Hello,

Thanks for your great work!

Since I upgraded to version 1.0.5 from 1.0.3, I'm no longer able to unzip files. I noticed that if I remove the OpenSSL dependency I have (pod 'OpenSSL', '~> 1.0'), it works again. Versions 1.0.4 & 1.0.5 are affected, 1.0.3 works.

The app throws an exception in OZZipReadStream.m at line 81 (in method readDataWithBuffer, result of unzReadCurrentFile is < 0).

When upgrading I noticed that a crypt.c file is added to MiniZip, maybe there's a conflict somewhere in this file with OpenSSL (which has a crypto.h file).

Not sure if you can / want to do something, but please let me know if it is the case.

Thanks!

Zip file size too low

Hi !
On version 1.0.5. I found some zip file error by following code:
if (len > UINT16_MAX)
return UNZ_PARAMERROR;

with #define UINT16_MAX 65535

Plesae check.

Thank you.

Issue with file corruption

Hi,
I am using the following method to zip a text file:
ZipFile *zipFile= [[ZipFile alloc] initWithFileName:zip_file_name mode:ZipFileModeCreate];

NSDictionary *attributes = [[NSFileManager defaultManager]attributesOfItemAtPath:txt_file_name error:&error];
NSDate *Date = [attributes objectForKey:NSFileCreationDate];

NSData *filedata = [NSData dataWithContentsOfFile:txt_file_name];

ZipWriteStream *stream = [zipFile writeFileInZipWithName:txt_file_name fileDate:Date compressionLevel:ZipCompressionLevelBest];
[stream writeData:filedata];
[stream finishedWriting];

[zipFile close];

However, my file seems to be corrupted. It has a non-zero size, and is in the correct location.
Does anybody have any ideas? Could there be anything i am doing later in my code that could corrupt it?
Mike

NSDate+DOSDate.h file not found

The 1.0.5 release removes the NSDate+DOSDate.h file but does not remove the dependency on it in OZZipFile.m So a clean pod install on a new machine, for instance, causes a compile time error.

There may also still be a dependency on NSDate+CRC32.h but I didn't look further into things.

Rolling back to 1.0.4 worked. This should be fixed for future versions. Either the file(s) needs to be kept in the pull or the dependency needs to be removed.

Support for Carthage dependency manager

As more and more modules support Carthage now, it would be very convienent for Objective-Zip to add support for it as well, so projects don't have to end up using two dependency managers.
Do you have any plans for this?

How detect Zip file Exception?

If zip file broken i have this:
Terminating app due to uncaught exception 'ZipException', reason: 'Can't open

And app crash after that.
How to get the error but the program did not fall?

Unable to unzip a file from an archive within any simulator based on 64 bit architecture

Zip archive is created (with password) with different archivers and with different content for test reasons, the result is the same and is always reproducible.
Everything is fine on all the simulators but iPad Air (no difference which iOS is setup). Device seems to work well too.
In method 'readDataWithBuffer:' a line 'int err= unzReadCurrentFile(_unzFile...' always gets as a return value '-3', which is 'Z_DATA_ERROR' and 'msg' contains a string "invalid distance too far back".

Version: objective-zip 1.0.2 (installed as a Pod)
Xcode Version 7.0.1.

v1.0.2 won't compile under Xcode 7 iOS project with a simple Swift file

cocopods v0.39, use_frameworks!, objective-zip v1.0.2

Just by importing the objective_zip module and nothing else via import objective_zip, I get the following compiler errors:

Pods/objective-zip/ZLib/crc32.h:5:1: Unknown type name 'local'
Pods/objective-zip/ZLib/crc32.h:5:7: Expected identifier or '('
Pods/objective-zip/ZLib/deflate.h:97:16: Redefinition of 'internal_state'
Pods/objective-zip/ZLib/inffixed.h:10:18: Unknown type name 'code'
Pods/objective-zip/ZLib/inffixed.h:87:18: Unknown type name 'code'
Pods/objective-zip/ZLib/inflate.h:36:9: Expected identifier
Pods/objective-zip/ZLib/inflate.h:106:5: Unknown type name 'code'
Pods/objective-zip/ZLib/inflate.h:106:10: Expected member name or ';' after declaration specifiers
Pods/objective-zip/ZLib/inflate.h:106:9: Expected ';' at end of declaration list
Pods/objective-zip/ZLib/inflate.h:107:5: Unknown type name 'code'
Pods/objective-zip/ZLib/inflate.h:107:10: Expected member name or ';' after declaration specifiers
Pods/objective-zip/ZLib/inflate.h:107:9: Expected ';' at end of declaration list
Pods/objective-zip/ZLib/inflate.h:115:5: Unknown type name 'code'
Pods/objective-zip/ZLib/inflate.h:118:5: Unknown type name 'code'
Pods/objective-zip/ZLib/inflate.h:118:16: Use of undeclared identifier 'ENOUGH'
Pods/objective-zip/ZLib/trees.h:73:36: Use of undeclared identifier 'DIST_CODE_LEN'
SampleSwift.swift:41:8: Could not build Objective-C module 'objective_zip'

Can't open file error, after unzipping a bunch of other files successfully.

I'm using Objective-Zip to unzip a somewhat large amount of zip files downloaded from AWS (not that matters much).

After downloading 2 or 3 hundred files the ZipFile stops to work, returning a "Can't open" exception. Debug info shows that when ZipFile tries to open the the file with unzOpen() the _unzFile == NULL, and an exception is thrown.
It happens always with a different file, and unzipping the file outside ZipFile works ok, so it is not a file problem.

For each file, a new instance of ZipFile is created. I really don't know what is happening, but it smells like some overflow in the minizip or zlib side.

Mine code is not the simplest, first I check and create directories and then I unzip using a buffer to optimize memory consumption. At the end the ZipFile instance is released and later a new one is created for a new file and so on.

My code is the following:

    @try {
        ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:_path_to_file mode:ZipFileModeUnzip];
        [unzipFile goToFirstFileInZip];

        do {
            FileInZipInfo *info = [unzipFile getCurrentFileInZipInfo];

            NSString *file_path = [NSString stringWithFormat:@"%@/%@", [_path_to_file stringByDeletingLastPathComponent], info.name];

            BOOL is_dir;
            if (![[NSFileManager defaultManager] fileExistsAtPath:[file_path stringByDeletingLastPathComponent] isDirectory:&is_dir]) {
                [[NSFileManager defaultManager] createDirectoryAtPath:[file_path stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:nil];
            } else if (!is_dir) {
                NSError *error;
                [[NSFileManager defaultManager] createDirectoryAtPath:[file_path stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:&error];
                if (error) {
                    return false;
                }
            }

            if (![[NSFileManager defaultManager] fileExistsAtPath:file_path]) {
                [[NSFileManager defaultManager] createFileAtPath:file_path contents:nil attributes:nil];
            }

            NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath:file_path];
            NSMutableData *buffer = [[NSMutableData alloc] initWithLength:BUFFER_SIZE];
            ZipReadStream *read = [unzipFile readCurrentFileInZip];

            // Read-then-write buffered loop
            do {

                // Reset buffer length
                [buffer setLength:BUFFER_SIZE];

                // Expand next chunk of bytes
                int bytesRead = [read readDataWithBuffer:buffer];
                if (bytesRead > 0) {

                    // Write what we have read
                    [buffer setLength:bytesRead];
                    [file writeData:buffer];

                } else
                    break;

            } while (YES);

            // Clean up
            [file closeFile];
            [read finishedReading];
            [buffer release];

        }while ([unzipFile goToNextFileInZip]) ;

        [unzipFile release];
        unzipFile = nil;
    } 
       @catch...

Thanks!

Issues from Cocoapods

Kind of weird. I attempted to use Cocoapods to install Objective-Zip in my project. Turns out, the most recent spec that's in the Cocoapods system is pointing to an AgileBits fork of version 0.7.2

I (naively it seems) tried to fix this by pointing the spec to the most recent version but was told that it's up to the maintainer of the library to officially tag the release. CocoaPods/Specs#1328

Thought I'd pass along the info.

Retrieving data without unzipping

Hello.. Is it possible to retrieve data without unzipping? and I was wondering if zip files has to be located in the Documents folder?Thanks..

Support for deleting / replacing files

If I'm not mistaken, currently we cannot delete / replace a file in the archive, without extracting all the archive and creating a new one, which is really cumbersome.

Do you intend to provide the functionality?

full of memory leaks

To reproduce unzip the same file (of some decent size) in a loop say 1000 times -- you will not be able to complete the loop without running out of memory.

Making zip archives that OS X can unzip

I'm making an archive which seems to be valid - unzip from the command line will unzip it, as will Stuffit Expander - but the OS X unarchive tool fails to unzip it when you double-click on it, and instead makes a .cpgz file from it.

Looking at the archive in zipinfo, as opposed to one made with the same files in the Finder, using the Compress... menu, there seem to be a few differences:

  • the version is 2.0 for our one as opposed to 1.0 from the Finder
  • the system is far for our one as opposed to unx from the Finder
  • the Finder one includes an extended local header for the files

I'm wonder which (if any) of these differences is causing the Unarchive tool to get confused, and whether there's some way to persuade Objective-Zip to make something that Unarchive can cope with.

Pod name should not have capitals

Adding pod 'Objective-Zip', '~> 1.0' as indicated in the Readme does not work. Need to drop the capitals

Should be: pod 'objective-zip', '~> 1.0'

Compressing large files in zip vs `streaming`

Hi my problem is that I'm tying to zip a folder containing multiple files which can be executed e.g this way:

 [OZZipFile *zFile = [[OZZipFile alloc] initWithFileName:zipFilePath mode:OZZipFileModeCreate];
        
        NSFileManager *fm  = [NSFileManager new];
        
        NSDirectoryEnumerator *directoryEnumerator = [fm enumeratorAtPath:folderPath];
        
        BOOL isDir;
        
        for (NSString *file in directoryEnumerator)
        {
            NSString *path = [folderPath stringByAppendingPathComponent:file];
            [fm fileExistsAtPath:path
                     isDirectory:&isDir];
            
            if (isDir)
            {
                continue;
            }
            
            OZZipWriteStream *stream = [zFile writeFileInZipWithName:file
                                                    compressionLevel:compressionLevel];

            NSData *inputDataBuffer;
            NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];

            [readHandle seekToFileOffset:0];

            while( [(inputDataBuffer = [readHandle readDataOfLength:2048 * 32]) length] != 0 ) {

                @autoreleasepool {

                    [stream writeData:inputDataBuffer];
                }
            }

            [stream finishedWriting];
        }
        
        [zFile close];

The problem is that some of those files may be big like i have 600mb video there, so the compression on even quiet good iPad may fail like iPad Air1 will not be able to compress the file.

I even tried doing some NSFileHandle as shown up and chunking write, but no memory footprint reduction at all.

So my question is. Does it really write like a stream or its just a name ? is there any other way to somehow compress big file in memory efficient way?

Regards
Marcin

Feature Request: unzip a specific byte range

I want to be able to extract a portion of a file in the zip archive. My specific use case is reading a video file from the zip, I only want to fetch specific chunks of data from the video file while playing the video

Files are not being fclosed!

-(BOOL) UnzipFileTo:(NSString*) path overWrite:(BOOL) overwrite
calls
unzCloseCurrentFile for each file

But, the file itself never fclosed!

Only unzClose(..) actually calls fclose.

I ran out of file descriptors when opening many zip files on ios.

I'm not sure whether this is because the zip files are not being fclosed or the contents that are being unzipped.

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.