Skip to content

Commit 7d8933a

Browse files
authored
TSCBasic: FILE is an opaque struct since Android 7 (#243)
1 parent 3b6b97d commit 7d8933a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sources/TSCBasic/WritableByteStream.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public extension WritableByteStream {
6666
// Public alias to the old name to not introduce API compatibility.
6767
public typealias OutputByteStream = WritableByteStream
6868

69+
#if os(Android)
70+
public typealias FILEPointer = OpaquePointer
71+
#else
72+
public typealias FILEPointer = UnsafeMutablePointer<FILE>
73+
#endif
74+
6975
extension WritableByteStream {
7076
/// Write a sequence of bytes to the buffer.
7177
public func write<S: Sequence>(sequence: S) where S.Iterator.Element == UInt8 {
@@ -670,7 +676,7 @@ public class FileOutputByteStream: _WritableByteStreamBase {
670676
public final class LocalFileOutputByteStream: FileOutputByteStream {
671677

672678
/// The pointer to the file.
673-
let filePointer: UnsafeMutablePointer<FILE>
679+
let filePointer: FILEPointer
674680

675681
/// Set to an error value if there were any IO error during writing.
676682
private var error: FileSystemError?
@@ -682,7 +688,7 @@ public final class LocalFileOutputByteStream: FileOutputByteStream {
682688
private let path: AbsolutePath?
683689

684690
/// Instantiate using the file pointer.
685-
public init(filePointer: UnsafeMutablePointer<FILE>, closeOnDeinit: Bool = true, buffered: Bool = true) throws {
691+
public init(filePointer: FILEPointer, closeOnDeinit: Bool = true, buffered: Bool = true) throws {
686692
self.filePointer = filePointer
687693
self.closeOnDeinit = closeOnDeinit
688694
self.path = nil

0 commit comments

Comments
 (0)