Re: Unicode filenames with Apple File System and UIManagedDocument
Re: Unicode filenames with Apple File System and UIManagedDocument
- Subject: Re: Unicode filenames with Apple File System and UIManagedDocument
- From: Quincey Morris <email@hidden>
- Date: Wed, 22 Mar 2017 23:51:46 -0700
On Mar 22, 2017, at 14:25 , email@hidden wrote:
>
> On Mar 22, 2017, at 2:00 PM, David Duncan <email@hidden <mailto:email@hidden>> wrote:
>>
>> So there was another explanation posted on the bug that I’m not certain you got, but which I think may explain.
>>
>> Basically the concept is that since APFS doesn’t normalize file names, if you store file names in some other storage (say in your preferences) then what could happen is this:
The “why” doesn’t matter at all. As I said before, the problem is that breaking the existing Cocoa file system API contract will break existing apps. It’s as simple as that.
Apple can certainly move the normalization out of the file system code into Cocoa frameworks code, but they can’t simply drop it. Imagine what would happen if they did. Within a few weeks, users would start reporting that they had lost access to some of their files. Not only existing files, but potentially files created after the conversion to APFS.
Not only that, but the Cocoa frameworks would break, too. Any time a file name was programmatically manipulated in the frameworks, such as having a suffix appended that was taken from a string constant or a resource string, the resulting name would be vulnerable to reversion to non-NFD, and … blammo.
This isn’t viable.
> Do I use the following?
>
> NSURL *url = [[self courseDirectory] URLByAppendingPathComponent:name.decomposedStringWithCanonicalMapping];
>
> Where [self courseDirectory] is a URL in English (assuming the sandboxed Documents directory are in English for other locales) and name is the NSString the user enters.
That isn’t going to be enough. Your “courseDirectory” subdirectory of the Documents directory might have an English name, but:
1. There’s no guarantee that English names have only a single Unicode form. (You could make this assumption for ASCII-character names, though.)
2. It’s unlikely that the path to the Documents directory is in English, and it’s not under your control.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden