summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/vtestream-base.h7
-rw-r--r--src/vtestream-file.h12
-rw-r--r--src/vtestream.h1
3 files changed, 20 insertions, 0 deletions
diff --git a/src/vtestream-base.h b/src/vtestream-base.h
index 8d5e86f..b79179a 100644
--- a/src/vtestream-base.h
+++ b/src/vtestream-base.h
@@ -36,6 +36,7 @@ typedef struct _VteStreamClass {
void (*read) (VteStream *stream, gsize offset, char *data, gsize len);
void (*truncate) (VteStream *stream, gsize offset);
void (*new_page) (VteStream *stream);
+ gsize (*head) (VteStream *stream);
} VteStreamClass;
static GType _vte_stream_get_type (void);
@@ -83,3 +84,9 @@ _vte_stream_new_page (VteStream *stream)
{
VTE_STREAM_GET_CLASS (stream)->new_page (stream);
}
+
+gsize
+_vte_stream_head (VteStream *stream)
+{
+ return VTE_STREAM_GET_CLASS (stream)->head (stream);
+}
diff --git a/src/vtestream-file.h b/src/vtestream-file.h
index 78a0234..f9b7d7c 100644
--- a/src/vtestream-file.h
+++ b/src/vtestream-file.h
@@ -231,6 +231,17 @@ _vte_file_stream_new_page (VteStream *astream)
_xtruncate (stream->fd[0], 0);
}
+static gsize
+_vte_file_stream_head (VteStream *astream)
+{
+ VteFileStream *stream = (VteFileStream *) astream;
+
+ if (stream->fd[0])
+ return stream->offset[0] += lseek (stream->fd[0], 0, SEEK_END);
+ else
+ return stream->offset[0];
+}
+
static void
_vte_file_stream_class_init (VteFileStreamClass *klass)
{
@@ -243,4 +254,5 @@ _vte_file_stream_class_init (VteFileStreamClass *klass)
klass->read = _vte_file_stream_read;
klass->truncate = _vte_file_stream_truncate;
klass->new_page = _vte_file_stream_new_page;
+ klass->head = _vte_file_stream_head;
}
diff --git a/src/vtestream.h b/src/vtestream.h
index 649e8fe..ec45fcc 100644
--- a/src/vtestream.h
+++ b/src/vtestream.h
@@ -32,6 +32,7 @@ gsize _vte_stream_append (VteStream *stream, const char *data, gsize len);
void _vte_stream_read (VteStream *stream, gsize offset, char *data, gsize len);
void _vte_stream_truncate (VteStream *stream, gsize offset);
void _vte_stream_new_page (VteStream *stream);
+gsize _vte_stream_head (VteStream *stream);
/* Various streams */