aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-stream-fs.c
diff options
context:
space:
mode:
authorBertrand Guiheneuf <bertrand@src.gnome.org>1999-06-19 04:32:18 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-06-19 04:32:18 +0800
commit19a118096fe6f3d7b79a0fe3cb6e5bfe50ef8767 (patch)
tree04f063fc3c18e43eea5251943be93fa89cfd5549 /camel/camel-stream-fs.c
parent499ae51b86891889ffb5fd9954b1f60efcadfed2 (diff)
downloadgsoc2013-evolution-19a118096fe6f3d7b79a0fe3cb6e5bfe50ef8767.tar
gsoc2013-evolution-19a118096fe6f3d7b79a0fe3cb6e5bfe50ef8767.tar.gz
gsoc2013-evolution-19a118096fe6f3d7b79a0fe3cb6e5bfe50ef8767.tar.bz2
gsoc2013-evolution-19a118096fe6f3d7b79a0fe3cb6e5bfe50ef8767.tar.lz
gsoc2013-evolution-19a118096fe6f3d7b79a0fe3cb6e5bfe50ef8767.tar.xz
gsoc2013-evolution-19a118096fe6f3d7b79a0fe3cb6e5bfe50ef8767.tar.zst
gsoc2013-evolution-19a118096fe6f3d7b79a0fe3cb6e5bfe50ef8767.zip
Commit of all Netherlands changes.
All mime stuff uses streams now, and it still works. Bertrand svn path=/trunk/; revision=981
Diffstat (limited to 'camel/camel-stream-fs.c')
-rw-r--r--camel/camel-stream-fs.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index 0a42e5062f..c7335f9821 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -27,6 +27,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
+#include "camel-log.h"
static CamelStreamClass *parent_class=NULL;
@@ -95,21 +96,27 @@ camel_stream_fs_new_with_name (GString *name, CamelStreamFsMode mode)
int flags;
CamelStreamFs *stream_fs;
- if (!name) return NULL;
-
+ g_assert (name);
+ g_assert (name->str);
+ CAMEL_LOG (FULL_DEBUG, "Entering CamelStream::new_with_name, name=\"%s\", mode=%d\n", name->str, mode);
v = stat (name->str, &s);
-
+
if (mode & CAMEL_STREAM_FS_READ)
- if (mode & CAMEL_STREAM_FS_WRITE) flags = O_RDWR;
+ if (mode & CAMEL_STREAM_FS_WRITE) flags = O_RDWR | O_CREAT;
else flags = O_RDONLY;
else
- if (mode & CAMEL_STREAM_FS_WRITE) flags = O_WRONLY;
+ if (mode & CAMEL_STREAM_FS_WRITE) flags = O_WRONLY | O_CREAT;
else return NULL;
- if (mode & CAMEL_STREAM_FS_READ)
+ if ( (mode & CAMEL_STREAM_FS_READ) && !(mode & CAMEL_STREAM_FS_WRITE) )
if (v == -1) return NULL;
fd = open (name->str, flags);
+ if (fd==-1) {
+ CAMEL_LOG (FULL_DEBUG, "CamelStreamFs::new_with_name can not obtain fd for file \"%s\"\n", name->str);
+ CAMEL_LOG (FULL_DEBUG, " Full error text is : %s\n", strerror(errno));
+ return NULL;
+ }
stream_fs = CAMEL_STREAM_FS (camel_stream_fs_new_with_fd (fd));
stream_fs->name = name;
@@ -123,6 +130,7 @@ camel_stream_fs_new_with_fd (int fd)
{
CamelStreamFs *stream_fs;
+ CAMEL_LOG (FULL_DEBUG, "Entering CamelStream::new_with_fd fd=%d\n",fd);
stream_fs = gtk_type_new (camel_stream_fs_get_type ());
stream_fs->fd = fd;
return CAMEL_STREAM (stream_fs);
@@ -166,11 +174,19 @@ static gint
_write (CamelStream *stream, gchar *buffer, gint n)
{
int v;
-
+ g_assert (stream);
+ g_assert ((CAMEL_STREAM_FS (stream))->fd);
+ CAMEL_LOG (FULL_DEBUG, "CamelStreamFs:: entering write. n=%d\n", n);
do {
v = write ( (CAMEL_STREAM_FS (stream))->fd, buffer, n);
} while (v == -1 && errno == EINTR);
+#if HARD_LOG_LEVEL >= FULL_DEBUG
+ if (v==-1) {
+ perror("");
+ CAMEL_LOG (FULL_DEBUG, "CamelStreamFs::write could not write bytes in stream\n");
+ }
+#endif
return v;
}