Hi Thomas,

This sentence in the header file comment (which should be in the documentation 
but isn't) explains the problem.

> The bookmark data must have been created with the 
> kCFURLBookmarkCreationSuitableForBookmarkFile option.

The bookmark data created by CFURLCreateBookmarkDataFromAliasRecord() won't 
have the kCFURLBookmarkCreationSuitableForBookmarkFile option set in it.

Before CFURLCreateBookmarkDataFromAliasRecord(), Finder Alias files (bookmark 
files) were created by the Finder and so we needed the bookmark data in the 
files created by CFURLCreateBookmarkDataFromAliasRecord() to provide the same 
(and a little more) functionality. The 
kCFURLBookmarkCreationSuitableForBookmarkFile option enforces that.

So, if you want to create a bookmark file from an AliasRecord, you either have 
to:

(1) Resolve the AliasHandle to a FSRef, convert the FSRef to a CFURL, create a 
bookmark to the CFURL using the kCFURLBookmarkCreationSuitableForBookmarkFile 
option, and then write the bookmark.

(2) Do what your stack overflow code does but after creating the bookmark from 
the AliasRecord, resolve the bookmark to its target, and then create a new 
bookmark to the target using the kCFURLBookmarkCreationSuitableForBookmarkFile 
option, and then write the bookmark.

CFURLCreateBookmarkDataFromAliasRecord() was intended as a way to convert alias 
records stored a program's own data files to a bookmark data with no I/O.

- Jim

> On May 18, 2016, at 1:50 PM, Thomas Tempelmann <tempelm...@gmail.com> wrote:
> 
> (This may be a bit off-topic, as this is a user-level question, but there are 
> the right people on this list who can answer this, I think)
> 
> I'm trying to write bookmark files with content from Alias data generated by 
> the Alias Manager. But that doesn't work, and I find no options that would 
> suggest that I'm simply missing something.
> 
> So I wonder if this is simply unsupported or a known bug in CoreFoundation?
> 
> Here's a detailed question on Stackoverflow from me on this:
> 
> http://stackoverflow.com/questions/37309635/ 
> <http://stackoverflow.com/questions/37309635/>
> 
> Thomas
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Filesystem-dev mailing list      (Filesystem-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/filesystem-dev/luther.j%40apple.com
> 
> This email sent to luthe...@apple.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (Filesystem-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/filesystem-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to