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. 503 * 504 * As a special exception to the normal conventions for functions that 505 * use #GError, if this function returns %FALSE (and sets @error) then 506 * @bytes_written will be set to the number of bytes that were 507 * successfully written before the error was encountered. This 508 * functionality is only available from C. If you need it from another 509 * language then you must write your own loop around 510 * g_output_stream_write(). 511 * 512 * Params: 513 * buffer = the buffer containing the data to write. 514 * count = the number of bytes to write 515 * bytesWritten = location to store the number of bytes that was 516 * written to the stream 517 * cancellable = optional #GCancellable object, %NULL to ignore. 518 * 519 * Return: %TRUE on success, %FALSE if there was an error 520 * 521 * Throws: GException on failure. 522 */ 523 public bool writeAll(ubyte[] buffer, out size_t bytesWritten, Cancellable cancellable) 524 { 525 GError* err = null; 526 527 auto p = g_output_stream_write_all(gOutputStream, buffer.ptr, cast(size_t)buffer.length, &bytesWritten, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 528 529 if (err !is null) 530 { 531 throw new GException( new ErrorG(err) ); 532 } 533 534 return p; 535 } 536 537 /** 538 * Request an asynchronous write of @count bytes from @buffer into 539 * the stream. When the operation is finished @callback will be called. 540 * You can then call g_output_stream_write_all_finish() to get the result of the 541 * operation. 542 * 543 * This is the asynchronous version of g_output_stream_write_all(). 544 * 545 * Call g_output_stream_write_all_finish() to collect the result. 546 * 547 * Any outstanding I/O request with higher priority (lower numerical 548 * value) will be executed before an outstanding request with lower 549 * priority. Default priority is %G_PRIORITY_DEFAULT. 550 * 551 * Note that no copy of @buffer will be made, so it must stay valid 552 * until @callback is called. 553 * 554 * Params: 555 * buffer = the buffer containing the data to write 556 * count = the number of bytes to write 557 * ioPriority = the io priority of the request 558 * cancellable = optional #GCancellable object, %NULL to ignore 559 * callback = callback to call when the request is satisfied 560 * userData = the data to pass to callback function 561 * 562 * Since: 2.44 563 */ 564 public void writeAllAsync(ubyte[] buffer, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 565 { 566 g_output_stream_write_all_async(gOutputStream, buffer.ptr, cast(size_t)buffer.length, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 567 } 568 569 /** 570 * Finishes an asynchronous stream write operation started with 571 * g_output_stream_write_all_async(). 572 * 573 * As a special exception to the normal conventions for functions that 574 * use #GError, if this function returns %FALSE (and sets @error) then 575 * @bytes_written will be set to the number of bytes that were 576 * successfully written before the error was encountered. This 577 * functionality is only available from C. If you need it from another 578 * language then you must write your own loop around 579 * g_output_stream_write_async(). 580 * 581 * Params: 582 * result = a #GAsyncResult 583 * bytesWritten = location to store the number of bytes that was written to the stream 584 * 585 * Return: %TRUE on success, %FALSE if there was an error 586 * 587 * Since: 2.44 588 * 589 * Throws: GException on failure. 590 */ 591 public bool writeAllFinish(AsyncResultIF result, out size_t bytesWritten) 592 { 593 GError* err = null; 594 595 auto p = g_output_stream_write_all_finish(gOutputStream, (result is null) ? null : result.getAsyncResultStruct(), &bytesWritten, &err) != 0; 596 597 if (err !is null) 598 { 599 throw new GException( new ErrorG(err) ); 600 } 601 602 return p; 603 } 604 605 /** 606 * Request an asynchronous write of @count bytes from @buffer into 607 * the stream. When the operation is finished @callback will be called. 608 * You can then call g_output_stream_write_finish() to get the result of the 609 * operation. 610 * 611 * During an async request no other sync and async calls are allowed, 612 * and will result in %G_IO_ERROR_PENDING errors. 613 * 614 * A value of @count larger than %G_MAXSSIZE will cause a 615 * %G_IO_ERROR_INVALID_ARGUMENT error. 616 * 617 * On success, the number of bytes written will be passed to the 618 * @callback. It is not an error if this is not the same as the 619 * requested size, as it can happen e.g. on a partial I/O error, 620 * but generally we try to write as many bytes as requested. 621 * 622 * You are guaranteed that this method will never fail with 623 * %G_IO_ERROR_WOULD_BLOCK - if @stream can't accept more data, the 624 * method will just wait until this changes. 625 * 626 * Any outstanding I/O request with higher priority (lower numerical 627 * value) will be executed before an outstanding request with lower 628 * priority. Default priority is %G_PRIORITY_DEFAULT. 629 * 630 * The asyncronous methods have a default fallback that uses threads 631 * to implement asynchronicity, so they are optional for inheriting 632 * classes. However, if you override one you must override all. 633 * 634 * For the synchronous, blocking version of this function, see 635 * g_output_stream_write(). 636 * 637 * Note that no copy of @buffer will be made, so it must stay valid 638 * until @callback is called. See g_output_stream_write_bytes_async() 639 * for a #GBytes version that will automatically hold a reference to 640 * the contents (without copying) for the duration of the call. 641 * 642 * Params: 643 * buffer = the buffer containing the data to write. 644 * count = the number of bytes to write 645 * ioPriority = the io priority of the request. 646 * cancellable = optional #GCancellable object, %NULL to ignore. 647 * callback = callback to call when the request is satisfied 648 * userData = the data to pass to callback function 649 */ 650 public void writeAsync(ubyte[] buffer, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 651 { 652 g_output_stream_write_async(gOutputStream, buffer.ptr, cast(size_t)buffer.length, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 653 } 654 655 /** 656 * A wrapper function for g_output_stream_write() which takes a 657 * #GBytes as input. This can be more convenient for use by language 658 * bindings or in other cases where the refcounted nature of #GBytes 659 * is helpful over a bare pointer interface. 660 * 661 * However, note that this function may still perform partial writes, 662 * just like g_output_stream_write(). If that occurs, to continue 663 * writing, you will need to create a new #GBytes containing just the 664 * remaining bytes, using g_bytes_new_from_bytes(). Passing the same 665 * #GBytes instance multiple times potentially can result in duplicated 666 * data in the output stream. 667 * 668 * Params: 669 * bytes = the #GBytes to write 670 * cancellable = optional cancellable object 671 * 672 * Return: Number of bytes written, or -1 on error 673 * 674 * Throws: GException on failure. 675 */ 676 public ptrdiff_t writeBytes(Bytes bytes, Cancellable cancellable) 677 { 678 GError* err = null; 679 680 auto p = g_output_stream_write_bytes(gOutputStream, (bytes is null) ? null : bytes.getBytesStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 681 682 if (err !is null) 683 { 684 throw new GException( new ErrorG(err) ); 685 } 686 687 return p; 688 } 689 690 /** 691 * This function is similar to g_output_stream_write_async(), but 692 * takes a #GBytes as input. Due to the refcounted nature of #GBytes, 693 * this allows the stream to avoid taking a copy of the data. 694 * 695 * However, note that this function may still perform partial writes, 696 * just like g_output_stream_write_async(). If that occurs, to continue 697 * writing, you will need to create a new #GBytes containing just the 698 * remaining bytes, using g_bytes_new_from_bytes(). Passing the same 699 * #GBytes instance multiple times potentially can result in duplicated 700 * data in the output stream. 701 * 702 * For the synchronous, blocking version of this function, see 703 * g_output_stream_write_bytes(). 704 * 705 * Params: 706 * bytes = The bytes to write 707 * ioPriority = the io priority of the request. 708 * cancellable = optional #GCancellable object, %NULL to ignore. 709 * callback = callback to call when the request is satisfied 710 * userData = the data to pass to callback function 711 */ 712 public void writeBytesAsync(Bytes bytes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 713 { 714 g_output_stream_write_bytes_async(gOutputStream, (bytes is null) ? null : bytes.getBytesStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 715 } 716 717 /** 718 * Finishes a stream write-from-#GBytes operation. 719 * 720 * Params: 721 * result = a #GAsyncResult. 722 * 723 * Return: a #gssize containing the number of bytes written to the stream. 724 * 725 * Throws: GException on failure. 726 */ 727 public ptrdiff_t writeBytesFinish(AsyncResultIF result) 728 { 729 GError* err = null; 730 731 auto p = g_output_stream_write_bytes_finish(gOutputStream, (result is null) ? null : result.getAsyncResultStruct(), &err); 732 733 if (err !is null) 734 { 735 throw new GException( new ErrorG(err) ); 736 } 737 738 return p; 739 } 740 741 /** 742 * Finishes a stream write operation. 743 * 744 * Params: 745 * result = a #GAsyncResult. 746 * 747 * Return: a #gssize containing the number of bytes written to the stream. 748 * 749 * Throws: GException on failure. 750 */ 751 public ptrdiff_t writeFinish(AsyncResultIF result) 752 { 753 GError* err = null; 754 755 auto p = g_output_stream_write_finish(gOutputStream, (result is null) ? null : result.getAsyncResultStruct(), &err); 756 757 if (err !is null) 758 { 759 throw new GException( new ErrorG(err) ); 760 } 761 762 return p; 763 } 764 }