summaryrefslogtreecommitdiff
path: root/riscos/download.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2005-07-23 20:43:37 +0000
committerJames Bursa <james@netsurf-browser.org>2005-07-23 20:43:37 +0000
commit253c199d1f52c2e86b2c02fad75937aa5e076fd8 (patch)
tree88f85d97ad434073a74fd1cc254123d179661610 /riscos/download.c
parent4e9457bee1dcadf9f0f20387e59edc970f42c987 (diff)
downloadnetsurf-253c199d1f52c2e86b2c02fad75937aa5e076fd8.tar.gz
netsurf-253c199d1f52c2e86b2c02fad75937aa5e076fd8.tar.bz2
[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
Diffstat (limited to 'riscos/download.c')
-rw-r--r--riscos/download.c17
1 files changed, 14 insertions, 3 deletions
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"));