File Tree: Attempt Unicode Normalization Form bodge on enumerated paths

CQTexperiment
Christopher Snowhill 2022-01-22 20:32:18 -08:00
parent 72f1168498
commit 38e013e4ab
1 changed files with 42 additions and 1 deletions

View File

@ -57,7 +57,48 @@ NSURL *resolveAliases(NSURL *url)
- (void)setURL:(NSURL *)u
{
url = u;
// BODGE!
if (![[NSFileManager defaultManager] fileExistsAtPath:[u path]])
{
// Somebody gave us an incompatible file URL on enumeration!
DLog(@"Incompatible URL found: %@", [u path]);
do
{
NSString * path = [u path];
NSString * bodge = [path precomposedStringWithCanonicalMapping];
if ([[NSFileManager defaultManager] fileExistsAtPath:bodge])
{
DLog(@"It's actually supposed to be NFC!");
u = [NSURL fileURLWithPath:bodge];
break;
}
bodge = [path decomposedStringWithCanonicalMapping];
if ([[NSFileManager defaultManager] fileExistsAtPath:bodge])
{
DLog(@"It's actually supposed to be NFD!");
u = [NSURL fileURLWithPath:bodge];
break;
}
bodge = [path precomposedStringWithCompatibilityMapping];
if ([[NSFileManager defaultManager] fileExistsAtPath:bodge])
{
DLog(@"It's actually supposed to be NFKC!");
u = [NSURL fileURLWithPath:bodge];
break;
}
bodge = [path decomposedStringWithCompatibilityMapping];
if ([[NSFileManager defaultManager] fileExistsAtPath:bodge])
{
DLog(@"It's actually supposed to be NFKD!");
u = [NSURL fileURLWithPath:bodge];
break;
}
DLog(@"No idea what's up with this path!");
}
while (0);
}
url = u;
display = [[NSFileManager defaultManager] displayNameAtPath:[u path]];