aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-stream-fs.c
diff options
context:
space:
mode:
authorBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-02 05:36:42 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-02 05:36:42 +0800
commitc54abe884b175add134cc07e8fda31ffa65cac26 (patch)
treede32af6f25286f1a337d69dc20c7979b841788c5 /camel/camel-stream-fs.c
parent2c543492092832d71f1f677d52a42043c8787be7 (diff)
downloadgsoc2013-evolution-c54abe884b175add134cc07e8fda31ffa65cac26.tar.gz
gsoc2013-evolution-c54abe884b175add134cc07e8fda31ffa65cac26.tar.zst
gsoc2013-evolution-c54abe884b175add134cc07e8fda31ffa65cac26.zip
new memory buffer based stream.
* camel/camel-stream-mem.c: * camel/camel-stream-mem.h: new memory buffer based stream. * camel/camel-stream-fs.c (_seek): implementation for file system based stream. * camel/camel-stream.c (camel_stream_seek): new method. * camel/camel-stream-fs.c (camel_stream_fs_class_init): pass CamelStreamFsClass instead of CamelStreamClass. svn path=/trunk/; revision=1056
Diffstat (limited to 'camel/camel-stream-fs.c')
-rw-r--r--camel/camel-stream-fs.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index 3216f6ffdf..0e006a28f3 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -41,10 +41,11 @@ static void _flush (CamelStream *stream);
static gint _available (CamelStream *stream);
static gboolean _eos (CamelStream *stream);
static void _close (CamelStream *stream);
+static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy);
static void
-camel_stream_fs_class_init (CamelStreamClass *camel_stream_fs_class)
+camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class)
{
CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_fs_class);
parent_class = gtk_type_class (gtk_object_get_type ());
@@ -58,6 +59,7 @@ camel_stream_fs_class_init (CamelStreamClass *camel_stream_fs_class)
camel_stream_class->available = _available;
camel_stream_class->eos = _eos;
camel_stream_class->close = _close;
+ camel_stream_class->seek = _seek;
}
@@ -249,3 +251,26 @@ _close (CamelStream *stream)
{
close ((CAMEL_STREAM_FS (stream))->fd);
}
+
+
+static gint
+_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy)
+{
+ int whence;
+ switch (policy) {
+ case CAMEL_STREAM_SET:
+ whence = SEEK_SET;
+ break;
+ case CAMEL_STREAM_CUR:
+ whence = SEEK_CUR;
+ break;
+ case CAMEL_STREAM_END:
+ whence = SEEK_END;
+ break;
+ default:
+ return -1;
+ }
+
+
+ return lseek ((CAMEL_STREAM_FS (stream))->fd, offset, whence);
+}