aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2005-12-17 22:00:22 +0800
committerTor Lillqvist <tml@src.gnome.org>2005-12-17 22:00:22 +0800
commiteeaa2f9ce13ff946b5a8cb40144da89779c0d1b3 (patch)
treeb62e1df814d74ac4c3452470b54ceb78bfb00786 /calendar/gui
parent0d3ac595d63a382092b2d76d898d757e7ada0c70 (diff)
downloadgsoc2013-evolution-eeaa2f9ce13ff946b5a8cb40144da89779c0d1b3.tar
gsoc2013-evolution-eeaa2f9ce13ff946b5a8cb40144da89779c0d1b3.tar.gz
gsoc2013-evolution-eeaa2f9ce13ff946b5a8cb40144da89779c0d1b3.tar.bz2
gsoc2013-evolution-eeaa2f9ce13ff946b5a8cb40144da89779c0d1b3.tar.lz
gsoc2013-evolution-eeaa2f9ce13ff946b5a8cb40144da89779c0d1b3.tar.xz
gsoc2013-evolution-eeaa2f9ce13ff946b5a8cb40144da89779c0d1b3.tar.zst
gsoc2013-evolution-eeaa2f9ce13ff946b5a8cb40144da89779c0d1b3.zip
: Use gstdio wrappers. Use g_filename_from_uri()
2005-12-17 Tor Lillqvist <tml@novell.com> * gui/dialogs/comp-editor.c: : Use gstdio wrappers. Use g_filename_from_uri() svn path=/trunk/; revision=30817
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/dialogs/comp-editor.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index ba99ce60f4..82c83d16ac 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -28,6 +28,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <glib.h>
+#include <glib/gstdio.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkstock.h>
#include <bonobo/bonobo-ui-util.h>
@@ -635,12 +636,14 @@ get_attachment_list (CompEditor *editor)
g_free (safe_fname);
/* do not overwrite existing files, this will result in truncation */
- if (!g_file_test (attach_file_url+7, G_FILE_TEST_EXISTS)) {
- stream = camel_stream_fs_new_with_name((const char *) attach_file_url+7, O_RDWR|O_CREAT|O_TRUNC, 0600);
+ filename = g_filename_from_uri (attach_file_url, NULL, NULL);
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ stream = camel_stream_fs_new_with_name(filename, O_RDWR|O_CREAT|O_TRUNC, 0600);
if (!stream) {
/* TODO handle error conditions */
g_message ("DEBUG: could not open the file to write\n");
g_free (attach_file_url);
+ g_free (filename);
continue;
}
@@ -657,6 +660,7 @@ get_attachment_list (CompEditor *editor)
list = g_slist_append (list, g_strdup (attach_file_url));
g_free (attach_file_url);
+ g_free (filename);
}
if (parts)
@@ -2210,22 +2214,25 @@ set_attachment_list (CompEditor *editor, GSList *attach_list)
*/
/* get url sans protocol and add it to the bar.
* how to set the filename properly */
- file_name = attach_filename +7;
+ file_name = g_filename_from_uri (attach_filename, NULL, NULL);
- if (stat (file_name, &statbuf) < 0) {
+ if (g_stat (file_name, &statbuf) < 0) {
g_warning ("Cannot attach file %s: %s", file_name, g_strerror (errno));
+ g_free (file_name);
continue;
}
/* return if it's not a regular file */
if (!S_ISREG (statbuf.st_mode)) {
g_warning ("Cannot attach file %s: not a regular file", file_name);
+ g_free (file_name);
return;
}
stream = camel_stream_fs_new_with_name (file_name, O_RDONLY, 0);
if (!stream) {
g_warning ("Cannot attach file %s: %s", file_name, g_strerror (errno));
+ g_free (file_name);
return;
}
@@ -2245,7 +2252,8 @@ set_attachment_list (CompEditor *editor, GSList *attach_list)
camel_data_wrapper_construct_from_stream (wrapper, stream);
camel_data_wrapper_set_mime_type (wrapper, "application/octet-stream");
}
-
+ g_free (file_name);
+
camel_object_unref (stream);
part = camel_mime_part_new ();