Mercurial > dwindows
changeset 2800:56eab3a84b62
Android: Add Android specific code to handle opening URIs in dwtest.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 17 Jul 2022 10:17:10 +0000 |
parents | fd7c6ff72383 |
children | b004cc75d574 |
files | dwtest.c |
diffstat | 1 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/dwtest.c Sun Jul 17 00:26:33 2022 +0000 +++ b/dwtest.c Sun Jul 17 10:17:10 2022 +0000 @@ -7,6 +7,10 @@ #include <string.h> #include <stdio.h> #include <errno.h> +#ifdef __ANDROID__ +#include <fcntl.h> +#include <unistd.h> +#endif #include "dw.h" /* For snprintf, strdup etc on old Windows SDK */ #if defined(__WIN32__) || defined(__OS2__) @@ -297,8 +301,18 @@ char *read_file(char *filename) { char *errors = NULL; +#ifdef __ANDROID__ + int fd = -1; - fp = fopen(filename, "r"); + /* Special way to open for URIs on Android */ + if(strstr(filename, "://")) + { + fd = dw_file_open(filename, O_RDONLY); + fp = fdopen(fd, "r"); + } + else +#endif + fp = fopen(filename, "r"); if(!fp) errors = strerror(errno); else @@ -326,6 +340,10 @@ dw_scrollbar_set_range(vscrollbar, num_lines, rows); dw_scrollbar_set_pos(vscrollbar, 0); } +#ifdef __ANDROID__ + if(fd != -1) + close(fd); +#endif return errors; }