I have some code that downloads a file from the internet. Once I have written X bytes of that file to the local file system I tell another class to start reading it.
CFReadStreamRef stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, (CFURLRef)url);
CFStreamClientContext context = {0, self, NULL, NULL, NULL};
CFReadStreamSetClient(stream,kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered,ASReadStreamCallBack,&context);
CFReadStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
In the case that we are able to read faster than we can write, my callback function gets an kCFStreamEventEndEncountered event. This is fine, I can ignore it since I know that we have reached the end of the file but there is more to be written and then read. However, once I get this event my callback is never called again.
Is there a way I can tell CFReadStreamSetClient to keep reading after the EOF? Is there a way that I can tell the CFReadStreamSetClient the file size so that it knows that it is not really at the EOF? Is there a way to write my own CFReadStreamSetClient that would be smart enough to ignore EOF in certain situations?
Thanks in advance, Randy