aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--embed/mozilla/MozDownload.cpp34
2 files changed, 34 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 66099c179..fd85fc5ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-11 Xan Lopez <xan@gnome.org>
+
+ * embed/mozilla/MozDownload.cpp:
+
+ Put the serial numbers in duplicated filenames just before
+ the last dot so we won't confuse apps like file-roller.
+
2004-02-11 Marco Pesenti Gritti <marco@gnome.org>
* embed/downloader-view.c: (downloader_view_build_ui):
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 66b7077e8..b8c0f1833 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -568,18 +568,38 @@ GetFilePath (const char *filename)
nsresult BuildDownloadPath (const char *defaultFileName, nsILocalFile **_retval)
{
char *path;
- int i = 0;
path = GetFilePath (defaultFileName);
- while (g_file_test (path, G_FILE_TEST_EXISTS))
+ if (g_file_test (path, G_FILE_TEST_EXISTS))
{
- g_free (path);
+ int i = 1;
+ char *dot_pos, *serial = NULL;
+ GString *tmp_path;
+ gssize position;
- char *tmp_path;
- tmp_path = g_strdup_printf ("%s.%d", defaultFileName, ++i);
- path = GetFilePath (tmp_path);
- g_free (tmp_path);
+ dot_pos = g_strrstr (defaultFileName, ".");
+ if (dot_pos)
+ {
+ position = dot_pos - defaultFileName;
+ }
+ else
+ {
+ position = strlen (defaultFileName);
+ }
+ tmp_path = g_string_new (NULL);
+
+ do {
+ g_free (path);
+ g_string_assign (tmp_path, defaultFileName);
+ serial = g_strdup_printf ("(%d)", i++);
+ g_string_insert (tmp_path, position, serial);
+ g_free (serial);
+ path = GetFilePath (tmp_path->str);
+
+ } while (g_file_test (path, G_FILE_TEST_EXISTS));
+
+ g_string_free (tmp_path, TRUE);
}
nsCOMPtr <nsILocalFile> destFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));