Skip to content

Commit 3afe178

Browse files
committed
Parity: InputStream.getBuffer(…)
Implement.
1 parent 7822b68 commit 3afe178

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Foundation/Stream.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ open class InputStream: Stream {
119119

120120
// 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.
121121
open func getBuffer(_ buffer: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>, length len: UnsafeMutablePointer<Int>) -> Bool {
122-
NSUnimplemented()
122+
if let result = UnsafeMutablePointer(mutating: CFReadStreamGetBuffer(_stream, 0, len)) {
123+
buffer.pointee = result
124+
return true
125+
} else {
126+
return false
127+
}
123128
}
124129

125130
// returns YES if the stream has bytes available or if it impossible to tell without actually doing the read.

0 commit comments

Comments
 (0)