summaryrefslogtreecommitdiff
path: root/gio/goutputstream.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2009-11-23 15:02:50 +0100
committerAlexander Larsson <alexl@redhat.com>2009-11-23 16:22:52 +0100
commitafe3324fcac8ea2a6b6007c938d7974aa923c0d3 (patch)
tree6e203b038cdd4dbdf92f544c978709a316129456 /gio/goutputstream.c
parent848e0bf760ea7326420669e90ef6675786dea702 (diff)
downloadglib-afe3324fcac8ea2a6b6007c938d7974aa923c0d3.tar.gz
Add g_output_stream_is_closing
Need this to check how we're flushing when closing a converter output stream.
Diffstat (limited to 'gio/goutputstream.c')
-rw-r--r--gio/goutputstream.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/gio/goutputstream.c b/gio/goutputstream.c
index 3406b2916..38d5419c4 100644
--- a/gio/goutputstream.c
+++ b/gio/goutputstream.c
@@ -51,6 +51,7 @@ G_DEFINE_TYPE (GOutputStream, g_output_stream, G_TYPE_OBJECT);
struct _GOutputStreamPrivate {
guint closed : 1;
guint pending : 1;
+ guint closing : 1;
GAsyncReadyCallback outstanding_callback;
};
@@ -520,6 +521,8 @@ g_output_stream_close (GOutputStream *stream,
if (!g_output_stream_set_pending (stream, error))
return FALSE;
+ stream->priv->closing = TRUE;
+
if (cancellable)
g_cancellable_push_current (cancellable);
@@ -545,7 +548,8 @@ g_output_stream_close (GOutputStream *stream,
if (cancellable)
g_cancellable_pop_current (cancellable);
-
+
+ stream->priv->closing = FALSE;
stream->priv->closed = TRUE;
g_output_stream_clear_pending (stream);
@@ -572,6 +576,7 @@ async_ready_close_callback_wrapper (GObject *source_object,
{
GOutputStream *stream = G_OUTPUT_STREAM (source_object);
+ stream->priv->closing = FALSE;
stream->priv->closed = TRUE;
g_output_stream_clear_pending (stream);
if (stream->priv->outstanding_callback)
@@ -982,6 +987,7 @@ g_output_stream_close_async (GOutputStream *stream,
}
class = G_OUTPUT_STREAM_GET_CLASS (stream);
+ stream->priv->closing = TRUE;
stream->priv->outstanding_callback = callback;
g_object_ref (stream);
class->close_async (stream, io_priority, cancellable,
@@ -1042,6 +1048,27 @@ g_output_stream_is_closed (GOutputStream *stream)
}
/**
+ * g_output_stream_is_closing:
+ * @stream: a #GOutputStream.
+ *
+ * Checks if an output stream is being closed. This can be
+ * used inside e.g. a flush implementation to see if the
+ * flush (or other i/o operation) is called from within
+ * the closing operation.
+ *
+ * Returns: %TRUE if @stream is being closed. %FALSE otherwise.
+ *
+ * Since: 2.24
+ **/
+gboolean
+g_output_stream_is_closing (GOutputStream *stream)
+{
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), TRUE);
+
+ return stream->priv->closing;
+}
+
+/**
* g_output_stream_has_pending:
* @stream: a #GOutputStream.
*