macOS – How Mac OS Tracks Moved Files

filesystemmacos

An application I was using had a .dockset file stored in my home directory. I moved this file, and the application automatically updated the location of the file. I notice a similar effect when moving files that I'm currently editing in apps like Xcode, TextEdit, BBEdit, Preview, iWork, etc.

How does Mac OS keep track of these file movements?

Best Answer

From a higher point of view (in opposite to the low level implementation) this is probably related to NSURL's bookmark capabilities.

A bookmark provides a persistent reference to a file-system resource. When you resolve a bookmark, you obtain a URL to the resource’s current location. A bookmark’s association with a file-system resource (typically a file or folder) usually continues to work if the user moves or renames the resource, or if the user relaunches your app or restarts the system.