Wednesday, February 19, 2025

fileReferenceURL vs. NSURLFileResourceIdentifierKey

Thomas Tempelmann (Mastodon, tweet):

There is a fine but important difference between the two - they behave differently if the item is a hard linked file.

If, especially on a APFS formatted volume, you have multiple hard links for the same file content, then

  • NSURLFileResourceIdentifierKey will return the same value (classic “inode”) for all these hard links, whereas
  • fileReferenceURL returns unique “link IDs” that keep the reference for each hard link entry’s path.

Jim Luther:

Don’t use that info to construct your own URL string. First, the info in that answer is incomplete. Second, that string format could change.

[…]

fileReference URLs were added because AppKit used FSRefs and they wanted a URL equivelent. Bookmarks are always more reliable but not as fast.

BTW, fileReference URLs on non-Mac devices are much less useful because there’s no coreservicesd.

Previously:

Comments RSS · Twitter · Mastodon

Leave a Comment