~ubuntu-branches/debian/squeeze/glib2.0/squeeze

« back to all changes in this revision

Viewing changes to gio/goutputstream.c

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2009-02-15 13:00:43 UTC
  • mfrom: (1.3.1 upstream) (69.1.10 intrepid)
  • Revision ID: james.westby@ubuntu.com-20090215130043-q47fbt3owmt42m2f
Tags: 2.18.4-2
* Release to unstable
* debian/rules:
- bump SHVER, since we are already forcing a 2.18.0 dependecy on the
  symbols introduced in the development versions
* debian/control.in:
- added Homepage and Vcs-* control fields

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * Author: Alexander Larsson <alexl@redhat.com>
21
21
 */
22
22
 
23
 
#include <config.h>
 
23
#include "config.h"
24
24
#include "goutputstream.h"
 
25
#include "gcancellable.h"
 
26
#include "gasyncresult.h"
25
27
#include "gsimpleasyncresult.h"
 
28
#include "ginputstream.h"
 
29
#include "gioerror.h"
26
30
#include "glibintl.h"
27
31
 
28
32
#include "gioalias.h"
32
36
 * @short_description: Base class for implementing streaming output
33
37
 * @include: gio/gio.h
34
38
 *
35
 
 *
 
39
 * GOutputStream has functions to write to a stream (g_output_stream_write()),
 
40
 * to close a stream (g_output_stream_close()) and to flush pending writes
 
41
 * (g_output_stream_flush()). 
 
42
 *
 
43
 * To copy the content of an input stream to an output stream without 
 
44
 * manually handling the reads and writes, use g_output_stream_splice(). 
 
45
 *
 
46
 * All of these functions have async variants too.
36
47
 **/
37
48
 
38
49
G_DEFINE_TYPE (GOutputStream, g_output_stream, G_TYPE_OBJECT);
92
103
  GOutputStream *stream;
93
104
 
94
105
  stream = G_OUTPUT_STREAM (object);
95
 
  
96
 
  if (G_OBJECT_CLASS (g_output_stream_parent_class)->finalize)
97
 
    (*G_OBJECT_CLASS (g_output_stream_parent_class)->finalize) (object);
 
106
 
 
107
  G_OBJECT_CLASS (g_output_stream_parent_class)->finalize (object);
98
108
}
99
109
 
100
110
static void
106
116
  
107
117
  if (!stream->priv->closed)
108
118
    g_output_stream_close (stream, NULL, NULL);
109
 
  
110
 
  if (G_OBJECT_CLASS (g_output_stream_parent_class)->dispose)
111
 
    (*G_OBJECT_CLASS (g_output_stream_parent_class)->dispose) (object);
 
119
 
 
120
  G_OBJECT_CLASS (g_output_stream_parent_class)->dispose (object);
112
121
}
113
122
 
114
123
static void
198
207
 
199
208
  if (class->write_fn == NULL) 
200
209
    {
201
 
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
202
 
                   _("Output stream doesn't implement write"));
 
210
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
 
211
                           _("Output stream doesn't implement write"));
203
212
      return -1;
204
213
    }
205
214
  
359
368
 
360
369
  if (g_input_stream_is_closed (source))
361
370
    {
362
 
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
363
 
                   _("Source stream is already closed"));
 
371
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
 
372
                           _("Source stream is already closed"));
364
373
      return -1;
365
374
    }
366
375
 
399
408
  bytes_copied = 0;
400
409
  if (class->write_fn == NULL) 
401
410
    {
402
 
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
403
 
                   _("Output stream doesn't implement write"));
 
411
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
 
412
                           _("Output stream doesn't implement write"));
404
413
      res = FALSE;
405
414
      goto notsupported;
406
415
    }
1072
1081
  
1073
1082
  if (stream->priv->closed)
1074
1083
    {
1075
 
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
1076
 
                   _("Stream is already closed"));
 
1084
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
 
1085
                           _("Stream is already closed"));
1077
1086
      return FALSE;
1078
1087
    }
1079
1088
  
1080
1089
  if (stream->priv->pending)
1081
1090
    {
1082
 
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
1083
 
                      /* Translators: This is an error you get if there is
1084
 
                       * already an operation running against this stream when
1085
 
                       * you try to start one */
1086
 
                      _("Stream has outstanding operation"));
 
1091
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PENDING,
 
1092
                           /* Translators: This is an error you get if there is
 
1093
                            * already an operation running against this stream when
 
1094
                            * you try to start one */
 
1095
                           _("Stream has outstanding operation"));
1087
1096
      return FALSE;
1088
1097
    }
1089
1098