• 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
Checking file modification dates in NSDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking file modification dates in NSDocument


  • Subject: Checking file modification dates in NSDocument
  • From: Sanford Selznick <email@hidden>
  • Date: Thu, 27 Jul 2006 16:18:19 -0700

Hello,

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.

  My application is NSDocument based.

  Currently am doing the following:

1. Caching the mod date when the file is opened in awakeFromNib in MyDocument. 2. I compare the current mod date to the cached copy at the top of NSDocument's writeToFile.
3. Then at the end of writeToFile I'm re-caching the date.


  If this were working, I wouldn't be writing.  ;-)

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

There's lots of exchanging going on. Cocoa appears to be threading/delaying the file writes somehow. And the modification dates I'm getting back are never correct. (Because of the caching.)

I'm currently grabbing the modification dates with stat(2). I'm getting my file path with [[document_ fileName] fileSystemRepresentation].

Where are the best places to hook into NSDocument to get accurate modification dates on files for caching and comparison?

Thanks,
  Sanford

PS - I've read TN2037 and don't want to implement file locking.
_______________________________________________
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


  • Prev by Date: Re: 'inserted' and 'removed' arrays in observeValueForKeyPath's change dictionary always nil
  • Next by Date: Re: NSTextView, style, and weird Core Data issue
  • Previous by thread: Re: 'inserted' and 'removed' arrays in observeValueForKeyPath's change dictionary always nil
  • Next by thread: Re: Checking file modification dates in NSDocument
  • Index(es):
    • Date
    • Thread