• 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: NSURL Name of a File: Content nor Attribute, how to check for modification?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURL Name of a File: Content nor Attribute, how to check for modification?


  • Subject: Re: NSURL Name of a File: Content nor Attribute, how to check for modification?
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 12 Dec 2009 00:12:52 -0600

On Dec 11, 2009, at 4:56 AM, martin halter wrote:

As I change the name of a File in Finder, neither NSURLContentModificationDateKey nor NSURLAttributeModificationDateKey do change.

I have an internal list of Files as NSURLs in my application and watch the directory with FSEvents. I properly receive the notification that something in the watched directory changed and can properly react if some content or some metadata has changed (ie. Label). But how can i detect if the name has changed?

A few years ago I read an interesting and philosophical discussion: does the name of a file belong to it's content or to it's metadata. It was very controversially discussed and as I see now for NSURL, it actually does not belong to any :-) so it's part of the URL itself.

In most Unix systems, the file name belongs to the directory containing the file. This is important in light of the possibility of a single file being hardlinked from multiple directories. Each may use a different name for the same file.


As i work only with fileReferenceURLs i don't know how to determine the change.

You can examine the NSURLNameKey to find the current name (I assume; I haven't checked that it's always up to date; it may be cached). If you want to detect that the name has changed, I guess you'd have to keep the old name along with the URL and compare.


You might also consider using the kqueue API. It has an event type for watching individual files for changes, including deletion or renaming.

Regards,
Ken

_______________________________________________

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


References: 
 >NSURL Name of a File: Content nor Attribute, how to check for modification? (From: martin halter <email@hidden>)

  • Prev by Date: Re: NSNumber stringValue
  • Next by Date: Re: Hang Initializing App
  • Previous by thread: NSURL Name of a File: Content nor Attribute, how to check for modification?
  • Next by thread: [COCOA] notification of enter/focus event?
  • Index(es):
    • Date
    • Thread