From 253c199d1f52c2e86b2c02fad75937aa5e076fd8 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sat, 23 Jul 2005 20:43:37 +0000 Subject: [project @ 2005-07-23 20:43:37 by bursa] Rewrite and simplify url_nice() to improve suggested filenames. Add option to keep extensions (no UI currently). svn path=/import/netsurf/; revision=1814 --- riscos/download.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'riscos/download.c') diff --git a/riscos/download.c b/riscos/download.c index 015ca6fe8..56612075b 100644 --- a/riscos/download.c +++ b/riscos/download.c @@ -32,6 +32,7 @@ #include "oslib/wimpspriteop.h" #include "netsurf/content/fetch.h" #include "netsurf/desktop/gui.h" +#include "netsurf/riscos/options.h" #include "netsurf/riscos/gui.h" #include "netsurf/riscos/query.h" #include "netsurf/riscos/wimp.h" @@ -177,6 +178,7 @@ struct gui_download_window *gui_download_window_create(const char *url, url_func_result res; char *local_path; utf8_convert_ret err; + size_t i; dw = malloc(sizeof *dw); if (!dw) { @@ -242,8 +244,16 @@ struct gui_download_window *gui_download_window_create(const char *url, download_template->icons[ICON_DOWNLOAD_ICON].data.indirected_sprite.id = (osspriteop_id) dw->sprite_name; - if ((res = url_nice(url, &nice)) == URL_FUNC_OK) { - strcpy(dw->path, nice); + if ((res = url_nice(url, &nice, option_strip_extensions)) == + URL_FUNC_OK) { + for (i = 0; nice[i]; i++) { + if (nice[i] == '.') + nice[i] = '/'; + else if (nice[i] <= ' ' || + strchr(":*#$&@^%\\", nice[i])) + nice[i] = '_'; + } + strncpy(dw->path, nice, sizeof dw->path); free(nice); } else @@ -296,7 +306,8 @@ struct gui_download_window *gui_download_window_create(const char *url, ro_gui_dialog_open(dw->window); - /* issue the warning now, so that it appears in front of the download window! */ + /* issue the warning now, so that it appears in front of the download + * window! */ if (space_warning) warn_user("DownloadWarn", messages_get("NoDiscSpace")); -- cgit v1.2.3