# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1617966351 0 # Node ID a773008c7c5d26aec30692fc63214523b202dcd5 # Parent ba24ddb19a435209fafae0d1edfd771a037c88f2 iOS: Make sure the plain text UTI is used with filePicker. Also strip off the "file://" prefixing the file path returned. diff -r ba24ddb19a43 -r a773008c7c5d dwtest.c --- a/dwtest.c Fri Apr 09 10:01:22 2021 +0000 +++ b/dwtest.c Fri Apr 09 11:05:51 2021 +0000 @@ -290,16 +290,16 @@ return TRUE; } -void read_file( void ) +void read_file(void) { int i,len; fp = fopen(current_file, "r" ); if(fp) { - lp = (char **)calloc( 1000,sizeof(char *)); + lp = (char **)calloc(1000,sizeof(char *)); /* should test for out of memory */ max_linewidth=0; - for(i = 0; i < 1000; i++) + for(i=0; i<1000; i++) { lp[i] = (char *)calloc(1, 1025); if (fgets( lp[i], 1024, fp ) == NULL) diff -r ba24ddb19a43 -r a773008c7c5d ios/dw.m --- a/ios/dw.m Fri Apr 09 10:01:22 2021 +0000 +++ b/ios/dw.m Fri Apr 09 11:05:51 2021 +0000 @@ -977,7 +977,18 @@ char *file = NULL; if(url && [[url absoluteString] length] > 0) - file = strdup([[url absoluteString] UTF8String]); + { + const char *tmp = [[url absoluteString] UTF8String]; + + if(tmp) + { + /* Strip off file:// so it looks the same as other platforms */ + if(strncmp(tmp, "file://", 7) == 0) + file = strdup(&tmp[7]); + else + file = strdup(tmp); + } + } dw_dialog_dismiss(dialog, file); } -(void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller @@ -1090,7 +1101,7 @@ mode = UIDocumentPickerModeExportToService; /* Try to generate a UTI for our passed extension */ if(ext) - UTIs = [NSArray arrayWithObject:[NSString stringWithFormat:@"public.%s", ext]]; + UTIs = [NSArray arrayWithObjects:[NSString stringWithFormat:@"public.%s", ext], @"public.text", nil]; else UTIs = @[@"public.text"]; picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:UTIs inMode:mode];