Giter Site home page Giter Site logo

Streaming Issue about zipzap HOT 3 CLOSED

sachinvas avatar sachinvas commented on August 23, 2024
Streaming Issue

from zipzap.

Comments (3)

pixelglow avatar pixelglow commented on August 23, 2024

I've ran your code against your given zip file, then fixed it to make it run correctly:

    NSInteger bytesRead;
    NSUInteger chunkSize = (archiveEntry.uncompressedSize < 512) ? archiveEntry.uncompressedSize : 512;
    NSMutableData *streamData = [NSMutableData data];
    [inputStream open]; // 1.
    do {
        streamData.length = chunkSize;
        bytesRead = [inputStream read:(uint8_t *)streamData.mutableBytes maxLength:chunkSize];
        bytesRead = (bytesRead < 0) ? 0 : bytesRead;
        if (bytesRead != 0) {
            streamData.length = bytesRead; // 2.
            [destinationHandle writeData:streamData];
        }
    } while (bytesRead);
    [inputStream close]; // 3.
  1. The new stream is unopened by convention, so you'll need to open it before use.
  2. Having read into the buffer, you'll need to truncate it to the actual number of bytes read, otherwise it is possible to write rubbish data into the file handle.
  3. The stream should be closed after use.

I've confirmed that the extracted file is byte-for-byte identical to using command-line unzip.

Hope that helps!

from zipzap.

sachinvas avatar sachinvas commented on August 23, 2024

Thank you so much. It helped a lot and one more thing can you please add
the Archive Decryption Header this is used to validate the password as
mentioned by the PKWARE?

Regards,

Sachin Vas
On Apr 4, 2014 11:13 AM, "Glen Low" [email protected] wrote:

I've ran your code against your given zip file, then fixed it to make it
run correctly:

NSInteger bytesRead;
NSUInteger chunkSize = (archiveEntry.uncompressedSize < 512) ? archiveEntry.uncompressedSize : 512;
NSMutableData *streamData = [NSMutableData data];
[inputStream open]; // 1.
do {
    streamData.length = chunkSize;
    bytesRead = [inputStream read:(uint8_t *)streamData.mutableBytes maxLength:chunkSize];
    bytesRead = (bytesRead < 0) ? 0 : bytesRead;
    if (bytesRead != 0) {
        streamData.length = bytesRead; // 2.
        [destinationHandle writeData:streamData];
    }
} while (bytesRead);
[inputStream close]; // 3.
  1. The new stream is unopened by convention, so you'll need to open it
    before use.
  2. Having read into the buffer, you'll need to truncate it to the
    actual number of bytes read, otherwise it is possible to write rubbish data
    into the file handle.
  3. The stream should be closed after use.

I've confirmed that the extracted file is byte-for-byte identical to using
command-line unzip.

Hope that helps!

Reply to this email directly or view it on GitHubhttps://github.com//issues/60#issuecomment-39533521
.

from zipzap.

pixelglow avatar pixelglow commented on August 23, 2024

At the moment, I don't have any plans to offer Central Directory Encryption which uses the Archive Decryption Header, but I would welcome any code contributions here!

from zipzap.

Related Issues (20)

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.