aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-part-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/camel-mime-part-utils.c')
-rw-r--r--camel/camel-mime-part-utils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 9914964a52..59ae49e595 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -132,3 +132,34 @@ camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part,
+void
+camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part,
+ CamelStream *stream)
+{
+ gint nb_bytes_read_total = 0;
+ gint nb_bytes_read_chunk;
+ GByteArray *buffer;
+#define STREAM_READ_CHUNK_SZ 100
+
+ if (mime_part->temp_message_buffer == NULL)
+ mime_part->temp_message_buffer = g_byte_array_new ();
+
+ buffer = mime_part->temp_message_buffer;
+
+ g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ);
+ nb_bytes_read_chunk = camel_stream_read (stream,
+ buffer->data + nb_bytes_read_total,
+ STREAM_READ_CHUNK_SZ);
+ nb_bytes_read_total += nb_bytes_read_chunk;
+
+ while (nb_bytes_read_chunk) {
+ g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ);
+ nb_bytes_read_chunk = camel_stream_read (stream,
+ buffer->data + nb_bytes_read_total,
+ STREAM_READ_CHUNK_SZ);
+ nb_bytes_read_total += nb_bytes_read_chunk;
+ }
+
+ g_byte_array_set_size (buffer, nb_bytes_read_total);
+
+}