Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android support #273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Zip/QuickZip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extension Zip {

let directoryName = fileName.replacingOccurrences(of: ".\(fileExtension)", with: "")

#if os(Linux)
#if os(Linux) || os(Android)
// urls(for:in:) is not yet implemented on Linux
// See https://github.com/apple/swift-corelibs-foundation/blob/swift-4.2-branch/Foundation/FileManager.swift#L125
let documentsUrl = fileManager.temporaryDirectory
Expand Down Expand Up @@ -109,7 +109,7 @@ extension Zip {
*/
public class func quickZipFiles(_ paths: [URL], fileName: String, progress: ((_ progress: Double) -> ())?) throws -> URL {
let fileManager = FileManager.default
#if os(Linux)
#if os(Linux) || os(Android)
// urls(for:in:) is not yet implemented on Linux
// See https://github.com/apple/swift-corelibs-foundation/blob/swift-4.2-branch/Foundation/FileManager.swift#L125
let documentsUrl = fileManager.temporaryDirectory
Expand Down
4 changes: 4 additions & 0 deletions Zip/Zip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ public class Zip {
}

var writeBytes: UInt64 = 0
#if os(Android)
var filePointer: OpaquePointer!
#else
var filePointer: UnsafeMutablePointer<FILE>?
#endif
filePointer = fopen(fullPath, "wb")
while filePointer != nil {
let readBytes = unzReadCurrentFile(zip, &buffer, bufferSize)
Expand Down
2 changes: 1 addition & 1 deletion ZipTests/ZipTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ZipTests: XCTestCase {
}

private func url(forResource resource: String, withExtension ext: String? = nil) -> URL? {
#if Xcode
#if Xcode || os(Android)
return Bundle(for: ZipTests.self).url(forResource: resource, withExtension: ext)
#else
let testDirPath = URL(fileURLWithPath: String(#file)).deletingLastPathComponent()
Expand Down