@@ -132,29 +132,41 @@ return length; } } -- (void)asyncReadWithBuffer: (void*)buffer +- (void)readIntoBuffer: (void*)buffer + exactLength: (size_t)length +{ + size_t readLength = 0; + + while (readLength < length) + readLength += [self readIntoBuffer: (char*)buffer + readLength + length: length - readLength]; +} + +#ifdef OF_HAVE_BLOCKS +- (void)asyncReadIntoBuffer: (void*)buffer length: (size_t)length block: (of_stream_async_read_block_t)block { [OFRunLoop OF_addAsyncReadForStream: self buffer: buffer length: length block: block]; } -- (void)readIntoBuffer: (void*)buffer - exactLength: (size_t)length -{ - size_t readLength = 0; - - while (readLength < length) - readLength += [self readIntoBuffer: (char*)buffer + readLength - length: length - readLength]; -} +- (void)asyncReadIntoBuffer: (void*)buffer + exactLength: (size_t)length + block: (of_stream_async_read_block_t)block +{ + [OFRunLoop OF_addAsyncReadForStream: self + buffer: buffer + exactLength: length + block: block]; +} +#endif - (uint8_t)readInt8 { uint8_t ret;