Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 3ce3be7
Author: Martin Lau <martinlau@livemail.tw>
Date:   Tue Dec 22 18:06:59 2020 +0800

    add bzip2; add set Compression

commit 91757ad
Author: Martin Lau <martinlau@livemail.tw>
Date:   Tue Dec 22 15:31:00 2020 +0800

    update README

commit 65efb44
Author: martin.lau <martin.lau@office.feng.com>
Date:   Tue Dec 22 07:24:49 2020 +0000

    fix build error on linux

commit 5c070be
Author: Martin Lau <martinlau@livemail.tw>
Date:   Tue Dec 22 14:59:12 2020 +0800

    support ios

commit 39995d4
Author: Martin Lau <martinlau@livemail.tw>
Date:   Tue Dec 22 13:47:17 2020 +0800

    Update libzip to 1.7.3
  • Loading branch information
MartinLau7 committed Dec 22, 2020
1 parent b9ffb96 commit bf5a5cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/LibzipSwift/ZipArchive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import libzip

public final class ZipArchive: ZipErrorHandler {
private var compressionCallback: ((Double) -> Void)?
private var compressionMethod: CompressionMethod = .default
private var compressionLevel: CompressionLevel = .fastest

internal var archivePointer: OpaquePointer!

Expand Down Expand Up @@ -305,6 +307,7 @@ public final class ZipArchive: ZipErrorHandler {
var external_fa = entry.externalAttributes.attributes
external_fa |= permissionsMask
try entry.setExternalAttributes(operatingSystem: .unix, attributes: external_fa)
try entry.setCompression(method: compressionMethod, flags: compressionLevel)
}
}
return result
Expand Down Expand Up @@ -353,6 +356,11 @@ public final class ZipArchive: ZipErrorHandler {
return false
}

public func setCompression(cm: CompressionMethod, cl: CompressionLevel) {
compressionMethod = cm
compressionLevel = cl
}

/// extract all entries to folder.
/// - Parameters:
/// - dir: the dst folder.
Expand Down
1 change: 1 addition & 0 deletions Sources/LibzipSwift/ZipConst.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public struct CompressionMethod: RawRepresentable {

public static let `default` = CompressionMethod(rawValue: ZIP_CM_DEFAULT)
public static let store = CompressionMethod(rawValue: ZIP_CM_STORE)
public static let bzip2 = CompressionMethod(rawValue: ZIP_CM_BZIP2)
public static let deflate = CompressionMethod(rawValue: ZIP_CM_DEFLATE)
public static let deflate64 = CompressionMethod(rawValue: ZIP_CM_DEFLATE64)
}
Expand Down

0 comments on commit bf5a5cc

Please sign in to comment.