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