diff options
author | Peter Hofmann <scm@uninformativ.de> | 2015-12-06 09:53:37 +0100 |
---|---|---|
committer | Peter Hofmann <scm@uninformativ.de> | 2015-12-06 09:53:37 +0100 |
commit | 0f0c693a6be637d3f8c4d602a3e690afd4aebf2a (patch) | |
tree | 01b8f7abd0ffc5210bdc2c223edfffc52c453b60 | |
parent | 3fb92e08feee3112d54f7ffb48f75eab64cf6dcd (diff) | |
download | lariza-0f0c693a6be637d3f8c4d602a3e690afd4aebf2a.tar.gz |
Strip G_DIR_SEPARATOR from local file names
Closes #15.
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | browser.c | 13 |
2 files changed, 14 insertions, 3 deletions
@@ -1,6 +1,10 @@ Release history for lariza next + [Fixed] + - Issue #15: lariza no longer tries to create local file names with + directory separators in them when downloading files. + [Changed] - For the sake of consistency, $LARIZA_WEB_EXTENSIONS_DIR has been removed. @@ -394,11 +394,17 @@ download_handle_start(WebKitWebView *web_view, WebKitDownload *download, gboolean download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer data) { - gchar *path, *path2 = NULL, *uri; + gchar *sug_clean, *path, *path2 = NULL, *uri; GtkToolItem *tb; int suffix = 1; + size_t i; - path = g_build_filename(download_dir, suggested_filename, NULL); + sug_clean = g_strdup(suggested_filename); + for (i = 0; i < strlen(sug_clean); i++) + if (sug_clean[i] == G_DIR_SEPARATOR) + sug_clean[i] = '_'; + + path = g_build_filename(download_dir, sug_clean, NULL); path2 = g_strdup(path); while (g_file_test(path2, G_FILE_TEST_EXISTS) && suffix < 1000) { @@ -421,7 +427,7 @@ download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer da tb = gtk_tool_button_new(NULL, NULL); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(tb), "gtk-delete"); - gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), suggested_filename); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), sug_clean); gtk_toolbar_insert(GTK_TOOLBAR(dm.toolbar), tb, 0); gtk_widget_show_all(dm.win); @@ -433,6 +439,7 @@ download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer da G_CALLBACK(downloadmanager_cancel), download); } + g_free(sug_clean); g_free(path); g_free(path2); |