From e5bfbca8893c80eb67805f868757092e60c60fee Mon Sep 17 00:00:00 2001 From: Butta Date: Tue, 20 Jul 2021 00:39:46 +0530 Subject: [PATCH] TSCBasic: FILE is an opaque struct since Android 7 --- Sources/TSCBasic/WritableByteStream.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/TSCBasic/WritableByteStream.swift b/Sources/TSCBasic/WritableByteStream.swift index 06af1506..cdfdb4c0 100644 --- a/Sources/TSCBasic/WritableByteStream.swift +++ b/Sources/TSCBasic/WritableByteStream.swift @@ -66,6 +66,12 @@ public extension WritableByteStream { // Public alias to the old name to not introduce API compatibility. public typealias OutputByteStream = WritableByteStream +#if os(Android) +public typealias FILEPointer = OpaquePointer +#else +public typealias FILEPointer = UnsafeMutablePointer +#endif + extension WritableByteStream { /// Write a sequence of bytes to the buffer. public func write(sequence: S) where S.Iterator.Element == UInt8 { @@ -670,7 +676,7 @@ public class FileOutputByteStream: _WritableByteStreamBase { public final class LocalFileOutputByteStream: FileOutputByteStream { /// The pointer to the file. - let filePointer: UnsafeMutablePointer + let filePointer: FILEPointer /// Set to an error value if there were any IO error during writing. private var error: FileSystemError? @@ -682,7 +688,7 @@ public final class LocalFileOutputByteStream: FileOutputByteStream { private let path: AbsolutePath? /// Instantiate using the file pointer. - public init(filePointer: UnsafeMutablePointer, closeOnDeinit: Bool = true, buffered: Bool = true) throws { + public init(filePointer: FILEPointer, closeOnDeinit: Bool = true, buffered: Bool = true) throws { self.filePointer = filePointer self.closeOnDeinit = closeOnDeinit self.path = nil