• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Checking file modification dates in NSDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking file modification dates in NSDocument


  • Subject: Re: Checking file modification dates in NSDocument
  • From: "Jordan Krushen" <email@hidden>
  • Date: Fri, 28 Jul 2006 11:40:42 -0700

On 7/27/06, Sanford Selznick <email@hidden> wrote:

   Before my users save files they've opened I want to first detect if
any other users (on the network or otherwise) have modified the file.
I want to do this by checking the mod date on the file before the
user saves, and then compare this date to the mod date when the file
was opened.

I'm writing the file data with [NSData writeToFile:path atomically:YES].

Be sure to understand what the 'atomically' flag does. It creates a *second* file, and moves it to where the first one was. You're not modifying the pre-existent file in place.

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.

J.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Checking file modification dates in NSDocument
      • From: Sanford Selznick <email@hidden>
  • Prev by Date: Re: How would you convert a \r to its UTF-8 counterpart ?
  • Next by Date: Re: Manually pull a menu down?
  • Previous by thread: Checking file modification dates in NSDocument
  • Next by thread: Re: Checking file modification dates in NSDocument
  • Index(es):
    • Date
    • Thread