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