0

I'm observing a file path for changes via file system events. Now I need to know if it is possible to get a reference to a file that is location independent, to keep track of the file when it is moved.

Is this be accomplished with OSX APIs?

1 Answers1

1

You can do this by getting an alias reference to the file. This requires using Carbon API, but there's a nice Objective-C wrapper called NDAlias that I've used in the past: https://github.com/nathanday/ndalias .

See here for more documentation: https://developer.apple.com/library/mac/#documentation/Carbon/Reference/Alias_Manager/Reference/reference.html

Andrew Madsen
  • 21,309
  • 5
  • 56
  • 97
  • Can such a reference be serialized and stored, e.g. to persist the alias when the app is closed/restarted? –  Mar 12 '12 at 21:32
  • Yes, it can. NDAlias implements the NSCoding protocol, so you can very easily save it to a file using NSKeyedArchiver. – Andrew Madsen Mar 12 '12 at 21:37