Created
May 28, 2009 20:47
-
-
Save patrickt/119560 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static long | |
rb_io_stream_read_internal(CFReadStreamRef readStream, UInt8 *buffer, long len) | |
{ | |
long data_read = 0; | |
while (data_read < len) { | |
printf("About to read. bytes available? %d\n", CFReadStreamHasBytesAvailable(readStream)); | |
int code = CFReadStreamRead(readStream, &buffer[data_read], len - data_read); | |
printf("Read completed. Read %d bytes\n", code); | |
if (code == 0) { | |
// EOF | |
break; | |
} | |
else if (code == -1) { | |
CFErrorRef er = CFReadStreamCopyError(readStream); | |
CFStringRef desc = CFErrorCopyDescription(er); | |
CFRelease(er); | |
CFMakeCollectable(desc); | |
rb_raise(rb_eRuntimeError, | |
"internal error while reading stream: %s", | |
RSTRING_PTR(desc)); | |
} | |
data_read += code; | |
} | |
return data_read; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment