From 3afe17869b223574fffe59dd9722ce6865b0db80 Mon Sep 17 00:00:00 2001 From: Lily Vulcano Date: Wed, 24 Jul 2019 10:34:16 -0700 Subject: [PATCH] =?UTF-8?q?Parity:=20InputStream.getBuffer(=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement. --- Foundation/Stream.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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.