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

TSCBasic: FILE is an opaque struct since Android 7 #243

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions Sources/TSCBasic/WritableByteStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<FILE>
#endif

extension WritableByteStream {
/// Write a sequence of bytes to the buffer.
public func write<S: Sequence>(sequence: S) where S.Iterator.Element == UInt8 {
Expand Down Expand Up @@ -670,7 +676,7 @@ public class FileOutputByteStream: _WritableByteStreamBase {
public final class LocalFileOutputByteStream: FileOutputByteStream {

/// The pointer to the file.
let filePointer: UnsafeMutablePointer<FILE>
let filePointer: FILEPointer

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

/// Instantiate using the file pointer.
public init(filePointer: UnsafeMutablePointer<FILE>, 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
Expand Down