Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking file modification dates in NSDocument



At 11:40 AM -0700 7/28/06, Jordan Krushen wrote:
PS - I've read TN2037 and don't want to implement file locking.

Then you're aware that all of the other work you're doing is ultimately for nothing, due to the inherent race condition between when you check for changes and when you commit the new file? If you don't use locks, then this code will quite possibly still destroy data under heavy use. You say you don't want to use locks, but you're writing code to ultimately do the same thing -- with the difference being that locks will prevent corruption, while your code will not.

You are right, of course. File Locking is the right solution. Unfortunately it's a royal pain the butt. And every app has to do it.


So, why isn't this built into Cocoa? TN2037 says exclusive locks are automatic in the framework, but I can clearly open/write the same document from two instances of my Cocoa app:

"By accessing files through the application frameworks (Carbon, Cocoa, Java), in versions of the OS supporting the advisory locks feature in frameworks, this will be provided automatically if you use the framework's file access methods."

A bold statement. But it doesn't appear to be true. Cocoa is clearly tracking my document... I can rename it in the Finder and watch MyDocument's window update. So why isn't the file locked for writing by others?

So what's the solution?  Stop using NSDocument?

Or perhaps: how does one patch NSDocument to do File Locking?

Or am I using the wrong Cocoa file access methods?

Thank you,
  Sanford
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Checking file modification dates in NSDocument (From: "Jordan Krushen" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.