简体   繁体   中英

Mac - Monitoring file moves / renames

I'm considering creating a file manager that keeps track of files on a user's system, but stores its metadata separately.

Is there a way to detect if a user moves a file outside of my application (or while my application isn't running) to know where the file moved to? For example, if a user has a photo stored in ~/Desktop/pictures (and my database has this as an entry), and they move it to ~/Documents/My Pictures , I'd like to be able to keep a reference to it still - is there a way to do this? Similarly, if they rename the file, I'd like to know it's the same file.

In other words - can you ask the system to notify you of changes to files' names and paths? Is there an application-accessible identifier for files which contains the proper reference irrespective of its actual name or path?

I'm new to the Cocoa API on the desktop; I'm one of those who learned Obj-C on iPhone programming and would like to apply it to the desktop.

Yes: it's called "bookmark data" , and has existed in this form since Mac OS X 10.6. If you need to use it on older version, you're looking for the Alias Manager .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM