{"id":1115,"date":"2005-10-03T10:37:36","date_gmt":"2005-10-03T14:37:36","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=1115"},"modified":"2025-07-03T18:46:41","modified_gmt":"2025-07-03T22:46:41","slug":"aliases-paths-and-fsrefs","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2005\/10\/03\/aliases-paths-and-fsrefs\/","title":{"rendered":"Aliases, Paths, and FSRefs"},"content":{"rendered":"<p>\n<a href=\"http:\/\/www.drunkenblog.com\/drunkenblog-archives\/000682.html\">DrunkenBatman<\/a>\nreports on an Apple engineer who, sadly, isn&rsquo;t familiar with aliases. Preview tracks bookmarks using paths.\n<\/p>\n\n<p>\nMeanwhile, <a href=\"http:\/\/wilshipley.com\/blog\/2005\/10\/pimp-my-code-part-5-special-apple.html\">Wil Shipley<\/a> rightly doesn&rsquo;t like the <code>-applicationSupportFolder<\/code> method in the CoreData stationery. But I guess someone should point out that <a href=\"http:\/\/developer.apple.com\/documentation\/Carbon\/Reference\/File_Manager\/file_manager\/chapter_1.2_section_9.html#\/\/apple_ref\/doc\/uid\/TP30000107-DontLinkChapterID_2-F14277\">FSRefMakePath<\/a> is actually rather new, and that you can avoid fixed-sized buffers using\n<a href=\"http:\/\/developer.apple.com\/documentation\/CoreFoundation\/Reference\/CFURLRef\/Reference\/chapter_2.1_section_2.html#\/\/apple_ref\/doc\/uid\/20001206-DontLinkChapterID_1-F16226\">CFURLCreateFromFSRef<\/a>. Also, I <em>do<\/em> think his code should make sure the Application Support folder exists, and that it should also resolve any aliases in the resulting path.\n<\/p>\n\n<p>\nMy version of this method uses <a href=\"http:\/\/developer.apple.com\/documentation\/Carbon\/Reference\/Folder_Manager\/folder_manager_ref\/chapter_1.2_section_3.html#\/\/apple_ref\/doc\/uid\/TP30000238-DontLinkChapterID_2-F16387\">FSFindFolder<\/a> (since <a href=\"http:\/\/developer.apple.com\/documentation\/Cocoa\/Reference\/Foundation\/ObjC_classic\/TypesAndConstants\/FoundationTypes.html#\/\/apple_ref\/doc\/c_ref\/NSApplicationSupportDirectory\">NSApplicationSupportDirectory<\/a> is only available in Tiger), and it will fall back on using a hard-coded path if <code>FSFindFolder<\/code> fails, which I&rsquo;ve seen happen in the wild. It also fixes the permissions of the folder, if necessary, to make sure that I&rsquo;ll be able to create files in it. Alas, it&rsquo;s not one line of code.\n<\/p>","protected":false},"excerpt":{"rendered":"<p>DrunkenBatman reports on an Apple engineer who, sadly, isn&rsquo;t familiar with aliases. Preview tracks bookmarks using paths. Meanwhile, Wil Shipley rightly doesn&rsquo;t like the -applicationSupportFolder method in the CoreData stationery. But I guess someone should point out that FSRefMakePath is actually rather new, and that you can avoid fixed-sized buffers using CFURLCreateFromFSRef. Also, I do [&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-07-03T22:46:42Z","apple_news_api_id":"371d6394-e1f9-4faf-94c4-01464e769c43","apple_news_api_modified_at":"2025-07-03T22:46:42Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/ANx1jlOH5T6-UxAFGTnacQw","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":[2786],"class_list":["post-1115","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-aliases"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1115","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=1115"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1115\/revisions"}],"predecessor-version":[{"id":48325,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1115\/revisions\/48325"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=1115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=1115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=1115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}