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