iOS: CFReadStreamCreateWithFile non-exclusive file access?
iOS: CFReadStreamCreateWithFile non-exclusive file access?
- Subject: iOS: CFReadStreamCreateWithFile non-exclusive file access?
- From: John Michael Zorko <email@hidden>
- Date: Tue, 29 Jun 2010 14:45:39 -0700
Hello, all ...
I'm trying to implement a progressive download / cache using CFReadStreamCreateWithFile() to open a file URL that another thread is writing to. Basically, I have one thread with an NSURLConnection downloading a URL, and it's didReceiveData writes the data to the file via an NSFileHandle. Meanwhile, i've another thread that is trying to open this file via CFReadStreamCreateWithFile() to play it back. The idea is that the thread with the NSURLConnection can write the data to the file as fast as it gets it, and the thread with the CFReadStream can consume it at it's leisure (like, say, the audio playback rate).
What i'm seeing is that the CFReadStreamCreateWithFile() always returns nil when given the file URL that the other thread has open and is writing to, yet returns a stream if the file isn't already open. Is there a way I can make a CFReadStream with non-exclusive access to an already open file, or do I need to go down to the BSD open() call with SHLOCK to do this? Or is there another way? Any help is appreciated :-)
Regards,
John
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden