> Le 19 janv. 2017 à 22:18, Daryle Walker <dary...@mac.com> a écrit : > > >> On Jan 16, 2017, at 12:08 PM, Charles Srstka <cocoa...@charlessoft.com> >> wrote: >> >>> On Jan 14, 2017, at 4:41 AM, Daryle Walker <dary...@mac.com >>> <mailto:dary...@mac.com>> wrote: >>> >>> Could I base the UUID off a hash of the URL? Maybe, but it wouldn’t survive >>> file moves. There are file references in macOS, which would be more stable, >>> but I read that there’s a bug in the URL class where it would degrade >>> file-reference URLs to standard-file URLs, so that’ll be problematic. >>> Another solution would to create bookmark data from a file URL and take a >>> hash of that. But are multiple bookmark data blocks of the same file URL >>> consistent enough for this idea to work? >> >> The thing with file reference URLs degrading to file path URLs is in the >> Swift is actually not a bug, it’s deliberate >> (https://bugs.swift.org/browse/SR-2728 >> <https://bugs.swift.org/browse/SR-2728>). The Swift team decided that file >> reference URLs are not appropriate for the Swift URL value type. However, if >> you’re using Objective-C, file reference URLs will still work fine, and you >> can always make an Objective-C wrapper that stores a file reference URL and >> use that from Swift. > > I looked at some code that gives a workaround for the file-reference URL > problem. It grabs the reference ID as a 128-bit value, dumps it into 2 64-bit > values, then sprinkles those onto a URL string template. Since UUIDs are > 128-bit values, I could just copy a reference ID directly into a UUID.
The file reference URL content is an implementation details and relying on the fact that a reference ID is 128 bit is very fragile IMHO, especially as Apple is planning to introduce a new FS soon. On APFS they may decide to use something completely different for file reference. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com