diff options
author | Xan Lopez <xan@src.gnome.org> | 2004-02-12 03:46:15 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2004-02-12 03:46:15 +0800 |
commit | fb5fe4f31dce92934ea16e87799716194d18fa79 (patch) | |
tree | 7b8948706446e58624212f13b8ba1f9fab2f74a7 /embed | |
parent | 41cf817b2b238b15b76cc33ecd377cd756ff8e2a (diff) | |
download | gsoc2013-epiphany-fb5fe4f31dce92934ea16e87799716194d18fa79.tar gsoc2013-epiphany-fb5fe4f31dce92934ea16e87799716194d18fa79.tar.gz gsoc2013-epiphany-fb5fe4f31dce92934ea16e87799716194d18fa79.tar.bz2 gsoc2013-epiphany-fb5fe4f31dce92934ea16e87799716194d18fa79.tar.lz gsoc2013-epiphany-fb5fe4f31dce92934ea16e87799716194d18fa79.tar.xz gsoc2013-epiphany-fb5fe4f31dce92934ea16e87799716194d18fa79.tar.zst gsoc2013-epiphany-fb5fe4f31dce92934ea16e87799716194d18fa79.zip |
Put the serial numbers in duplicated filenames just before the last dot so
* 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.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
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)); |