diff --git a/Foundation/Stream.swift b/Foundation/Stream.swift index 0aec7f0de6..874bab4934 100644 --- a/Foundation/Stream.swift +++ b/Foundation/Stream.swift @@ -119,7 +119,12 @@ open class InputStream: Stream { // returns in O(1) a pointer to the buffer in 'buffer' and by reference in 'len' how many bytes are available. This buffer is only valid until the next stream operation. Subclassers may return NO for this if it is not appropriate for the stream type. This may return NO if the buffer is not available. open func getBuffer(_ buffer: UnsafeMutablePointer?>, length len: UnsafeMutablePointer) -> Bool { - NSUnimplemented() + if let result = UnsafeMutablePointer(mutating: CFReadStreamGetBuffer(_stream, 0, len)) { + buffer.pointee = result + return true + } else { + return false + } } // returns YES if the stream has bytes available or if it impossible to tell without actually doing the read.