From 04c195bbd98991203816b936d0717fa2ef863b08 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Thu, 9 Jan 2025 12:32:19 -0500 Subject: [PATCH] Android support --- Zip/QuickZip.swift | 4 ++-- Zip/Zip.swift | 4 ++++ ZipTests/ZipTests.swift | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Zip/QuickZip.swift b/Zip/QuickZip.swift index 779912a8..c539a6a4 100644 --- a/Zip/QuickZip.swift +++ b/Zip/QuickZip.swift @@ -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 @@ -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 diff --git a/Zip/Zip.swift b/Zip/Zip.swift index 4908f658..e10740c2 100644 --- a/Zip/Zip.swift +++ b/Zip/Zip.swift @@ -211,7 +211,11 @@ public class Zip { } var writeBytes: UInt64 = 0 + #if os(Android) + var filePointer: OpaquePointer! + #else var filePointer: UnsafeMutablePointer? + #endif filePointer = fopen(fullPath, "wb") while filePointer != nil { let readBytes = unzReadCurrentFile(zip, &buffer, bufferSize) diff --git a/ZipTests/ZipTests.swift b/ZipTests/ZipTests.swift index 957ef51e..07ae7ac6 100644 --- a/ZipTests/ZipTests.swift +++ b/ZipTests/ZipTests.swift @@ -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()