1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.OutputStream;
26 
27 private import gio.AsyncResultIF;
28 private import gio.Cancellable;
29 private import gio.InputStream;
30 private import glib.Bytes;
31 private import glib.ErrorG;
32 private import glib.GException;
33 private import glib.Str;
34 private import gobject.ObjectG;
35 private import gtkc.gio;
36 public  import gtkc.giotypes;
37 
38 
39 /**
40  * #GOutputStream has functions to write to a stream (g_output_stream_write()),
41  * to close a stream (g_output_stream_close()) and to flush pending writes
42  * (g_output_stream_flush()).
43  * 
44  * To copy the content of an input stream to an output stream without
45  * manually handling the reads and writes, use g_output_stream_splice().
46  * 
47  * All of these functions have async variants too.
48  */
49 public class OutputStream : ObjectG
50 {
51 	/** the main Gtk struct */
52 	protected GOutputStream* gOutputStream;
53 
54 	/** Get the main Gtk struct */
55 	public GOutputStream* getOutputStreamStruct()
56 	{
57 		return gOutputStream;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gOutputStream;
64 	}
65 
66 	protected override void setStruct(GObject* obj)
67 	{
68 		gOutputStream = cast(GOutputStream*)obj;
69 		super.setStruct(obj);
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GOutputStream* gOutputStream, bool ownedRef = false)
76 	{
77 		this.gOutputStream = gOutputStream;
78 		super(cast(GObject*)gOutputStream, ownedRef);
79 	}
80 
81 	/**
82 	 */
83 
84 	public static GType getType()
85 	{
86 		return g_output_stream_get_type();
87 	}
88 
89 	/**
90 	 * Clears the pending flag on @stream.
91 	 */
92 	public void clearPending()
93 	{
94 		g_output_stream_clear_pending(gOutputStream);
95 	}
96 
97 	/**
98 	 * Closes the stream, releasing resources related to it.
99 	 *
100 	 * Once the stream is closed, all other operations will return %G_IO_ERROR_CLOSED.
101 	 * Closing a stream multiple times will not return an error.
102 	 *
103 	 * Closing a stream will automatically flush any outstanding buffers in the
104 	 * stream.
105 	 *
106 	 * Streams will be automatically closed when the last reference
107 	 * is dropped, but you might want to call this function to make sure
108 	 * resources are released as early as possible.
109 	 *
110 	 * Some streams might keep the backing store of the stream (e.g. a file descriptor)
111 	 * open after the stream is closed. See the documentation for the individual
112 	 * stream for details.
113 	 *
114 	 * On failure the first error that happened will be reported, but the close
115 	 * operation will finish as much as possible. A stream that failed to
116 	 * close will still return %G_IO_ERROR_CLOSED for all operations. Still, it
117 	 * is important to check and report the error to the user, otherwise
118 	 * there might be a loss of data as all data might not be written.
119 	 *
120 	 * If @cancellable is not %NULL, then the operation can be cancelled by
121 	 * triggering the cancellable object from another thread. If the operation
122 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
123 	 * Cancelling a close will still leave the stream closed, but there some streams
124 	 * can use a faster close that doesn't block to e.g. check errors. On
125 	 * cancellation (as with any error) there is no guarantee that all written
126 	 * data will reach the target.
127 	 *
128 	 * Params:
129 	 *     cancellable = optional cancellable object
130 	 *
131 	 * Return: %TRUE on success, %FALSE on failure
132 	 *
133 	 * Throws: GException on failure.
134 	 */
135 	public bool close(Cancellable cancellable)
136 	{
137 		GError* err = null;
138 		
139 		auto p = g_output_stream_close(gOutputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
140 		
141 		if (err !is null)
142 		{
143 			throw new GException( new ErrorG(err) );
144 		}
145 		
146 		return p;
147 	}
148 
149 	/**
150 	 * Requests an asynchronous close of the stream, releasing resources
151 	 * related to it. When the operation is finished @callback will be
152 	 * called. You can then call g_output_stream_close_finish() to get
153 	 * the result of the operation.
154 	 *
155 	 * For behaviour details see g_output_stream_close().
156 	 *
157 	 * The asyncronous methods have a default fallback that uses threads
158 	 * to implement asynchronicity, so they are optional for inheriting
159 	 * classes. However, if you override one you must override all.
160 	 *
161 	 * Params:
162 	 *     ioPriority = the io priority of the request.
163 	 *     cancellable = optional cancellable object
164 	 *     callback = callback to call when the request is satisfied
165 	 *     userData = the data to pass to callback function
166 	 */
167 	public void closeAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
168 	{
169 		g_output_stream_close_async(gOutputStream, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
170 	}
171 
172 	/**
173 	 * Closes an output stream.
174 	 *
175 	 * Params:
176 	 *     result = a #GAsyncResult.
177 	 *
178 	 * Return: %TRUE if stream was successfully closed, %FALSE otherwise.
179 	 *
180 	 * Throws: GException on failure.
181 	 */
182 	public bool closeFinish(AsyncResultIF result)
183 	{
184 		GError* err = null;
185 		
186 		auto p = g_output_stream_close_finish(gOutputStream, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
187 		
188 		if (err !is null)
189 		{
190 			throw new GException( new ErrorG(err) );
191 		}
192 		
193 		return p;
194 	}
195 
196 	/**
197 	 * Forces a write of all user-space buffered data for the given
198 	 * @stream. Will block during the operation. Closing the stream will
199 	 * implicitly cause a flush.
200 	 *
201 	 * This function is optional for inherited classes.
202 	 *
203 	 * If @cancellable is not %NULL, then the operation can be cancelled by
204 	 * triggering the cancellable object from another thread. If the operation
205 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
206 	 *
207 	 * Params:
208 	 *     cancellable = optional cancellable object
209 	 *
210 	 * Return: %TRUE on success, %FALSE on error
211 	 *
212 	 * Throws: GException on failure.
213 	 */
214 	public bool flush(Cancellable cancellable)
215 	{
216 		GError* err = null;
217 		
218 		auto p = g_output_stream_flush(gOutputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
219 		
220 		if (err !is null)
221 		{
222 			throw new GException( new ErrorG(err) );
223 		}
224 		
225 		return p;
226 	}
227 
228 	/**
229 	 * Forces an asynchronous write of all user-space buffered data for
230 	 * the given @stream.
231 	 * For behaviour details see g_output_stream_flush().
232 	 *
233 	 * When the operation is finished @callback will be
234 	 * called. You can then call g_output_stream_flush_finish() to get the
235 	 * result of the operation.
236 	 *
237 	 * Params:
238 	 *     ioPriority = the io priority of the request.
239 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
240 	 *     callback = a #GAsyncReadyCallback to call when the request is satisfied
241 	 *     userData = the data to pass to callback function
242 	 */
243 	public void flushAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
244 	{
245 		g_output_stream_flush_async(gOutputStream, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
246 	}
247 
248 	/**
249 	 * Finishes flushing an output stream.
250 	 *
251 	 * Params:
252 	 *     result = a GAsyncResult.
253 	 *
254 	 * Return: %TRUE if flush operation succeeded, %FALSE otherwise.
255 	 *
256 	 * Throws: GException on failure.
257 	 */
258 	public bool flushFinish(AsyncResultIF result)
259 	{
260 		GError* err = null;
261 		
262 		auto p = g_output_stream_flush_finish(gOutputStream, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
263 		
264 		if (err !is null)
265 		{
266 			throw new GException( new ErrorG(err) );
267 		}
268 		
269 		return p;
270 	}
271 
272 	/**
273 	 * Checks if an ouput stream has pending actions.
274 	 *
275 	 * Return: %TRUE if @stream has pending actions.
276 	 */
277 	public bool hasPending()
278 	{
279 		return g_output_stream_has_pending(gOutputStream) != 0;
280 	}
281 
282 	/**
283 	 * Checks if an output stream has already been closed.
284 	 *
285 	 * Return: %TRUE if @stream is closed. %FALSE otherwise.
286 	 */
287 	public bool isClosed()
288 	{
289 		return g_output_stream_is_closed(gOutputStream) != 0;
290 	}
291 
292 	/**
293 	 * Checks if an output stream is being closed. This can be
294 	 * used inside e.g. a flush implementation to see if the
295 	 * flush (or other i/o operation) is called from within
296 	 * the closing operation.
297 	 *
298 	 * Return: %TRUE if @stream is being closed. %FALSE otherwise.
299 	 *
300 	 * Since: 2.24
301 	 */
302 	public bool isClosing()
303 	{
304 		return g_output_stream_is_closing(gOutputStream) != 0;
305 	}
306 
307 	/**
308 	 * Sets @stream to have actions pending. If the pending flag is
309 	 * already set or @stream is closed, it will return %FALSE and set
310 	 * @error.
311 	 *
312 	 * Return: %TRUE if pending was previously unset and is now set.
313 	 *
314 	 * Throws: GException on failure.
315 	 */
316 	public bool setPending()
317 	{
318 		GError* err = null;
319 		
320 		auto p = g_output_stream_set_pending(gOutputStream, &err) != 0;
321 		
322 		if (err !is null)
323 		{
324 			throw new GException( new ErrorG(err) );
325 		}
326 		
327 		return p;
328 	}
329 
330 	/**
331 	 * Splices an input stream into an output stream.
332 	 *
333 	 * Params:
334 	 *     source = a #GInputStream.
335 	 *     flags = a set of #GOutputStreamSpliceFlags.
336 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
337 	 *
338 	 * Return: a #gssize containing the size of the data spliced, or
339 	 *     -1 if an error occurred. Note that if the number of bytes
340 	 *     spliced is greater than %G_MAXSSIZE, then that will be
341 	 *     returned, and there is no way to determine the actual number
342 	 *     of bytes spliced.
343 	 *
344 	 * Throws: GException on failure.
345 	 */
346 	public ptrdiff_t splice(InputStream source, GOutputStreamSpliceFlags flags, Cancellable cancellable)
347 	{
348 		GError* err = null;
349 		
350 		auto p = g_output_stream_splice(gOutputStream, (source is null) ? null : source.getInputStreamStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
351 		
352 		if (err !is null)
353 		{
354 			throw new GException( new ErrorG(err) );
355 		}
356 		
357 		return p;
358 	}
359 
360 	/**
361 	 * Splices a stream asynchronously.
362 	 * When the operation is finished @callback will be called.
363 	 * You can then call g_output_stream_splice_finish() to get the
364 	 * result of the operation.
365 	 *
366 	 * For the synchronous, blocking version of this function, see
367 	 * g_output_stream_splice().
368 	 *
369 	 * Params:
370 	 *     source = a #GInputStream.
371 	 *     flags = a set of #GOutputStreamSpliceFlags.
372 	 *     ioPriority = the io priority of the request.
373 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
374 	 *     callback = a #GAsyncReadyCallback.
375 	 *     userData = user data passed to @callback.
376 	 */
377 	public void spliceAsync(InputStream source, GOutputStreamSpliceFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
378 	{
379 		g_output_stream_splice_async(gOutputStream, (source is null) ? null : source.getInputStreamStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
380 	}
381 
382 	/**
383 	 * Finishes an asynchronous stream splice operation.
384 	 *
385 	 * Params:
386 	 *     result = a #GAsyncResult.
387 	 *
388 	 * Return: a #gssize of the number of bytes spliced. Note that if the
389 	 *     number of bytes spliced is greater than %G_MAXSSIZE, then that
390 	 *     will be returned, and there is no way to determine the actual
391 	 *     number of bytes spliced.
392 	 *
393 	 * Throws: GException on failure.
394 	 */
395 	public ptrdiff_t spliceFinish(AsyncResultIF result)
396 	{
397 		GError* err = null;
398 		
399 		auto p = g_output_stream_splice_finish(gOutputStream, (result is null) ? null : result.getAsyncResultStruct(), &err);
400 		
401 		if (err !is null)
402 		{
403 			throw new GException( new ErrorG(err) );
404 		}
405 		
406 		return p;
407 	}
408 
409 	/**
410 	 * This is a utility function around g_output_stream_write_all(). It
411 	 * uses g_strdup_vprintf() to turn @format and @args into a string that
412 	 * is then written to @stream.
413 	 *
414 	 * See the documentation of g_output_stream_write_all() about the
415 	 * behavior of the actual write operation.
416 	 *
417 	 * Note that partial writes cannot be properly checked with this
418 	 * function due to the variable length of the written string, if you
419 	 * need precise control over partial write failures, you need to
420 	 * create you own printf()-like wrapper around g_output_stream_write()
421 	 * or g_output_stream_write_all().
422 	 *
423 	 * Params:
424 	 *     bytesWritten = location to store the number of bytes that was
425 	 *         written to the stream
426 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
427 	 *     error = location to store the error occurring, or %NULL to ignore
428 	 *     format = the format string. See the printf() documentation
429 	 *     args = the parameters to insert into the format string
430 	 *
431 	 * Return: %TRUE on success, %FALSE if there was an error
432 	 *
433 	 * Since: 2.40
434 	 */
435 	public bool vprintf(out size_t bytesWritten, Cancellable cancellable, out ErrorG error, string format, void* args)
436 	{
437 		GError* outerror = null;
438 		
439 		auto p = g_output_stream_vprintf(gOutputStream, &bytesWritten, (cancellable is null) ? null : cancellable.getCancellableStruct(), &outerror, Str.toStringz(format), args) != 0;
440 		
441 		error = new ErrorG(outerror);
442 		
443 		return p;
444 	}
445 
446 	/**
447 	 * Tries to write @count bytes from @buffer into the stream. Will block
448 	 * during the operation.
449 	 *
450 	 * If count is 0, returns 0 and does nothing. A value of @count
451 	 * larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.
452 	 *
453 	 * On success, the number of bytes written to the stream is returned.
454 	 * It is not an error if this is not the same as the requested size, as it
455 	 * can happen e.g. on a partial I/O error, or if there is not enough
456 	 * storage in the stream. All writes block until at least one byte
457 	 * is written or an error occurs; 0 is never returned (unless
458 	 * @count is 0).
459 	 *
460 	 * If @cancellable is not %NULL, then the operation can be cancelled by
461 	 * triggering the cancellable object from another thread. If the operation
462 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
463 	 * operation was partially finished when the operation was cancelled the
464 	 * partial result will be returned, without an error.
465 	 *
466 	 * On error -1 is returned and @error is set accordingly.
467 	 *
468 	 * Params:
469 	 *     buffer = the buffer containing the data to write.
470 	 *     count = the number of bytes to write
471 	 *     cancellable = optional cancellable object
472 	 *
473 	 * Return: Number of bytes written, or -1 on error
474 	 *
475 	 * Throws: GException on failure.
476 	 */
477 	public ptrdiff_t write(ubyte[] buffer, Cancellable cancellable)
478 	{
479 		GError* err = null;
480 		
481 		auto p = g_output_stream_write(gOutputStream, buffer.ptr, cast(size_t)buffer.length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
482 		
483 		if (err !is null)
484 		{
485 			throw new GException( new ErrorG(err) );
486 		}
487 		
488 		return p;
489 	}
490 
491 	/**
492 	 * Tries to write @count bytes from @buffer into the stream. Will block
493 	 * during the operation.
494 	 *
495 	 * This function is similar to g_output_stream_write(), except it tries to
496 	 * write as many bytes as requested, only stopping on an error.
497 	 *
498 	 * On a successful write of @count bytes, %TRUE is returned, and @bytes_written
499 	 * is set to @count.
500 	 *
501 	 * If there is an error during the operation %FALSE is returned and @error
502 	 * is set to indicate the error status, @bytes_written is updated to contain
503 	 * the number of bytes written into the stream before the error occurred.
504 	 *
505 	 * Params:
506 	 *     buffer = the buffer containing the data to write.
507 	 *     count = the number of bytes to write
508 	 *     bytesWritten = location to store the number of bytes that was
509 	 *         written to the stream
510 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
511 	 *
512 	 * Return: %TRUE on success, %FALSE if there was an error
513 	 *
514 	 * Throws: GException on failure.
515 	 */
516 	public bool writeAll(ubyte[] buffer, out size_t bytesWritten, Cancellable cancellable)
517 	{
518 		GError* err = null;
519 		
520 		auto p = g_output_stream_write_all(gOutputStream, buffer.ptr, cast(size_t)buffer.length, &bytesWritten, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
521 		
522 		if (err !is null)
523 		{
524 			throw new GException( new ErrorG(err) );
525 		}
526 		
527 		return p;
528 	}
529 
530 	/**
531 	 * Request an asynchronous write of @count bytes from @buffer into
532 	 * the stream. When the operation is finished @callback will be called.
533 	 * You can then call g_output_stream_write_finish() to get the result of the
534 	 * operation.
535 	 *
536 	 * During an async request no other sync and async calls are allowed,
537 	 * and will result in %G_IO_ERROR_PENDING errors.
538 	 *
539 	 * A value of @count larger than %G_MAXSSIZE will cause a
540 	 * %G_IO_ERROR_INVALID_ARGUMENT error.
541 	 *
542 	 * On success, the number of bytes written will be passed to the
543 	 * @callback. It is not an error if this is not the same as the
544 	 * requested size, as it can happen e.g. on a partial I/O error,
545 	 * but generally we try to write as many bytes as requested.
546 	 *
547 	 * You are guaranteed that this method will never fail with
548 	 * %G_IO_ERROR_WOULD_BLOCK - if @stream can't accept more data, the
549 	 * method will just wait until this changes.
550 	 *
551 	 * Any outstanding I/O request with higher priority (lower numerical
552 	 * value) will be executed before an outstanding request with lower
553 	 * priority. Default priority is %G_PRIORITY_DEFAULT.
554 	 *
555 	 * The asyncronous methods have a default fallback that uses threads
556 	 * to implement asynchronicity, so they are optional for inheriting
557 	 * classes. However, if you override one you must override all.
558 	 *
559 	 * For the synchronous, blocking version of this function, see
560 	 * g_output_stream_write().
561 	 *
562 	 * Note that no copy of @buffer will be made, so it must stay valid
563 	 * until @callback is called. See g_output_stream_write_bytes_async()
564 	 * for a #GBytes version that will automatically hold a reference to
565 	 * the contents (without copying) for the duration of the call.
566 	 *
567 	 * Params:
568 	 *     buffer = the buffer containing the data to write.
569 	 *     count = the number of bytes to write
570 	 *     ioPriority = the io priority of the request.
571 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
572 	 *     callback = callback to call when the request is satisfied
573 	 *     userData = the data to pass to callback function
574 	 */
575 	public void writeAsync(ubyte[] buffer, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
576 	{
577 		g_output_stream_write_async(gOutputStream, buffer.ptr, cast(size_t)buffer.length, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
578 	}
579 
580 	/**
581 	 * A wrapper function for g_output_stream_write() which takes a
582 	 * #GBytes as input.  This can be more convenient for use by language
583 	 * bindings or in other cases where the refcounted nature of #GBytes
584 	 * is helpful over a bare pointer interface.
585 	 *
586 	 * However, note that this function may still perform partial writes,
587 	 * just like g_output_stream_write().  If that occurs, to continue
588 	 * writing, you will need to create a new #GBytes containing just the
589 	 * remaining bytes, using g_bytes_new_from_bytes(). Passing the same
590 	 * #GBytes instance multiple times potentially can result in duplicated
591 	 * data in the output stream.
592 	 *
593 	 * Params:
594 	 *     bytes = the #GBytes to write
595 	 *     cancellable = optional cancellable object
596 	 *
597 	 * Return: Number of bytes written, or -1 on error
598 	 *
599 	 * Throws: GException on failure.
600 	 */
601 	public ptrdiff_t writeBytes(Bytes bytes, Cancellable cancellable)
602 	{
603 		GError* err = null;
604 		
605 		auto p = g_output_stream_write_bytes(gOutputStream, (bytes is null) ? null : bytes.getBytesStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
606 		
607 		if (err !is null)
608 		{
609 			throw new GException( new ErrorG(err) );
610 		}
611 		
612 		return p;
613 	}
614 
615 	/**
616 	 * This function is similar to g_output_stream_write_async(), but
617 	 * takes a #GBytes as input.  Due to the refcounted nature of #GBytes,
618 	 * this allows the stream to avoid taking a copy of the data.
619 	 *
620 	 * However, note that this function may still perform partial writes,
621 	 * just like g_output_stream_write_async(). If that occurs, to continue
622 	 * writing, you will need to create a new #GBytes containing just the
623 	 * remaining bytes, using g_bytes_new_from_bytes(). Passing the same
624 	 * #GBytes instance multiple times potentially can result in duplicated
625 	 * data in the output stream.
626 	 *
627 	 * For the synchronous, blocking version of this function, see
628 	 * g_output_stream_write_bytes().
629 	 *
630 	 * Params:
631 	 *     bytes = The bytes to write
632 	 *     ioPriority = the io priority of the request.
633 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
634 	 *     callback = callback to call when the request is satisfied
635 	 *     userData = the data to pass to callback function
636 	 */
637 	public void writeBytesAsync(Bytes bytes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
638 	{
639 		g_output_stream_write_bytes_async(gOutputStream, (bytes is null) ? null : bytes.getBytesStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
640 	}
641 
642 	/**
643 	 * Finishes a stream write-from-#GBytes operation.
644 	 *
645 	 * Params:
646 	 *     result = a #GAsyncResult.
647 	 *
648 	 * Return: a #gssize containing the number of bytes written to the stream.
649 	 *
650 	 * Throws: GException on failure.
651 	 */
652 	public ptrdiff_t writeBytesFinish(AsyncResultIF result)
653 	{
654 		GError* err = null;
655 		
656 		auto p = g_output_stream_write_bytes_finish(gOutputStream, (result is null) ? null : result.getAsyncResultStruct(), &err);
657 		
658 		if (err !is null)
659 		{
660 			throw new GException( new ErrorG(err) );
661 		}
662 		
663 		return p;
664 	}
665 
666 	/**
667 	 * Finishes a stream write operation.
668 	 *
669 	 * Params:
670 	 *     result = a #GAsyncResult.
671 	 *
672 	 * Return: a #gssize containing the number of bytes written to the stream.
673 	 *
674 	 * Throws: GException on failure.
675 	 */
676 	public ptrdiff_t writeFinish(AsyncResultIF result)
677 	{
678 		GError* err = null;
679 		
680 		auto p = g_output_stream_write_finish(gOutputStream, (result is null) ? null : result.getAsyncResultStruct(), &err);
681 		
682 		if (err !is null)
683 		{
684 			throw new GException( new ErrorG(err) );
685 		}
686 		
687 		return p;
688 	}
689 }