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