mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Fix problem with repeated access to zip entry's data
This commit is contained in:
@@ -85,6 +85,8 @@ public class ZipEntry: ContainerEntry {
|
||||
localHeader!.lastModFileTime == cdEntry.lastModFileTime &&
|
||||
localHeader!.lastModFileDate == cdEntry.lastModFileDate
|
||||
else { throw ZipError.wrongLocalHeader }
|
||||
} else {
|
||||
pointerData.index += localHeader!.headerSize
|
||||
}
|
||||
|
||||
let hasDataDescriptor = localHeader!.generalPurposeBitFlags & 0x08 != 0
|
||||
|
||||
@@ -25,6 +25,8 @@ struct ZipLocalHeader {
|
||||
private(set) var accessTimestamp: UInt32?
|
||||
private(set) var creationTimestamp: UInt32?
|
||||
|
||||
let headerSize: Int
|
||||
|
||||
init(_ pointerData: DataWithPointer) throws {
|
||||
// Check signature.
|
||||
guard pointerData.uint32() == 0x04034b50
|
||||
@@ -47,6 +49,7 @@ struct ZipLocalHeader {
|
||||
|
||||
let fileNameLength = pointerData.uint16().toInt()
|
||||
let extraFieldLength = pointerData.uint16().toInt()
|
||||
self.headerSize = 30 + fileNameLength + extraFieldLength
|
||||
|
||||
guard let fileName = ZipCommon.getStringField(pointerData, fileNameLength, useUtf8)
|
||||
else { throw ZipError.wrongTextField }
|
||||
|
||||
@@ -151,6 +151,8 @@ class ZipTests: XCTestCase {
|
||||
}
|
||||
|
||||
XCTAssertEqual(try? entries[0].data(), answerData)
|
||||
// Test repeat of getting entry data (there was a problem with it).
|
||||
XCTAssertEqual(try? entries[0].data(), answerData)
|
||||
}
|
||||
|
||||
func testZipBZip2() {
|
||||
|
||||
Reference in New Issue
Block a user