diff options
Diffstat (limited to 'composer/e-msg-composer-attachment.c')
-rw-r--r-- | composer/e-msg-composer-attachment.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index 49af8bc122..0b2d08aec9 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -28,6 +28,7 @@ attachment manually. */ #include <sys/stat.h> +#include <errno.h> #include <gtk/gtknotebook.h> #include <gtk/gtktogglebutton.h> @@ -143,12 +144,14 @@ e_msg_composer_attachment_get_type (void) * e_msg_composer_attachment_new: * @file_name: filename to attach * @disposition: Content-Disposition of the attachment + * @ex: exception * * Return value: the new attachment, or %NULL on error **/ EMsgComposerAttachment * -e_msg_composer_attachment_new (const gchar *file_name, - const gchar *disposition) +e_msg_composer_attachment_new (const char *file_name, + const char *disposition, + CamelException *ex) { EMsgComposerAttachment *new; CamelMimePart *part; @@ -160,16 +163,28 @@ e_msg_composer_attachment_new (const gchar *file_name, g_return_val_if_fail (file_name != NULL, NULL); - if (stat (file_name, &statbuf) < 0) + if (stat (file_name, &statbuf) < 0) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot attach file %s: %s"), + file_name, g_strerror (errno)); return NULL; + } /* return if it's not a regular file */ - if (!S_ISREG (statbuf.st_mode)) + if (!S_ISREG (statbuf.st_mode)) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot attach file %s: not a regular file"), + file_name); return NULL; + } stream = camel_stream_fs_new_with_name (file_name, O_RDONLY, 0); - if (!stream) + if (!stream) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot attach file %s: %s"), + file_name, g_strerror (errno)); return NULL; + } wrapper = camel_data_wrapper_new (); camel_data_wrapper_construct_from_stream (wrapper, stream); camel_object_unref (CAMEL_OBJECT (stream)); |