On 30 May 2010, at 17:51, Jens Alfke wrote:

>> When a change occurs, I attempt to open the file using the FS API specifying 
>> exclusive read + exclusive write access. If it fails, it's likely because 
>> some other process still has the file open. I delay a half second or so and 
>> try again.
> 
> That sounds like a good approach, but it’s not 100% reliable. If the creating 
> process opened the file without requesting an exclusive lock, then your open 
> call will succeed even though the file is still open. 
> 
> Unfortunately you probably can’t do any better than that, since there’s no 
> cheap way to find out if another process has the file open.

Thanks guys, that makes it sound like my previously mentioned 
solution/work-around of trying to create a PDFDocument from the URL is the 
safest solution. The attempt will fail until the file has been fully written, 
and I only need to read the data, not write to it. Also, as far as I can tell, 
reading a PDFDocument with initWithURL: (and immediately discarding it if it 
succeeds) is a fairly cheap operation.

António

-----------------------------------------
Forgiveness is not an occasional act;
it is a permanent attitude.

--Martin Luther King, Jr
-----------------------------------------




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to