Comments (3)
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.
- The new stream is unopened by convention, so you'll need to open it before use.
- 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.
- 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.
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.
- The new stream is unopened by convention, so you'll need to open it
before use.- 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.- 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.
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)
- <ZipZap/ZZDataChannel.h> not found in UnitTest HOT 1
- Archives are corrupt on iOS 10.2 HOT 1
- No High Level APIs for Most Probable Use Cases HOT 3
- ZZArchiveEntry archiveEntryWithDirectoryName: Does Not Create Valid Entry
- ZZDeflateOutputStream write:maxLength erroneously returning zero HOT 1
- NSOutputStream write lose data when init with a non-text file
- [Bug] how to create a zip for symbol directory
- Module name is not consistent between Cocoapods and Carthage
- Lowering the deployment target
- Support iOS 9 HOT 2
- newDataWithError is nil
- Zipperdown security issue (Path traversal symbols not being ignored) HOT 2
- Unable to Build Xcode 10 Beta
- @"ZZOpenOptionsCreateIfMissingKey" - code: 0, archive succeeds HOT 1
- Archiving release version of ZipZap
- I hope to increase the encryption zip function. HOT 1
- New clang compiler complains tautology in this code HOT 1
- How to set the firstExtraField?
- Swift Package
- Not able to open Password protected file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zipzap.