Mercurial > dwindows
comparison ios/dw.m @ 2445:a773008c7c5d
iOS: Make sure the plain text UTI is used with filePicker.
Also strip off the "file://" prefixing the file path returned.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 09 Apr 2021 11:05:51 +0000 |
parents | ba24ddb19a43 |
children | 8723c01fb87e |
comparison
equal
deleted
inserted
replaced
2444:ba24ddb19a43 | 2445:a773008c7c5d |
---|---|
975 { | 975 { |
976 NSURL *url = [urls firstObject]; | 976 NSURL *url = [urls firstObject]; |
977 char *file = NULL; | 977 char *file = NULL; |
978 | 978 |
979 if(url && [[url absoluteString] length] > 0) | 979 if(url && [[url absoluteString] length] > 0) |
980 file = strdup([[url absoluteString] UTF8String]); | 980 { |
981 const char *tmp = [[url absoluteString] UTF8String]; | |
982 | |
983 if(tmp) | |
984 { | |
985 /* Strip off file:// so it looks the same as other platforms */ | |
986 if(strncmp(tmp, "file://", 7) == 0) | |
987 file = strdup(&tmp[7]); | |
988 else | |
989 file = strdup(tmp); | |
990 } | |
991 } | |
981 dw_dialog_dismiss(dialog, file); | 992 dw_dialog_dismiss(dialog, file); |
982 } | 993 } |
983 -(void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller | 994 -(void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller |
984 { | 995 { |
985 dw_dialog_dismiss(dialog, NULL); | 996 dw_dialog_dismiss(dialog, NULL); |
1088 /* Setup the picker */ | 1099 /* Setup the picker */ |
1089 if(flags & DW_FILE_SAVE) | 1100 if(flags & DW_FILE_SAVE) |
1090 mode = UIDocumentPickerModeExportToService; | 1101 mode = UIDocumentPickerModeExportToService; |
1091 /* Try to generate a UTI for our passed extension */ | 1102 /* Try to generate a UTI for our passed extension */ |
1092 if(ext) | 1103 if(ext) |
1093 UTIs = [NSArray arrayWithObject:[NSString stringWithFormat:@"public.%s", ext]]; | 1104 UTIs = [NSArray arrayWithObjects:[NSString stringWithFormat:@"public.%s", ext], @"public.text", nil]; |
1094 else | 1105 else |
1095 UTIs = @[@"public.text"]; | 1106 UTIs = @[@"public.text"]; |
1096 picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:UTIs inMode:mode]; | 1107 picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:UTIs inMode:mode]; |
1097 [picker setAllowsMultipleSelection:NO]; | 1108 [picker setAllowsMultipleSelection:NO]; |
1098 [picker setShouldShowFileExtensions:YES]; | 1109 [picker setShouldShowFileExtensions:YES]; |