Mercurial > HandyFTP
changeset 157:35d2bf9ae680
Android: Add Android specific code to open URIs.
author | Brian Smith <brian@dbsoft.org> |
---|---|
date | Sun, 17 Jul 2022 05:57:20 -0500 |
parents | 49dbea50b32a |
children | 3b95a19f0764 |
files | src/handyftp.c |
diffstat | 1 files changed, 33 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/handyftp.c Tue Jun 28 03:58:56 2022 -0500 +++ b/src/handyftp.c Sun Jul 17 05:57:20 2022 -0500 @@ -551,8 +551,18 @@ void savequeue(SiteTab *thissite, char *filename) { FILE *fp; - - if((fp = fopen(filename, "w")) != NULL) +#ifdef __ANDROID__ + int fd = -1; + + if(strstr(filename, "://")) + { + fd = dw_file_open(filename, O_WRONLY); + fp = fdopen(fd, "w"); + } + else +#endif + fp = fopen(filename, "w"); + if(fp != NULL) { Queue *tmp = thissite->queue; @@ -570,6 +580,10 @@ } fclose(fp); } +#ifdef __ANDROID__ + if(fd != -1) + close(fd); +#endif } /* Removes the newline char from a string */ @@ -633,10 +647,20 @@ /* Load the contents of the saved queue to the site queue */ void loadqueue(SiteTab *thissite, char *filename) { + char buf[1001] = {0}; FILE *fp; - char buf[1001] = ""; - - if((fp = fopen(filename, "r")) != NULL && fgets(buf, 1000, fp) != NULL) +#ifdef __ANDROID__ + int fd = -1; + + if(strstr(filename, "://")) + { + fd = dw_file_open(filename, O_RDONLY); + fp = fdopen(fd, "r"); + } + else +#endif + fp = fopen(filename, "r"); + if(fp != NULL && fgets(buf, 1000, fp) != NULL) { trimnewline(buf); @@ -647,7 +671,6 @@ return; } - while(!feof(fp)) { Queue *thisq; @@ -709,6 +732,10 @@ } if(fp) fclose(fp); +#ifdef __ANDROID__ + if(fd != -1) + close(fd); +#endif } /* Adds a directory listing to the current cache, removing