{"id":46788,"date":"2025-02-19T16:36:09","date_gmt":"2025-02-19T21:36:09","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=46788"},"modified":"2025-02-19T16:36:09","modified_gmt":"2025-02-19T21:36:09","slug":"filereferenceurl-vs-nsurlfileresourceidentifierkey","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2025\/02\/19\/filereferenceurl-vs-nsurlfileresourceidentifierkey\/","title":{"rendered":"fileReferenceURL vs. NSURLFileResourceIdentifierKey"},"content":{"rendered":"<p><a href=\"https:\/\/stackoverflow.com\/questions\/79427583\/what-is-the-difference-between-filereferenceurl-and-nsurlfileresourceidentifierk\">Thomas Tempelmann<\/a> (<a href=\"https:\/\/iosdev.space\/@tempelorg\/113980347124397031\">Mastodon<\/a>, <a href=\"https:\/\/x.com\/tempelorg\/status\/1888976457273106437\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/stackoverflow.com\/questions\/79427583\/what-is-the-difference-between-filereferenceurl-and-nsurlfileresourceidentifierk\"><p>There is a fine but important difference between the two - they behave differently if the item is a <strong>hard linked file<\/strong>.<\/p><p>If, especially on a APFS formatted volume, you have multiple hard links for the same file content, then<\/p><ul><li><code>NSURLFileResourceIdentifierKey<\/code> will return the same value (classic &ldquo;inode&rdquo;) for all these hard links, whereas<\/li><li><code>fileReferenceURL<\/code> returns unique &ldquo;link IDs&rdquo; that keep the reference for each hard link entry&rsquo;s path.<\/li><\/ul><\/blockquote>\n\n<p><a href=\"https:\/\/techhub.social\/@jimluther\/113981912564640141\">Jim Luther<\/a>:<\/p>\n<blockquote cite=\"https:\/\/techhub.social\/@jimluther\/113981912564640141\"><p>Don&rsquo;t use that info to construct your own URL string. First, the info in that answer is incomplete. Second, that string format could change.<\/p><p>[&#8230;]<\/p><p>fileReference URLs were added because AppKit used FSRefs and they wanted a URL equivelent. Bookmarks are always more reliable but not as fast.<\/p><p>BTW, fileReference URLs on non-Mac devices are much less useful because there&rsquo;s no coreservicesd.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2016\/12\/02\/file-reference-urls-dont-work-in-swift-3\/\">File Reference URLs Don&rsquo;t Work in Swift 3<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>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, thenNSURLFileResourceIdentifierKey will return the same value (classic &ldquo;inode&rdquo;) for all these hard links, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2025-02-19T21:36:12Z","apple_news_api_id":"86eea7fc-586b-4080-ae20-57f79db99350","apple_news_api_modified_at":"2025-02-19T21:36:12Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/Ahu6n_FhrQICuIFf3nbmTUA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[1395,30,2598,71,489],"class_list":["post-46788","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-apple-file-system-apfs","tag-mac","tag-macos-15-sequoia","tag-programming","tag-url"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=46788"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46788\/revisions"}],"predecessor-version":[{"id":46789,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46788\/revisions\/46789"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=46788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=46788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=46788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}