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.FileT; 26 27 public import gio.AppInfo; 28 public import gio.AppInfoIF; 29 public import gio.AsyncResultIF; 30 public import gio.Cancellable; 31 public import gio.File; 32 public import gio.FileAttributeInfoList; 33 public import gio.FileEnumerator; 34 public import gio.FileIF; 35 public import gio.FileIOStream; 36 public import gio.FileInfo; 37 public import gio.FileInputStream; 38 public import gio.FileMonitor; 39 public import gio.FileOutputStream; 40 public import gio.Mount; 41 public import gio.MountIF; 42 public import gio.MountOperation; 43 public import glib.Bytes; 44 public import glib.ConstructionException; 45 public import glib.ErrorG; 46 public import glib.GException; 47 public import glib.Str; 48 public import gobject.ObjectG; 49 public import gtkc.gio; 50 public import gtkc.giotypes; 51 52 53 /** 54 * #GFile is a high level abstraction for manipulating files on a 55 * virtual file system. #GFiles are lightweight, immutable objects 56 * that do no I/O upon creation. It is necessary to understand that 57 * #GFile objects do not represent files, merely an identifier for a 58 * file. All file content I/O is implemented as streaming operations 59 * (see #GInputStream and #GOutputStream). 60 * 61 * To construct a #GFile, you can use: 62 * - g_file_new_for_path() if you have a path. 63 * - g_file_new_for_uri() if you have a URI. 64 * - g_file_new_for_commandline_arg() for a command line argument. 65 * - g_file_new_tmp() to create a temporary file from a template. 66 * - g_file_parse_name() from a UTF-8 string gotten from g_file_get_parse_name(). 67 * 68 * One way to think of a #GFile is as an abstraction of a pathname. For 69 * normal files the system pathname is what is stored internally, but as 70 * #GFiles are extensible it could also be something else that corresponds 71 * to a pathname in a userspace implementation of a filesystem. 72 * 73 * #GFiles make up hierarchies of directories and files that correspond to 74 * the files on a filesystem. You can move through the file system with 75 * #GFile using g_file_get_parent() to get an identifier for the parent 76 * directory, g_file_get_child() to get a child within a directory, 77 * g_file_resolve_relative_path() to resolve a relative path between two 78 * #GFiles. There can be multiple hierarchies, so you may not end up at 79 * the same root if you repeatedly call g_file_get_parent() on two different 80 * files. 81 * 82 * All #GFiles have a basename (get with g_file_get_basename()). These names 83 * are byte strings that are used to identify the file on the filesystem 84 * (relative to its parent directory) and there is no guarantees that they 85 * have any particular charset encoding or even make any sense at all. If 86 * you want to use filenames in a user interface you should use the display 87 * name that you can get by requesting the 88 * %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info(). 89 * This is guaranteed to be in UTF-8 and can be used in a user interface. 90 * But always store the real basename or the #GFile to use to actually 91 * access the file, because there is no way to go from a display name to 92 * the actual name. 93 * 94 * Using #GFile as an identifier has the same weaknesses as using a path 95 * in that there may be multiple aliases for the same file. For instance, 96 * hard or soft links may cause two different #GFiles to refer to the same 97 * file. Other possible causes for aliases are: case insensitive filesystems, 98 * short and long names on FAT/NTFS, or bind mounts in Linux. If you want to 99 * check if two #GFiles point to the same file you can query for the 100 * %G_FILE_ATTRIBUTE_ID_FILE attribute. Note that #GFile does some trivial 101 * canonicalization of pathnames passed in, so that trivial differences in 102 * the path string used at creation (duplicated slashes, slash at end of 103 * path, "." or ".." path segments, etc) does not create different #GFiles. 104 * 105 * Many #GFile operations have both synchronous and asynchronous versions 106 * to suit your application. Asynchronous versions of synchronous functions 107 * simply have _async() appended to their function names. The asynchronous 108 * I/O functions call a #GAsyncReadyCallback which is then used to finalize 109 * the operation, producing a GAsyncResult which is then passed to the 110 * function's matching _finish() operation. 111 * 112 * It is highly recommended to use asynchronous calls when running within a 113 * shared main loop, such as in the main thread of an application. This avoids 114 * I/O operations blocking other sources on the main loop from being dispatched. 115 * Synchronous I/O operations should be performed from worker threads. See the 116 * [introduction to asynchronous programming section][async-programming] for 117 * more. 118 * 119 * Some #GFile operations almost always take a noticeable amount of time, and 120 * so do not have synchronous analogs. Notable cases include: 121 * - g_file_mount_mountable() to mount a mountable file. 122 * - g_file_unmount_mountable_with_operation() to unmount a mountable file. 123 * - g_file_eject_mountable_with_operation() to eject a mountable file. 124 * 125 * ## Entity Tags # {#gfile-etag} 126 * 127 * One notable feature of #GFiles are entity tags, or "etags" for 128 * short. Entity tags are somewhat like a more abstract version of the 129 * traditional mtime, and can be used to quickly determine if the file 130 * has been modified from the version on the file system. See the 131 * HTTP 1.1 132 * [specification](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) 133 * for HTTP Etag headers, which are a very similar concept. 134 */ 135 public template FileT(TStruct) 136 { 137 /** Get the main Gtk struct */ 138 public GFile* getFileStruct(bool transferOwnership = false) 139 { 140 if (transferOwnership) 141 ownedRef = false; 142 return cast(GFile*)getStruct(); 143 } 144 145 146 /** 147 * Constructs a #GFile with the given @parse_name (i.e. something 148 * given by g_file_get_parse_name()). This operation never fails, 149 * but the returned object might not support any I/O operation if 150 * the @parse_name cannot be parsed. 151 * 152 * Params: 153 * parseName = a file name or path to be parsed 154 * 155 * Returns: a new #GFile. 156 */ 157 public static FileIF parseName(string parseName) 158 { 159 auto p = g_file_parse_name(Str.toStringz(parseName)); 160 161 if(p is null) 162 { 163 return null; 164 } 165 166 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 167 } 168 169 /** 170 * Gets an output stream for appending data to the file. 171 * If the file doesn't already exist it is created. 172 * 173 * By default files created are generally readable by everyone, 174 * but if you pass #G_FILE_CREATE_PRIVATE in @flags the file 175 * will be made readable only to the current user, to the level that 176 * is supported on the target filesystem. 177 * 178 * If @cancellable is not %NULL, then the operation can be cancelled 179 * by triggering the cancellable object from another thread. If the 180 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 181 * returned. 182 * 183 * Some file systems don't allow all file names, and may return an 184 * %G_IO_ERROR_INVALID_FILENAME error. If the file is a directory the 185 * %G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are 186 * possible too, and depend on what kind of filesystem the file is on. 187 * 188 * Params: 189 * flags = a set of #GFileCreateFlags 190 * cancellable = optional #GCancellable object, 191 * %NULL to ignore 192 * 193 * Returns: a #GFileOutputStream, or %NULL on error. 194 * Free the returned object with g_object_unref(). 195 * 196 * Throws: GException on failure. 197 */ 198 public FileOutputStream appendTo(GFileCreateFlags flags, Cancellable cancellable) 199 { 200 GError* err = null; 201 202 auto p = g_file_append_to(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 203 204 if (err !is null) 205 { 206 throw new GException( new ErrorG(err) ); 207 } 208 209 if(p is null) 210 { 211 return null; 212 } 213 214 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) p, true); 215 } 216 217 /** 218 * Asynchronously opens @file for appending. 219 * 220 * For more details, see g_file_append_to() which is 221 * the synchronous version of this call. 222 * 223 * When the operation is finished, @callback will be called. 224 * You can then call g_file_append_to_finish() to get the result 225 * of the operation. 226 * 227 * Params: 228 * flags = a set of #GFileCreateFlags 229 * ioPriority = the [I/O priority][io-priority] of the request 230 * cancellable = optional #GCancellable object, 231 * %NULL to ignore 232 * callback = a #GAsyncReadyCallback to call 233 * when the request is satisfied 234 * userData = the data to pass to callback function 235 */ 236 public void appendToAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 237 { 238 g_file_append_to_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 239 } 240 241 /** 242 * Finishes an asynchronous file append operation started with 243 * g_file_append_to_async(). 244 * 245 * Params: 246 * res = #GAsyncResult 247 * 248 * Returns: a valid #GFileOutputStream 249 * or %NULL on error. 250 * Free the returned object with g_object_unref(). 251 * 252 * Throws: GException on failure. 253 */ 254 public FileOutputStream appendToFinish(AsyncResultIF res) 255 { 256 GError* err = null; 257 258 auto p = g_file_append_to_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 259 260 if (err !is null) 261 { 262 throw new GException( new ErrorG(err) ); 263 } 264 265 if(p is null) 266 { 267 return null; 268 } 269 270 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) p, true); 271 } 272 273 /** 274 * Copies the file @source to the location specified by @destination. 275 * Can not handle recursive copies of directories. 276 * 277 * If the flag #G_FILE_COPY_OVERWRITE is specified an already 278 * existing @destination file is overwritten. 279 * 280 * If the flag #G_FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks 281 * will be copied as symlinks, otherwise the target of the 282 * @source symlink will be copied. 283 * 284 * If @cancellable is not %NULL, then the operation can be cancelled by 285 * triggering the cancellable object from another thread. If the operation 286 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 287 * 288 * If @progress_callback is not %NULL, then the operation can be monitored 289 * by setting this to a #GFileProgressCallback function. 290 * @progress_callback_data will be passed to this function. It is guaranteed 291 * that this callback will be called after all data has been transferred with 292 * the total number of bytes copied during the operation. 293 * 294 * If the @source file does not exist, then the %G_IO_ERROR_NOT_FOUND error 295 * is returned, independent on the status of the @destination. 296 * 297 * If #G_FILE_COPY_OVERWRITE is not specified and the target exists, then 298 * the error %G_IO_ERROR_EXISTS is returned. 299 * 300 * If trying to overwrite a file over a directory, the %G_IO_ERROR_IS_DIRECTORY 301 * error is returned. If trying to overwrite a directory with a directory the 302 * %G_IO_ERROR_WOULD_MERGE error is returned. 303 * 304 * If the source is a directory and the target does not exist, or 305 * #G_FILE_COPY_OVERWRITE is specified and the target is a file, then the 306 * %G_IO_ERROR_WOULD_RECURSE error is returned. 307 * 308 * If you are interested in copying the #GFile object itself (not the on-disk 309 * file), see g_file_dup(). 310 * 311 * Params: 312 * destination = destination #GFile 313 * flags = set of #GFileCopyFlags 314 * cancellable = optional #GCancellable object, 315 * %NULL to ignore 316 * progressCallback = function to callback with 317 * progress information, or %NULL if progress information is not needed 318 * progressCallbackData = user data to pass to @progress_callback 319 * 320 * Returns: %TRUE on success, %FALSE otherwise. 321 * 322 * Throws: GException on failure. 323 */ 324 public bool copy(FileIF destination, GFileCopyFlags flags, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData) 325 { 326 GError* err = null; 327 328 auto p = g_file_copy(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressCallbackData, &err) != 0; 329 330 if (err !is null) 331 { 332 throw new GException( new ErrorG(err) ); 333 } 334 335 return p; 336 } 337 338 /** 339 * Copies the file @source to the location specified by @destination 340 * asynchronously. For details of the behaviour, see g_file_copy(). 341 * 342 * If @progress_callback is not %NULL, then that function that will be called 343 * just like in g_file_copy(). The callback will run in the default main context 344 * of the thread calling g_file_copy_async() — the same context as @callback is 345 * run in. 346 * 347 * When the operation is finished, @callback will be called. You can then call 348 * g_file_copy_finish() to get the result of the operation. 349 * 350 * Params: 351 * destination = destination #GFile 352 * flags = set of #GFileCopyFlags 353 * ioPriority = the [I/O priority][io-priority] of the request 354 * cancellable = optional #GCancellable object, 355 * %NULL to ignore 356 * progressCallback = function to callback with progress 357 * information, or %NULL if progress information is not needed 358 * progressCallbackData = user data to pass to @progress_callback 359 * callback = a #GAsyncReadyCallback to call when the request is satisfied 360 * userData = the data to pass to callback function 361 */ 362 public void copyAsync(FileIF destination, GFileCopyFlags flags, int ioPriority, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData, GAsyncReadyCallback callback, void* userData) 363 { 364 g_file_copy_async(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressCallbackData, callback, userData); 365 } 366 367 /** 368 * Copies the file attributes from @source to @destination. 369 * 370 * Normally only a subset of the file attributes are copied, 371 * those that are copies in a normal file copy operation 372 * (which for instance does not include e.g. owner). However 373 * if #G_FILE_COPY_ALL_METADATA is specified in @flags, then 374 * all the metadata that is possible to copy is copied. This 375 * is useful when implementing move by copy + delete source. 376 * 377 * Params: 378 * destination = a #GFile to copy attributes to 379 * flags = a set of #GFileCopyFlags 380 * cancellable = optional #GCancellable object, 381 * %NULL to ignore 382 * 383 * Returns: %TRUE if the attributes were copied successfully, 384 * %FALSE otherwise. 385 * 386 * Throws: GException on failure. 387 */ 388 public bool copyAttributes(FileIF destination, GFileCopyFlags flags, Cancellable cancellable) 389 { 390 GError* err = null; 391 392 auto p = g_file_copy_attributes(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 393 394 if (err !is null) 395 { 396 throw new GException( new ErrorG(err) ); 397 } 398 399 return p; 400 } 401 402 /** 403 * Finishes copying the file started with g_file_copy_async(). 404 * 405 * Params: 406 * res = a #GAsyncResult 407 * 408 * Returns: a %TRUE on success, %FALSE on error. 409 * 410 * Throws: GException on failure. 411 */ 412 public bool copyFinish(AsyncResultIF res) 413 { 414 GError* err = null; 415 416 auto p = g_file_copy_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err) != 0; 417 418 if (err !is null) 419 { 420 throw new GException( new ErrorG(err) ); 421 } 422 423 return p; 424 } 425 426 /** 427 * Creates a new file and returns an output stream for writing to it. 428 * The file must not already exist. 429 * 430 * By default files created are generally readable by everyone, 431 * but if you pass #G_FILE_CREATE_PRIVATE in @flags the file 432 * will be made readable only to the current user, to the level 433 * that is supported on the target filesystem. 434 * 435 * If @cancellable is not %NULL, then the operation can be cancelled 436 * by triggering the cancellable object from another thread. If the 437 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 438 * returned. 439 * 440 * If a file or directory with this name already exists the 441 * %G_IO_ERROR_EXISTS error will be returned. Some file systems don't 442 * allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME 443 * error, and if the name is to long %G_IO_ERROR_FILENAME_TOO_LONG will 444 * be returned. Other errors are possible too, and depend on what kind 445 * of filesystem the file is on. 446 * 447 * Params: 448 * flags = a set of #GFileCreateFlags 449 * cancellable = optional #GCancellable object, 450 * %NULL to ignore 451 * 452 * Returns: a #GFileOutputStream for the newly created 453 * file, or %NULL on error. 454 * Free the returned object with g_object_unref(). 455 * 456 * Throws: GException on failure. 457 */ 458 public FileOutputStream create(GFileCreateFlags flags, Cancellable cancellable) 459 { 460 GError* err = null; 461 462 auto p = g_file_create(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 463 464 if (err !is null) 465 { 466 throw new GException( new ErrorG(err) ); 467 } 468 469 if(p is null) 470 { 471 return null; 472 } 473 474 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) p, true); 475 } 476 477 /** 478 * Asynchronously creates a new file and returns an output stream 479 * for writing to it. The file must not already exist. 480 * 481 * For more details, see g_file_create() which is 482 * the synchronous version of this call. 483 * 484 * When the operation is finished, @callback will be called. 485 * You can then call g_file_create_finish() to get the result 486 * of the operation. 487 * 488 * Params: 489 * flags = a set of #GFileCreateFlags 490 * ioPriority = the [I/O priority][io-priority] of the request 491 * cancellable = optional #GCancellable object, 492 * %NULL to ignore 493 * callback = a #GAsyncReadyCallback to call 494 * when the request is satisfied 495 * userData = the data to pass to callback function 496 */ 497 public void createAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 498 { 499 g_file_create_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 500 } 501 502 /** 503 * Finishes an asynchronous file create operation started with 504 * g_file_create_async(). 505 * 506 * Params: 507 * res = a #GAsyncResult 508 * 509 * Returns: a #GFileOutputStream or %NULL on error. 510 * Free the returned object with g_object_unref(). 511 * 512 * Throws: GException on failure. 513 */ 514 public FileOutputStream createFinish(AsyncResultIF res) 515 { 516 GError* err = null; 517 518 auto p = g_file_create_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 519 520 if (err !is null) 521 { 522 throw new GException( new ErrorG(err) ); 523 } 524 525 if(p is null) 526 { 527 return null; 528 } 529 530 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) p, true); 531 } 532 533 /** 534 * Creates a new file and returns a stream for reading and 535 * writing to it. The file must not already exist. 536 * 537 * By default files created are generally readable by everyone, 538 * but if you pass #G_FILE_CREATE_PRIVATE in @flags the file 539 * will be made readable only to the current user, to the level 540 * that is supported on the target filesystem. 541 * 542 * If @cancellable is not %NULL, then the operation can be cancelled 543 * by triggering the cancellable object from another thread. If the 544 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 545 * returned. 546 * 547 * If a file or directory with this name already exists, the 548 * %G_IO_ERROR_EXISTS error will be returned. Some file systems don't 549 * allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME 550 * error, and if the name is too long, %G_IO_ERROR_FILENAME_TOO_LONG 551 * will be returned. Other errors are possible too, and depend on what 552 * kind of filesystem the file is on. 553 * 554 * Note that in many non-local file cases read and write streams are 555 * not supported, so make sure you really need to do read and write 556 * streaming, rather than just opening for reading or writing. 557 * 558 * Params: 559 * flags = a set of #GFileCreateFlags 560 * cancellable = optional #GCancellable object, 561 * %NULL to ignore 562 * 563 * Returns: a #GFileIOStream for the newly created 564 * file, or %NULL on error. 565 * Free the returned object with g_object_unref(). 566 * 567 * Since: 2.22 568 * 569 * Throws: GException on failure. 570 */ 571 public FileIOStream createReadwrite(GFileCreateFlags flags, Cancellable cancellable) 572 { 573 GError* err = null; 574 575 auto p = g_file_create_readwrite(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 576 577 if (err !is null) 578 { 579 throw new GException( new ErrorG(err) ); 580 } 581 582 if(p is null) 583 { 584 return null; 585 } 586 587 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 588 } 589 590 /** 591 * Asynchronously creates a new file and returns a stream 592 * for reading and writing to it. The file must not already exist. 593 * 594 * For more details, see g_file_create_readwrite() which is 595 * the synchronous version of this call. 596 * 597 * When the operation is finished, @callback will be called. 598 * You can then call g_file_create_readwrite_finish() to get 599 * the result of the operation. 600 * 601 * Params: 602 * flags = a set of #GFileCreateFlags 603 * ioPriority = the [I/O priority][io-priority] of the request 604 * cancellable = optional #GCancellable object, 605 * %NULL to ignore 606 * callback = a #GAsyncReadyCallback to call 607 * when the request is satisfied 608 * userData = the data to pass to callback function 609 * 610 * Since: 2.22 611 */ 612 public void createReadwriteAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 613 { 614 g_file_create_readwrite_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 615 } 616 617 /** 618 * Finishes an asynchronous file create operation started with 619 * g_file_create_readwrite_async(). 620 * 621 * Params: 622 * res = a #GAsyncResult 623 * 624 * Returns: a #GFileIOStream or %NULL on error. 625 * Free the returned object with g_object_unref(). 626 * 627 * Since: 2.22 628 * 629 * Throws: GException on failure. 630 */ 631 public FileIOStream createReadwriteFinish(AsyncResultIF res) 632 { 633 GError* err = null; 634 635 auto p = g_file_create_readwrite_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 636 637 if (err !is null) 638 { 639 throw new GException( new ErrorG(err) ); 640 } 641 642 if(p is null) 643 { 644 return null; 645 } 646 647 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 648 } 649 650 /** 651 * Deletes a file. If the @file is a directory, it will only be 652 * deleted if it is empty. This has the same semantics as g_unlink(). 653 * 654 * If @cancellable is not %NULL, then the operation can be cancelled by 655 * triggering the cancellable object from another thread. If the operation 656 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 657 * 658 * Params: 659 * cancellable = optional #GCancellable object, 660 * %NULL to ignore 661 * 662 * Returns: %TRUE if the file was deleted. %FALSE otherwise. 663 * 664 * Throws: GException on failure. 665 */ 666 public bool delet(Cancellable cancellable) 667 { 668 GError* err = null; 669 670 auto p = g_file_delete(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 671 672 if (err !is null) 673 { 674 throw new GException( new ErrorG(err) ); 675 } 676 677 return p; 678 } 679 680 /** 681 * Asynchronously delete a file. If the @file is a directory, it will 682 * only be deleted if it is empty. This has the same semantics as 683 * g_unlink(). 684 * 685 * Params: 686 * ioPriority = the [I/O priority][io-priority] of the request 687 * cancellable = optional #GCancellable object, 688 * %NULL to ignore 689 * callback = a #GAsyncReadyCallback to call 690 * when the request is satisfied 691 * userData = the data to pass to callback function 692 * 693 * Since: 2.34 694 */ 695 public void deleteAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 696 { 697 g_file_delete_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 698 } 699 700 /** 701 * Finishes deleting a file started with g_file_delete_async(). 702 * 703 * Params: 704 * result = a #GAsyncResult 705 * 706 * Returns: %TRUE if the file was deleted. %FALSE otherwise. 707 * 708 * Since: 2.34 709 * 710 * Throws: GException on failure. 711 */ 712 public bool deleteFinish(AsyncResultIF result) 713 { 714 GError* err = null; 715 716 auto p = g_file_delete_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 717 718 if (err !is null) 719 { 720 throw new GException( new ErrorG(err) ); 721 } 722 723 return p; 724 } 725 726 /** 727 * Duplicates a #GFile handle. This operation does not duplicate 728 * the actual file or directory represented by the #GFile; see 729 * g_file_copy() if attempting to copy a file. 730 * 731 * This call does no blocking I/O. 732 * 733 * Returns: a new #GFile that is a duplicate 734 * of the given #GFile. 735 */ 736 public FileIF dup() 737 { 738 auto p = g_file_dup(getFileStruct()); 739 740 if(p is null) 741 { 742 return null; 743 } 744 745 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 746 } 747 748 /** 749 * Starts an asynchronous eject on a mountable. 750 * When this operation has completed, @callback will be called with 751 * @user_user data, and the operation can be finalized with 752 * g_file_eject_mountable_finish(). 753 * 754 * If @cancellable is not %NULL, then the operation can be cancelled by 755 * triggering the cancellable object from another thread. If the operation 756 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 757 * 758 * Deprecated: Use g_file_eject_mountable_with_operation() instead. 759 * 760 * Params: 761 * flags = flags affecting the operation 762 * cancellable = optional #GCancellable object, 763 * %NULL to ignore 764 * callback = a #GAsyncReadyCallback to call 765 * when the request is satisfied, or %NULL 766 * userData = the data to pass to callback function 767 */ 768 public void ejectMountable(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 769 { 770 g_file_eject_mountable(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 771 } 772 773 /** 774 * Finishes an asynchronous eject operation started by 775 * g_file_eject_mountable(). 776 * 777 * Deprecated: Use g_file_eject_mountable_with_operation_finish() 778 * instead. 779 * 780 * Params: 781 * result = a #GAsyncResult 782 * 783 * Returns: %TRUE if the @file was ejected successfully. 784 * %FALSE otherwise. 785 * 786 * Throws: GException on failure. 787 */ 788 public bool ejectMountableFinish(AsyncResultIF result) 789 { 790 GError* err = null; 791 792 auto p = g_file_eject_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 793 794 if (err !is null) 795 { 796 throw new GException( new ErrorG(err) ); 797 } 798 799 return p; 800 } 801 802 /** 803 * Starts an asynchronous eject on a mountable. 804 * When this operation has completed, @callback will be called with 805 * @user_user data, and the operation can be finalized with 806 * g_file_eject_mountable_with_operation_finish(). 807 * 808 * If @cancellable is not %NULL, then the operation can be cancelled by 809 * triggering the cancellable object from another thread. If the operation 810 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 811 * 812 * Params: 813 * flags = flags affecting the operation 814 * mountOperation = a #GMountOperation, 815 * or %NULL to avoid user interaction 816 * cancellable = optional #GCancellable object, 817 * %NULL to ignore 818 * callback = a #GAsyncReadyCallback to call 819 * when the request is satisfied, or %NULL 820 * userData = the data to pass to callback function 821 * 822 * Since: 2.22 823 */ 824 public void ejectMountableWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 825 { 826 g_file_eject_mountable_with_operation(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 827 } 828 829 /** 830 * Finishes an asynchronous eject operation started by 831 * g_file_eject_mountable_with_operation(). 832 * 833 * Params: 834 * result = a #GAsyncResult 835 * 836 * Returns: %TRUE if the @file was ejected successfully. 837 * %FALSE otherwise. 838 * 839 * Since: 2.22 840 * 841 * Throws: GException on failure. 842 */ 843 public bool ejectMountableWithOperationFinish(AsyncResultIF result) 844 { 845 GError* err = null; 846 847 auto p = g_file_eject_mountable_with_operation_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 848 849 if (err !is null) 850 { 851 throw new GException( new ErrorG(err) ); 852 } 853 854 return p; 855 } 856 857 /** 858 * Gets the requested information about the files in a directory. 859 * The result is a #GFileEnumerator object that will give out 860 * #GFileInfo objects for all the files in the directory. 861 * 862 * The @attributes value is a string that specifies the file 863 * attributes that should be gathered. It is not an error if 864 * it's not possible to read a particular requested attribute 865 * from a file - it just won't be set. @attributes should 866 * be a comma-separated list of attributes or attribute wildcards. 867 * The wildcard "*" means all attributes, and a wildcard like 868 * "standard::*" means all attributes in the standard namespace. 869 * An example attribute query be "standard::*,owner::user". 870 * The standard attributes are available as defines, like 871 * #G_FILE_ATTRIBUTE_STANDARD_NAME. 872 * 873 * If @cancellable is not %NULL, then the operation can be cancelled 874 * by triggering the cancellable object from another thread. If the 875 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 876 * returned. 877 * 878 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 879 * be returned. If the file is not a directory, the %G_IO_ERROR_NOT_DIRECTORY 880 * error will be returned. Other errors are possible too. 881 * 882 * Params: 883 * attributes = an attribute query string 884 * flags = a set of #GFileQueryInfoFlags 885 * cancellable = optional #GCancellable object, 886 * %NULL to ignore 887 * 888 * Returns: A #GFileEnumerator if successful, 889 * %NULL on error. Free the returned object with g_object_unref(). 890 * 891 * Throws: GException on failure. 892 */ 893 public FileEnumerator enumerateChildren(string attributes, GFileQueryInfoFlags flags, Cancellable cancellable) 894 { 895 GError* err = null; 896 897 auto p = g_file_enumerate_children(getFileStruct(), Str.toStringz(attributes), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 898 899 if (err !is null) 900 { 901 throw new GException( new ErrorG(err) ); 902 } 903 904 if(p is null) 905 { 906 return null; 907 } 908 909 return ObjectG.getDObject!(FileEnumerator)(cast(GFileEnumerator*) p, true); 910 } 911 912 /** 913 * Asynchronously gets the requested information about the files 914 * in a directory. The result is a #GFileEnumerator object that will 915 * give out #GFileInfo objects for all the files in the directory. 916 * 917 * For more details, see g_file_enumerate_children() which is 918 * the synchronous version of this call. 919 * 920 * When the operation is finished, @callback will be called. You can 921 * then call g_file_enumerate_children_finish() to get the result of 922 * the operation. 923 * 924 * Params: 925 * attributes = an attribute query string 926 * flags = a set of #GFileQueryInfoFlags 927 * ioPriority = the [I/O priority][io-priority] of the request 928 * cancellable = optional #GCancellable object, 929 * %NULL to ignore 930 * callback = a #GAsyncReadyCallback to call when the 931 * request is satisfied 932 * userData = the data to pass to callback function 933 */ 934 public void enumerateChildrenAsync(string attributes, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 935 { 936 g_file_enumerate_children_async(getFileStruct(), Str.toStringz(attributes), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 937 } 938 939 /** 940 * Finishes an async enumerate children operation. 941 * See g_file_enumerate_children_async(). 942 * 943 * Params: 944 * res = a #GAsyncResult 945 * 946 * Returns: a #GFileEnumerator or %NULL 947 * if an error occurred. 948 * Free the returned object with g_object_unref(). 949 * 950 * Throws: GException on failure. 951 */ 952 public FileEnumerator enumerateChildrenFinish(AsyncResultIF res) 953 { 954 GError* err = null; 955 956 auto p = g_file_enumerate_children_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 957 958 if (err !is null) 959 { 960 throw new GException( new ErrorG(err) ); 961 } 962 963 if(p is null) 964 { 965 return null; 966 } 967 968 return ObjectG.getDObject!(FileEnumerator)(cast(GFileEnumerator*) p, true); 969 } 970 971 /** 972 * Checks if the two given #GFiles refer to the same file. 973 * 974 * Note that two #GFiles that differ can still refer to the same 975 * file on the filesystem due to various forms of filename 976 * aliasing. 977 * 978 * This call does no blocking I/O. 979 * 980 * Params: 981 * file2 = the second #GFile 982 * 983 * Returns: %TRUE if @file1 and @file2 are equal. 984 */ 985 public bool equal(FileIF file2) 986 { 987 return g_file_equal(getFileStruct(), (file2 is null) ? null : file2.getFileStruct()) != 0; 988 } 989 990 /** 991 * Gets a #GMount for the #GFile. 992 * 993 * If the #GFileIface for @file does not have a mount (e.g. 994 * possibly a remote share), @error will be set to %G_IO_ERROR_NOT_FOUND 995 * and %NULL will be returned. 996 * 997 * If @cancellable is not %NULL, then the operation can be cancelled by 998 * triggering the cancellable object from another thread. If the operation 999 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1000 * 1001 * Params: 1002 * cancellable = optional #GCancellable object, 1003 * %NULL to ignore 1004 * 1005 * Returns: a #GMount where the @file is located 1006 * or %NULL on error. 1007 * Free the returned object with g_object_unref(). 1008 * 1009 * Throws: GException on failure. 1010 */ 1011 public MountIF findEnclosingMount(Cancellable cancellable) 1012 { 1013 GError* err = null; 1014 1015 auto p = g_file_find_enclosing_mount(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1016 1017 if (err !is null) 1018 { 1019 throw new GException( new ErrorG(err) ); 1020 } 1021 1022 if(p is null) 1023 { 1024 return null; 1025 } 1026 1027 return ObjectG.getDObject!(Mount, MountIF)(cast(GMount*) p, true); 1028 } 1029 1030 /** 1031 * Asynchronously gets the mount for the file. 1032 * 1033 * For more details, see g_file_find_enclosing_mount() which is 1034 * the synchronous version of this call. 1035 * 1036 * When the operation is finished, @callback will be called. 1037 * You can then call g_file_find_enclosing_mount_finish() to 1038 * get the result of the operation. 1039 * 1040 * Params: 1041 * ioPriority = the [I/O priority][io-priority] of the request 1042 * cancellable = optional #GCancellable object, 1043 * %NULL to ignore 1044 * callback = a #GAsyncReadyCallback to call 1045 * when the request is satisfied 1046 * userData = the data to pass to callback function 1047 */ 1048 public void findEnclosingMountAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1049 { 1050 g_file_find_enclosing_mount_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1051 } 1052 1053 /** 1054 * Finishes an asynchronous find mount request. 1055 * See g_file_find_enclosing_mount_async(). 1056 * 1057 * Params: 1058 * res = a #GAsyncResult 1059 * 1060 * Returns: #GMount for given @file or %NULL on error. 1061 * Free the returned object with g_object_unref(). 1062 * 1063 * Throws: GException on failure. 1064 */ 1065 public MountIF findEnclosingMountFinish(AsyncResultIF res) 1066 { 1067 GError* err = null; 1068 1069 auto p = g_file_find_enclosing_mount_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 1070 1071 if (err !is null) 1072 { 1073 throw new GException( new ErrorG(err) ); 1074 } 1075 1076 if(p is null) 1077 { 1078 return null; 1079 } 1080 1081 return ObjectG.getDObject!(Mount, MountIF)(cast(GMount*) p, true); 1082 } 1083 1084 /** 1085 * Gets the base name (the last component of the path) for a given #GFile. 1086 * 1087 * If called for the top level of a system (such as the filesystem root 1088 * or a uri like sftp://host/) it will return a single directory separator 1089 * (and on Windows, possibly a drive letter). 1090 * 1091 * The base name is a byte string (not UTF-8). It has no defined encoding 1092 * or rules other than it may not contain zero bytes. If you want to use 1093 * filenames in a user interface you should use the display name that you 1094 * can get by requesting the %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME 1095 * attribute with g_file_query_info(). 1096 * 1097 * This call does no blocking I/O. 1098 * 1099 * Returns: string containing the #GFile's 1100 * base name, or %NULL if given #GFile is invalid. The returned string 1101 * should be freed with g_free() when no longer needed. 1102 */ 1103 public string getBasename() 1104 { 1105 auto retStr = g_file_get_basename(getFileStruct()); 1106 1107 scope(exit) Str.freeString(retStr); 1108 return Str.toString(retStr); 1109 } 1110 1111 /** 1112 * Gets a child of @file with basename equal to @name. 1113 * 1114 * Note that the file with that specific name might not exist, but 1115 * you can still have a #GFile that points to it. You can use this 1116 * for instance to create that file. 1117 * 1118 * This call does no blocking I/O. 1119 * 1120 * Params: 1121 * name = string containing the child's basename 1122 * 1123 * Returns: a #GFile to a child specified by @name. 1124 * Free the returned object with g_object_unref(). 1125 */ 1126 public FileIF getChild(string name) 1127 { 1128 auto p = g_file_get_child(getFileStruct(), Str.toStringz(name)); 1129 1130 if(p is null) 1131 { 1132 return null; 1133 } 1134 1135 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 1136 } 1137 1138 /** 1139 * Gets the child of @file for a given @display_name (i.e. a UTF-8 1140 * version of the name). If this function fails, it returns %NULL 1141 * and @error will be set. This is very useful when constructing a 1142 * #GFile for a new file and the user entered the filename in the 1143 * user interface, for instance when you select a directory and 1144 * type a filename in the file selector. 1145 * 1146 * This call does no blocking I/O. 1147 * 1148 * Params: 1149 * displayName = string to a possible child 1150 * 1151 * Returns: a #GFile to the specified child, or 1152 * %NULL if the display name couldn't be converted. 1153 * Free the returned object with g_object_unref(). 1154 * 1155 * Throws: GException on failure. 1156 */ 1157 public FileIF getChildForDisplayName(string displayName) 1158 { 1159 GError* err = null; 1160 1161 auto p = g_file_get_child_for_display_name(getFileStruct(), Str.toStringz(displayName), &err); 1162 1163 if (err !is null) 1164 { 1165 throw new GException( new ErrorG(err) ); 1166 } 1167 1168 if(p is null) 1169 { 1170 return null; 1171 } 1172 1173 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 1174 } 1175 1176 /** 1177 * Gets the parent directory for the @file. 1178 * If the @file represents the root directory of the 1179 * file system, then %NULL will be returned. 1180 * 1181 * This call does no blocking I/O. 1182 * 1183 * Returns: a #GFile structure to the 1184 * parent of the given #GFile or %NULL if there is no parent. Free 1185 * the returned object with g_object_unref(). 1186 */ 1187 public FileIF getParent() 1188 { 1189 auto p = g_file_get_parent(getFileStruct()); 1190 1191 if(p is null) 1192 { 1193 return null; 1194 } 1195 1196 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 1197 } 1198 1199 /** 1200 * Gets the parse name of the @file. 1201 * A parse name is a UTF-8 string that describes the 1202 * file such that one can get the #GFile back using 1203 * g_file_parse_name(). 1204 * 1205 * This is generally used to show the #GFile as a nice 1206 * full-pathname kind of string in a user interface, 1207 * like in a location entry. 1208 * 1209 * For local files with names that can safely be converted 1210 * to UTF-8 the pathname is used, otherwise the IRI is used 1211 * (a form of URI that allows UTF-8 characters unescaped). 1212 * 1213 * This call does no blocking I/O. 1214 * 1215 * Returns: a string containing the #GFile's parse name. 1216 * The returned string should be freed with g_free() 1217 * when no longer needed. 1218 */ 1219 public string getParseName() 1220 { 1221 auto retStr = g_file_get_parse_name(getFileStruct()); 1222 1223 scope(exit) Str.freeString(retStr); 1224 return Str.toString(retStr); 1225 } 1226 1227 /** 1228 * Gets the local pathname for #GFile, if one exists. If non-%NULL, this is 1229 * guaranteed to be an absolute, canonical path. It might contain symlinks. 1230 * 1231 * This call does no blocking I/O. 1232 * 1233 * Returns: string containing the #GFile's path, 1234 * or %NULL if no such path exists. The returned string should be freed 1235 * with g_free() when no longer needed. 1236 */ 1237 public string getPath() 1238 { 1239 auto retStr = g_file_get_path(getFileStruct()); 1240 1241 scope(exit) Str.freeString(retStr); 1242 return Str.toString(retStr); 1243 } 1244 1245 /** 1246 * Gets the path for @descendant relative to @parent. 1247 * 1248 * This call does no blocking I/O. 1249 * 1250 * Params: 1251 * descendant = input #GFile 1252 * 1253 * Returns: string with the relative path from 1254 * @descendant to @parent, or %NULL if @descendant doesn't have @parent as 1255 * prefix. The returned string should be freed with g_free() when 1256 * no longer needed. 1257 */ 1258 public string getRelativePath(FileIF descendant) 1259 { 1260 auto retStr = g_file_get_relative_path(getFileStruct(), (descendant is null) ? null : descendant.getFileStruct()); 1261 1262 scope(exit) Str.freeString(retStr); 1263 return Str.toString(retStr); 1264 } 1265 1266 /** 1267 * Gets the URI for the @file. 1268 * 1269 * This call does no blocking I/O. 1270 * 1271 * Returns: a string containing the #GFile's URI. 1272 * The returned string should be freed with g_free() 1273 * when no longer needed. 1274 */ 1275 public string getUri() 1276 { 1277 auto retStr = g_file_get_uri(getFileStruct()); 1278 1279 scope(exit) Str.freeString(retStr); 1280 return Str.toString(retStr); 1281 } 1282 1283 /** 1284 * Gets the URI scheme for a #GFile. 1285 * RFC 3986 decodes the scheme as: 1286 * |[ 1287 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] 1288 * ]| 1289 * Common schemes include "file", "http", "ftp", etc. 1290 * 1291 * This call does no blocking I/O. 1292 * 1293 * Returns: a string containing the URI scheme for the given 1294 * #GFile. The returned string should be freed with g_free() 1295 * when no longer needed. 1296 */ 1297 public string getUriScheme() 1298 { 1299 auto retStr = g_file_get_uri_scheme(getFileStruct()); 1300 1301 scope(exit) Str.freeString(retStr); 1302 return Str.toString(retStr); 1303 } 1304 1305 /** 1306 * Checks if @file has a parent, and optionally, if it is @parent. 1307 * 1308 * If @parent is %NULL then this function returns %TRUE if @file has any 1309 * parent at all. If @parent is non-%NULL then %TRUE is only returned 1310 * if @file is an immediate child of @parent. 1311 * 1312 * Params: 1313 * parent = the parent to check for, or %NULL 1314 * 1315 * Returns: %TRUE if @file is an immediate child of @parent (or any parent in 1316 * the case that @parent is %NULL). 1317 * 1318 * Since: 2.24 1319 */ 1320 public bool hasParent(FileIF parent) 1321 { 1322 return g_file_has_parent(getFileStruct(), (parent is null) ? null : parent.getFileStruct()) != 0; 1323 } 1324 1325 /** 1326 * Checks whether @file has the prefix specified by @prefix. 1327 * 1328 * In other words, if the names of initial elements of @file's 1329 * pathname match @prefix. Only full pathname elements are matched, 1330 * so a path like /foo is not considered a prefix of /foobar, only 1331 * of /foo/bar. 1332 * 1333 * A #GFile is not a prefix of itself. If you want to check for 1334 * equality, use g_file_equal(). 1335 * 1336 * This call does no I/O, as it works purely on names. As such it can 1337 * sometimes return %FALSE even if @file is inside a @prefix (from a 1338 * filesystem point of view), because the prefix of @file is an alias 1339 * of @prefix. 1340 * 1341 * Params: 1342 * prefix = input #GFile 1343 * 1344 * Returns: %TRUE if the @files's parent, grandparent, etc is @prefix, 1345 * %FALSE otherwise. 1346 */ 1347 public bool hasPrefix(FileIF prefix) 1348 { 1349 return g_file_has_prefix(getFileStruct(), (prefix is null) ? null : prefix.getFileStruct()) != 0; 1350 } 1351 1352 /** 1353 * Checks to see if a #GFile has a given URI scheme. 1354 * 1355 * This call does no blocking I/O. 1356 * 1357 * Params: 1358 * uriScheme = a string containing a URI scheme 1359 * 1360 * Returns: %TRUE if #GFile's backend supports the 1361 * given URI scheme, %FALSE if URI scheme is %NULL, 1362 * not supported, or #GFile is invalid. 1363 */ 1364 public bool hasUriScheme(string uriScheme) 1365 { 1366 return g_file_has_uri_scheme(getFileStruct(), Str.toStringz(uriScheme)) != 0; 1367 } 1368 1369 /** 1370 * Creates a hash value for a #GFile. 1371 * 1372 * This call does no blocking I/O. 1373 * 1374 * Returns: 0 if @file is not a valid #GFile, otherwise an 1375 * integer that can be used as hash value for the #GFile. 1376 * This function is intended for easily hashing a #GFile to 1377 * add to a #GHashTable or similar data structure. 1378 */ 1379 public uint hash() 1380 { 1381 return g_file_hash(getFileStruct()); 1382 } 1383 1384 /** 1385 * Checks to see if a file is native to the platform. 1386 * 1387 * A native file s one expressed in the platform-native filename format, 1388 * e.g. "C:\Windows" or "/usr/bin/". This does not mean the file is local, 1389 * as it might be on a locally mounted remote filesystem. 1390 * 1391 * On some systems non-native files may be available using the native 1392 * filesystem via a userspace filesystem (FUSE), in these cases this call 1393 * will return %FALSE, but g_file_get_path() will still return a native path. 1394 * 1395 * This call does no blocking I/O. 1396 * 1397 * Returns: %TRUE if @file is native 1398 */ 1399 public bool isNative() 1400 { 1401 return g_file_is_native(getFileStruct()) != 0; 1402 } 1403 1404 /** 1405 * Loads the content of the file into memory. The data is always 1406 * zero-terminated, but this is not included in the resultant @length. 1407 * The returned @content should be freed with g_free() when no longer 1408 * needed. 1409 * 1410 * If @cancellable is not %NULL, then the operation can be cancelled by 1411 * triggering the cancellable object from another thread. If the operation 1412 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1413 * 1414 * Params: 1415 * cancellable = optional #GCancellable object, %NULL to ignore 1416 * contents = a location to place the contents of the file 1417 * length = a location to place the length of the contents of the file, 1418 * or %NULL if the length is not needed 1419 * etagOut = a location to place the current entity tag for the file, 1420 * or %NULL if the entity tag is not needed 1421 * 1422 * Returns: %TRUE if the @file's contents were successfully loaded. 1423 * %FALSE if there were errors. 1424 * 1425 * Throws: GException on failure. 1426 */ 1427 public bool loadContents(Cancellable cancellable, out string contents, out string etagOut) 1428 { 1429 char* outcontents = null; 1430 size_t length; 1431 char* outetagOut = null; 1432 GError* err = null; 1433 1434 auto p = g_file_load_contents(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &outcontents, &length, &outetagOut, &err) != 0; 1435 1436 if (err !is null) 1437 { 1438 throw new GException( new ErrorG(err) ); 1439 } 1440 1441 contents = Str.toString(outcontents, length); 1442 etagOut = Str.toString(outetagOut); 1443 1444 return p; 1445 } 1446 1447 /** 1448 * Starts an asynchronous load of the @file's contents. 1449 * 1450 * For more details, see g_file_load_contents() which is 1451 * the synchronous version of this call. 1452 * 1453 * When the load operation has completed, @callback will be called 1454 * with @user data. To finish the operation, call 1455 * g_file_load_contents_finish() with the #GAsyncResult returned by 1456 * the @callback. 1457 * 1458 * If @cancellable is not %NULL, then the operation can be cancelled by 1459 * triggering the cancellable object from another thread. If the operation 1460 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1461 * 1462 * Params: 1463 * cancellable = optional #GCancellable object, %NULL to ignore 1464 * callback = a #GAsyncReadyCallback to call when the request is satisfied 1465 * userData = the data to pass to callback function 1466 */ 1467 public void loadContentsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1468 { 1469 g_file_load_contents_async(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1470 } 1471 1472 /** 1473 * Finishes an asynchronous load of the @file's contents. 1474 * The contents are placed in @contents, and @length is set to the 1475 * size of the @contents string. The @content should be freed with 1476 * g_free() when no longer needed. If @etag_out is present, it will be 1477 * set to the new entity tag for the @file. 1478 * 1479 * Params: 1480 * res = a #GAsyncResult 1481 * contents = a location to place the contents of the file 1482 * length = a location to place the length of the contents of the file, 1483 * or %NULL if the length is not needed 1484 * etagOut = a location to place the current entity tag for the file, 1485 * or %NULL if the entity tag is not needed 1486 * 1487 * Returns: %TRUE if the load was successful. If %FALSE and @error is 1488 * present, it will be set appropriately. 1489 * 1490 * Throws: GException on failure. 1491 */ 1492 public bool loadContentsFinish(AsyncResultIF res, out string contents, out string etagOut) 1493 { 1494 char* outcontents = null; 1495 size_t length; 1496 char* outetagOut = null; 1497 GError* err = null; 1498 1499 auto p = g_file_load_contents_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &outcontents, &length, &outetagOut, &err) != 0; 1500 1501 if (err !is null) 1502 { 1503 throw new GException( new ErrorG(err) ); 1504 } 1505 1506 contents = Str.toString(outcontents, length); 1507 etagOut = Str.toString(outetagOut); 1508 1509 return p; 1510 } 1511 1512 /** 1513 * Reads the partial contents of a file. A #GFileReadMoreCallback should 1514 * be used to stop reading from the file when appropriate, else this 1515 * function will behave exactly as g_file_load_contents_async(). This 1516 * operation can be finished by g_file_load_partial_contents_finish(). 1517 * 1518 * Users of this function should be aware that @user_data is passed to 1519 * both the @read_more_callback and the @callback. 1520 * 1521 * If @cancellable is not %NULL, then the operation can be cancelled by 1522 * triggering the cancellable object from another thread. If the operation 1523 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1524 * 1525 * Params: 1526 * cancellable = optional #GCancellable object, %NULL to ignore 1527 * readMoreCallback = a #GFileReadMoreCallback to receive partial data 1528 * and to specify whether further data should be read 1529 * callback = a #GAsyncReadyCallback to call when the request is satisfied 1530 * userData = the data to pass to the callback functions 1531 */ 1532 public void loadPartialContentsAsync(Cancellable cancellable, GFileReadMoreCallback readMoreCallback, GAsyncReadyCallback callback, void* userData) 1533 { 1534 g_file_load_partial_contents_async(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), readMoreCallback, callback, userData); 1535 } 1536 1537 /** 1538 * Finishes an asynchronous partial load operation that was started 1539 * with g_file_load_partial_contents_async(). The data is always 1540 * zero-terminated, but this is not included in the resultant @length. 1541 * The returned @content should be freed with g_free() when no longer 1542 * needed. 1543 * 1544 * Params: 1545 * res = a #GAsyncResult 1546 * contents = a location to place the contents of the file 1547 * length = a location to place the length of the contents of the file, 1548 * or %NULL if the length is not needed 1549 * etagOut = a location to place the current entity tag for the file, 1550 * or %NULL if the entity tag is not needed 1551 * 1552 * Returns: %TRUE if the load was successful. If %FALSE and @error is 1553 * present, it will be set appropriately. 1554 * 1555 * Throws: GException on failure. 1556 */ 1557 public bool loadPartialContentsFinish(AsyncResultIF res, out string contents, out string etagOut) 1558 { 1559 char* outcontents = null; 1560 size_t length; 1561 char* outetagOut = null; 1562 GError* err = null; 1563 1564 auto p = g_file_load_partial_contents_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &outcontents, &length, &outetagOut, &err) != 0; 1565 1566 if (err !is null) 1567 { 1568 throw new GException( new ErrorG(err) ); 1569 } 1570 1571 contents = Str.toString(outcontents, length); 1572 etagOut = Str.toString(outetagOut); 1573 1574 return p; 1575 } 1576 1577 /** 1578 * Creates a directory. Note that this will only create a child directory 1579 * of the immediate parent directory of the path or URI given by the #GFile. 1580 * To recursively create directories, see g_file_make_directory_with_parents(). 1581 * This function will fail if the parent directory does not exist, setting 1582 * @error to %G_IO_ERROR_NOT_FOUND. If the file system doesn't support 1583 * creating directories, this function will fail, setting @error to 1584 * %G_IO_ERROR_NOT_SUPPORTED. 1585 * 1586 * For a local #GFile the newly created directory will have the default 1587 * (current) ownership and permissions of the current process. 1588 * 1589 * If @cancellable is not %NULL, then the operation can be cancelled by 1590 * triggering the cancellable object from another thread. If the operation 1591 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1592 * 1593 * Params: 1594 * cancellable = optional #GCancellable object, 1595 * %NULL to ignore 1596 * 1597 * Returns: %TRUE on successful creation, %FALSE otherwise. 1598 * 1599 * Throws: GException on failure. 1600 */ 1601 public bool makeDirectory(Cancellable cancellable) 1602 { 1603 GError* err = null; 1604 1605 auto p = g_file_make_directory(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1606 1607 if (err !is null) 1608 { 1609 throw new GException( new ErrorG(err) ); 1610 } 1611 1612 return p; 1613 } 1614 1615 /** 1616 * Asynchronously creates a directory. 1617 * 1618 * Params: 1619 * ioPriority = the [I/O priority][io-priority] of the request 1620 * cancellable = optional #GCancellable object, 1621 * %NULL to ignore 1622 * callback = a #GAsyncReadyCallback to call 1623 * when the request is satisfied 1624 * userData = the data to pass to callback function 1625 * 1626 * Since: 2.38 1627 */ 1628 public void makeDirectoryAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1629 { 1630 g_file_make_directory_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1631 } 1632 1633 /** 1634 * Finishes an asynchronous directory creation, started with 1635 * g_file_make_directory_async(). 1636 * 1637 * Params: 1638 * result = a #GAsyncResult 1639 * 1640 * Returns: %TRUE on successful directory creation, %FALSE otherwise. 1641 * 1642 * Since: 2.38 1643 * 1644 * Throws: GException on failure. 1645 */ 1646 public bool makeDirectoryFinish(AsyncResultIF result) 1647 { 1648 GError* err = null; 1649 1650 auto p = g_file_make_directory_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 1651 1652 if (err !is null) 1653 { 1654 throw new GException( new ErrorG(err) ); 1655 } 1656 1657 return p; 1658 } 1659 1660 /** 1661 * Creates a directory and any parent directories that may not 1662 * exist similar to 'mkdir -p'. If the file system does not support 1663 * creating directories, this function will fail, setting @error to 1664 * %G_IO_ERROR_NOT_SUPPORTED. If the directory itself already exists, 1665 * this function will fail setting @error to %G_IO_ERROR_EXISTS, unlike 1666 * the similar g_mkdir_with_parents(). 1667 * 1668 * For a local #GFile the newly created directories will have the default 1669 * (current) ownership and permissions of the current process. 1670 * 1671 * If @cancellable is not %NULL, then the operation can be cancelled by 1672 * triggering the cancellable object from another thread. If the operation 1673 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1674 * 1675 * Params: 1676 * cancellable = optional #GCancellable object, 1677 * %NULL to ignore 1678 * 1679 * Returns: %TRUE if all directories have been successfully created, %FALSE 1680 * otherwise. 1681 * 1682 * Since: 2.18 1683 * 1684 * Throws: GException on failure. 1685 */ 1686 public bool makeDirectoryWithParents(Cancellable cancellable) 1687 { 1688 GError* err = null; 1689 1690 auto p = g_file_make_directory_with_parents(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1691 1692 if (err !is null) 1693 { 1694 throw new GException( new ErrorG(err) ); 1695 } 1696 1697 return p; 1698 } 1699 1700 /** 1701 * Creates a symbolic link named @file which contains the string 1702 * @symlink_value. 1703 * 1704 * If @cancellable is not %NULL, then the operation can be cancelled by 1705 * triggering the cancellable object from another thread. If the operation 1706 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1707 * 1708 * Params: 1709 * symlinkValue = a string with the path for the target 1710 * of the new symlink 1711 * cancellable = optional #GCancellable object, 1712 * %NULL to ignore 1713 * 1714 * Returns: %TRUE on the creation of a new symlink, %FALSE otherwise. 1715 * 1716 * Throws: GException on failure. 1717 */ 1718 public bool makeSymbolicLink(string symlinkValue, Cancellable cancellable) 1719 { 1720 GError* err = null; 1721 1722 auto p = g_file_make_symbolic_link(getFileStruct(), Str.toStringz(symlinkValue), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1723 1724 if (err !is null) 1725 { 1726 throw new GException( new ErrorG(err) ); 1727 } 1728 1729 return p; 1730 } 1731 1732 /** 1733 * Recursively measures the disk usage of @file. 1734 * 1735 * This is essentially an analog of the 'du' command, but it also 1736 * reports the number of directories and non-directory files encountered 1737 * (including things like symbolic links). 1738 * 1739 * By default, errors are only reported against the toplevel file 1740 * itself. Errors found while recursing are silently ignored, unless 1741 * %G_FILE_DISK_USAGE_REPORT_ALL_ERRORS is given in @flags. 1742 * 1743 * The returned size, @disk_usage, is in bytes and should be formatted 1744 * with g_format_size() in order to get something reasonable for showing 1745 * in a user interface. 1746 * 1747 * @progress_callback and @progress_data can be given to request 1748 * periodic progress updates while scanning. See the documentation for 1749 * #GFileMeasureProgressCallback for information about when and how the 1750 * callback will be invoked. 1751 * 1752 * Params: 1753 * flags = #GFileMeasureFlags 1754 * cancellable = optional #GCancellable 1755 * progressCallback = a #GFileMeasureProgressCallback 1756 * progressData = user_data for @progress_callback 1757 * diskUsage = the number of bytes of disk space used 1758 * numDirs = the number of directories encountered 1759 * numFiles = the number of non-directories encountered 1760 * 1761 * Returns: %TRUE if successful, with the out parameters set. 1762 * %FALSE otherwise, with @error set. 1763 * 1764 * Since: 2.38 1765 * 1766 * Throws: GException on failure. 1767 */ 1768 public bool measureDiskUsage(GFileMeasureFlags flags, Cancellable cancellable, GFileMeasureProgressCallback progressCallback, void* progressData, out ulong diskUsage, out ulong numDirs, out ulong numFiles) 1769 { 1770 GError* err = null; 1771 1772 auto p = g_file_measure_disk_usage(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressData, &diskUsage, &numDirs, &numFiles, &err) != 0; 1773 1774 if (err !is null) 1775 { 1776 throw new GException( new ErrorG(err) ); 1777 } 1778 1779 return p; 1780 } 1781 1782 /** 1783 * Recursively measures the disk usage of @file. 1784 * 1785 * This is the asynchronous version of g_file_measure_disk_usage(). See 1786 * there for more information. 1787 * 1788 * Params: 1789 * flags = #GFileMeasureFlags 1790 * ioPriority = the [I/O priority][io-priority] of the request 1791 * cancellable = optional #GCancellable 1792 * progressCallback = a #GFileMeasureProgressCallback 1793 * progressData = user_data for @progress_callback 1794 * callback = a #GAsyncReadyCallback to call when complete 1795 * userData = the data to pass to callback function 1796 * 1797 * Since: 2.38 1798 */ 1799 public void measureDiskUsageAsync(GFileMeasureFlags flags, int ioPriority, Cancellable cancellable, GFileMeasureProgressCallback progressCallback, void* progressData, GAsyncReadyCallback callback, void* userData) 1800 { 1801 g_file_measure_disk_usage_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressData, callback, userData); 1802 } 1803 1804 /** 1805 * Collects the results from an earlier call to 1806 * g_file_measure_disk_usage_async(). See g_file_measure_disk_usage() for 1807 * more information. 1808 * 1809 * Params: 1810 * result = the #GAsyncResult passed to your #GAsyncReadyCallback 1811 * diskUsage = the number of bytes of disk space used 1812 * numDirs = the number of directories encountered 1813 * numFiles = the number of non-directories encountered 1814 * 1815 * Returns: %TRUE if successful, with the out parameters set. 1816 * %FALSE otherwise, with @error set. 1817 * 1818 * Since: 2.38 1819 * 1820 * Throws: GException on failure. 1821 */ 1822 public bool measureDiskUsageFinish(AsyncResultIF result, out ulong diskUsage, out ulong numDirs, out ulong numFiles) 1823 { 1824 GError* err = null; 1825 1826 auto p = g_file_measure_disk_usage_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &diskUsage, &numDirs, &numFiles, &err) != 0; 1827 1828 if (err !is null) 1829 { 1830 throw new GException( new ErrorG(err) ); 1831 } 1832 1833 return p; 1834 } 1835 1836 /** 1837 * Obtains a file or directory monitor for the given file, 1838 * depending on the type of the file. 1839 * 1840 * If @cancellable is not %NULL, then the operation can be cancelled by 1841 * triggering the cancellable object from another thread. If the operation 1842 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1843 * 1844 * Params: 1845 * flags = a set of #GFileMonitorFlags 1846 * cancellable = optional #GCancellable object, 1847 * %NULL to ignore 1848 * 1849 * Returns: a #GFileMonitor for the given @file, 1850 * or %NULL on error. 1851 * Free the returned object with g_object_unref(). 1852 * 1853 * Since: 2.18 1854 * 1855 * Throws: GException on failure. 1856 */ 1857 public FileMonitor monitor(GFileMonitorFlags flags, Cancellable cancellable) 1858 { 1859 GError* err = null; 1860 1861 auto p = g_file_monitor(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1862 1863 if (err !is null) 1864 { 1865 throw new GException( new ErrorG(err) ); 1866 } 1867 1868 if(p is null) 1869 { 1870 return null; 1871 } 1872 1873 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) p, true); 1874 } 1875 1876 /** 1877 * Obtains a directory monitor for the given file. 1878 * This may fail if directory monitoring is not supported. 1879 * 1880 * If @cancellable is not %NULL, then the operation can be cancelled by 1881 * triggering the cancellable object from another thread. If the operation 1882 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1883 * 1884 * It does not make sense for @flags to contain 1885 * %G_FILE_MONITOR_WATCH_HARD_LINKS, since hard links can not be made to 1886 * directories. It is not possible to monitor all the files in a 1887 * directory for changes made via hard links; if you want to do this then 1888 * you must register individual watches with g_file_monitor(). 1889 * 1890 * Params: 1891 * flags = a set of #GFileMonitorFlags 1892 * cancellable = optional #GCancellable object, 1893 * %NULL to ignore 1894 * 1895 * Returns: a #GFileMonitor for the given @file, 1896 * or %NULL on error. 1897 * Free the returned object with g_object_unref(). 1898 * 1899 * Throws: GException on failure. 1900 */ 1901 public FileMonitor monitorDirectory(GFileMonitorFlags flags, Cancellable cancellable) 1902 { 1903 GError* err = null; 1904 1905 auto p = g_file_monitor_directory(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1906 1907 if (err !is null) 1908 { 1909 throw new GException( new ErrorG(err) ); 1910 } 1911 1912 if(p is null) 1913 { 1914 return null; 1915 } 1916 1917 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) p, true); 1918 } 1919 1920 /** 1921 * Obtains a file monitor for the given file. If no file notification 1922 * mechanism exists, then regular polling of the file is used. 1923 * 1924 * If @cancellable is not %NULL, then the operation can be cancelled by 1925 * triggering the cancellable object from another thread. If the operation 1926 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1927 * 1928 * If @flags contains %G_FILE_MONITOR_WATCH_HARD_LINKS then the monitor 1929 * will also attempt to report changes made to the file via another 1930 * filename (ie, a hard link). Without this flag, you can only rely on 1931 * changes made through the filename contained in @file to be 1932 * reported. Using this flag may result in an increase in resource 1933 * usage, and may not have any effect depending on the #GFileMonitor 1934 * backend and/or filesystem type. 1935 * 1936 * Params: 1937 * flags = a set of #GFileMonitorFlags 1938 * cancellable = optional #GCancellable object, 1939 * %NULL to ignore 1940 * 1941 * Returns: a #GFileMonitor for the given @file, 1942 * or %NULL on error. 1943 * Free the returned object with g_object_unref(). 1944 * 1945 * Throws: GException on failure. 1946 */ 1947 public FileMonitor monitorFile(GFileMonitorFlags flags, Cancellable cancellable) 1948 { 1949 GError* err = null; 1950 1951 auto p = g_file_monitor_file(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1952 1953 if (err !is null) 1954 { 1955 throw new GException( new ErrorG(err) ); 1956 } 1957 1958 if(p is null) 1959 { 1960 return null; 1961 } 1962 1963 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) p, true); 1964 } 1965 1966 /** 1967 * Starts a @mount_operation, mounting the volume that contains 1968 * the file @location. 1969 * 1970 * When this operation has completed, @callback will be called with 1971 * @user_user data, and the operation can be finalized with 1972 * g_file_mount_enclosing_volume_finish(). 1973 * 1974 * If @cancellable is not %NULL, then the operation can be cancelled by 1975 * triggering the cancellable object from another thread. If the operation 1976 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1977 * 1978 * Params: 1979 * flags = flags affecting the operation 1980 * mountOperation = a #GMountOperation 1981 * or %NULL to avoid user interaction 1982 * cancellable = optional #GCancellable object, 1983 * %NULL to ignore 1984 * callback = a #GAsyncReadyCallback to call 1985 * when the request is satisfied, or %NULL 1986 * userData = the data to pass to callback function 1987 */ 1988 public void mountEnclosingVolume(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1989 { 1990 g_file_mount_enclosing_volume(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1991 } 1992 1993 /** 1994 * Finishes a mount operation started by g_file_mount_enclosing_volume(). 1995 * 1996 * Params: 1997 * result = a #GAsyncResult 1998 * 1999 * Returns: %TRUE if successful. If an error has occurred, 2000 * this function will return %FALSE and set @error 2001 * appropriately if present. 2002 * 2003 * Throws: GException on failure. 2004 */ 2005 public bool mountEnclosingVolumeFinish(AsyncResultIF result) 2006 { 2007 GError* err = null; 2008 2009 auto p = g_file_mount_enclosing_volume_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2010 2011 if (err !is null) 2012 { 2013 throw new GException( new ErrorG(err) ); 2014 } 2015 2016 return p; 2017 } 2018 2019 /** 2020 * Mounts a file of type G_FILE_TYPE_MOUNTABLE. 2021 * Using @mount_operation, you can request callbacks when, for instance, 2022 * passwords are needed during authentication. 2023 * 2024 * If @cancellable is not %NULL, then the operation can be cancelled by 2025 * triggering the cancellable object from another thread. If the operation 2026 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2027 * 2028 * When the operation is finished, @callback will be called. 2029 * You can then call g_file_mount_mountable_finish() to get 2030 * the result of the operation. 2031 * 2032 * Params: 2033 * flags = flags affecting the operation 2034 * mountOperation = a #GMountOperation, 2035 * or %NULL to avoid user interaction 2036 * cancellable = optional #GCancellable object, 2037 * %NULL to ignore 2038 * callback = a #GAsyncReadyCallback to call 2039 * when the request is satisfied, or %NULL 2040 * userData = the data to pass to callback function 2041 */ 2042 public void mountMountable(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2043 { 2044 g_file_mount_mountable(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2045 } 2046 2047 /** 2048 * Finishes a mount operation. See g_file_mount_mountable() for details. 2049 * 2050 * Finish an asynchronous mount operation that was started 2051 * with g_file_mount_mountable(). 2052 * 2053 * Params: 2054 * result = a #GAsyncResult 2055 * 2056 * Returns: a #GFile or %NULL on error. 2057 * Free the returned object with g_object_unref(). 2058 * 2059 * Throws: GException on failure. 2060 */ 2061 public FileIF mountMountableFinish(AsyncResultIF result) 2062 { 2063 GError* err = null; 2064 2065 auto p = g_file_mount_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err); 2066 2067 if (err !is null) 2068 { 2069 throw new GException( new ErrorG(err) ); 2070 } 2071 2072 if(p is null) 2073 { 2074 return null; 2075 } 2076 2077 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 2078 } 2079 2080 /** 2081 * Tries to move the file or directory @source to the location specified 2082 * by @destination. If native move operations are supported then this is 2083 * used, otherwise a copy + delete fallback is used. The native 2084 * implementation may support moving directories (for instance on moves 2085 * inside the same filesystem), but the fallback code does not. 2086 * 2087 * If the flag #G_FILE_COPY_OVERWRITE is specified an already 2088 * existing @destination file is overwritten. 2089 * 2090 * If the flag #G_FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks 2091 * will be copied as symlinks, otherwise the target of the 2092 * @source symlink will be copied. 2093 * 2094 * If @cancellable is not %NULL, then the operation can be cancelled by 2095 * triggering the cancellable object from another thread. If the operation 2096 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2097 * 2098 * If @progress_callback is not %NULL, then the operation can be monitored 2099 * by setting this to a #GFileProgressCallback function. 2100 * @progress_callback_data will be passed to this function. It is 2101 * guaranteed that this callback will be called after all data has been 2102 * transferred with the total number of bytes copied during the operation. 2103 * 2104 * If the @source file does not exist, then the %G_IO_ERROR_NOT_FOUND 2105 * error is returned, independent on the status of the @destination. 2106 * 2107 * If #G_FILE_COPY_OVERWRITE is not specified and the target exists, 2108 * then the error %G_IO_ERROR_EXISTS is returned. 2109 * 2110 * If trying to overwrite a file over a directory, the %G_IO_ERROR_IS_DIRECTORY 2111 * error is returned. If trying to overwrite a directory with a directory the 2112 * %G_IO_ERROR_WOULD_MERGE error is returned. 2113 * 2114 * If the source is a directory and the target does not exist, or 2115 * #G_FILE_COPY_OVERWRITE is specified and the target is a file, then 2116 * the %G_IO_ERROR_WOULD_RECURSE error may be returned (if the native 2117 * move operation isn't available). 2118 * 2119 * Params: 2120 * destination = #GFile pointing to the destination location 2121 * flags = set of #GFileCopyFlags 2122 * cancellable = optional #GCancellable object, 2123 * %NULL to ignore 2124 * progressCallback = #GFileProgressCallback 2125 * function for updates 2126 * progressCallbackData = gpointer to user data for 2127 * the callback function 2128 * 2129 * Returns: %TRUE on successful move, %FALSE otherwise. 2130 * 2131 * Throws: GException on failure. 2132 */ 2133 public bool move(FileIF destination, GFileCopyFlags flags, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData) 2134 { 2135 GError* err = null; 2136 2137 auto p = g_file_move(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressCallbackData, &err) != 0; 2138 2139 if (err !is null) 2140 { 2141 throw new GException( new ErrorG(err) ); 2142 } 2143 2144 return p; 2145 } 2146 2147 /** 2148 * Opens an existing file for reading and writing. The result is 2149 * a #GFileIOStream that can be used to read and write the contents 2150 * of the file. 2151 * 2152 * If @cancellable is not %NULL, then the operation can be cancelled 2153 * by triggering the cancellable object from another thread. If the 2154 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2155 * returned. 2156 * 2157 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 2158 * be returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY 2159 * error will be returned. Other errors are possible too, and depend on 2160 * what kind of filesystem the file is on. Note that in many non-local 2161 * file cases read and write streams are not supported, so make sure you 2162 * really need to do read and write streaming, rather than just opening 2163 * for reading or writing. 2164 * 2165 * Params: 2166 * cancellable = a #GCancellable 2167 * 2168 * Returns: #GFileIOStream or %NULL on error. 2169 * Free the returned object with g_object_unref(). 2170 * 2171 * Since: 2.22 2172 * 2173 * Throws: GException on failure. 2174 */ 2175 public FileIOStream openReadwrite(Cancellable cancellable) 2176 { 2177 GError* err = null; 2178 2179 auto p = g_file_open_readwrite(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2180 2181 if (err !is null) 2182 { 2183 throw new GException( new ErrorG(err) ); 2184 } 2185 2186 if(p is null) 2187 { 2188 return null; 2189 } 2190 2191 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 2192 } 2193 2194 /** 2195 * Asynchronously opens @file for reading and writing. 2196 * 2197 * For more details, see g_file_open_readwrite() which is 2198 * the synchronous version of this call. 2199 * 2200 * When the operation is finished, @callback will be called. 2201 * You can then call g_file_open_readwrite_finish() to get 2202 * the result of the operation. 2203 * 2204 * Params: 2205 * ioPriority = the [I/O priority][io-priority] of the request 2206 * cancellable = optional #GCancellable object, 2207 * %NULL to ignore 2208 * callback = a #GAsyncReadyCallback to call 2209 * when the request is satisfied 2210 * userData = the data to pass to callback function 2211 * 2212 * Since: 2.22 2213 */ 2214 public void openReadwriteAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2215 { 2216 g_file_open_readwrite_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2217 } 2218 2219 /** 2220 * Finishes an asynchronous file read operation started with 2221 * g_file_open_readwrite_async(). 2222 * 2223 * Params: 2224 * res = a #GAsyncResult 2225 * 2226 * Returns: a #GFileIOStream or %NULL on error. 2227 * Free the returned object with g_object_unref(). 2228 * 2229 * Since: 2.22 2230 * 2231 * Throws: GException on failure. 2232 */ 2233 public FileIOStream openReadwriteFinish(AsyncResultIF res) 2234 { 2235 GError* err = null; 2236 2237 auto p = g_file_open_readwrite_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2238 2239 if (err !is null) 2240 { 2241 throw new GException( new ErrorG(err) ); 2242 } 2243 2244 if(p is null) 2245 { 2246 return null; 2247 } 2248 2249 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 2250 } 2251 2252 /** 2253 * Polls a file of type #G_FILE_TYPE_MOUNTABLE. 2254 * 2255 * If @cancellable is not %NULL, then the operation can be cancelled by 2256 * triggering the cancellable object from another thread. If the operation 2257 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2258 * 2259 * When the operation is finished, @callback will be called. 2260 * You can then call g_file_mount_mountable_finish() to get 2261 * the result of the operation. 2262 * 2263 * Params: 2264 * cancellable = optional #GCancellable object, %NULL to ignore 2265 * callback = a #GAsyncReadyCallback to call 2266 * when the request is satisfied, or %NULL 2267 * userData = the data to pass to callback function 2268 * 2269 * Since: 2.22 2270 */ 2271 public void pollMountable(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2272 { 2273 g_file_poll_mountable(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2274 } 2275 2276 /** 2277 * Finishes a poll operation. See g_file_poll_mountable() for details. 2278 * 2279 * Finish an asynchronous poll operation that was polled 2280 * with g_file_poll_mountable(). 2281 * 2282 * Params: 2283 * result = a #GAsyncResult 2284 * 2285 * Returns: %TRUE if the operation finished successfully. %FALSE 2286 * otherwise. 2287 * 2288 * Since: 2.22 2289 * 2290 * Throws: GException on failure. 2291 */ 2292 public bool pollMountableFinish(AsyncResultIF result) 2293 { 2294 GError* err = null; 2295 2296 auto p = g_file_poll_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2297 2298 if (err !is null) 2299 { 2300 throw new GException( new ErrorG(err) ); 2301 } 2302 2303 return p; 2304 } 2305 2306 /** 2307 * Returns the #GAppInfo that is registered as the default 2308 * application to handle the file specified by @file. 2309 * 2310 * If @cancellable is not %NULL, then the operation can be cancelled by 2311 * triggering the cancellable object from another thread. If the operation 2312 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2313 * 2314 * Params: 2315 * cancellable = optional #GCancellable object, %NULL to ignore 2316 * 2317 * Returns: a #GAppInfo if the handle was found, 2318 * %NULL if there were errors. 2319 * When you are done with it, release it with g_object_unref() 2320 * 2321 * Throws: GException on failure. 2322 */ 2323 public AppInfoIF queryDefaultHandler(Cancellable cancellable) 2324 { 2325 GError* err = null; 2326 2327 auto p = g_file_query_default_handler(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2328 2329 if (err !is null) 2330 { 2331 throw new GException( new ErrorG(err) ); 2332 } 2333 2334 if(p is null) 2335 { 2336 return null; 2337 } 2338 2339 return ObjectG.getDObject!(AppInfo, AppInfoIF)(cast(GAppInfo*) p, true); 2340 } 2341 2342 /** 2343 * Utility function to check if a particular file exists. This is 2344 * implemented using g_file_query_info() and as such does blocking I/O. 2345 * 2346 * Note that in many cases it is racy to first check for file existence 2347 * and then execute something based on the outcome of that, because the 2348 * file might have been created or removed in between the operations. The 2349 * general approach to handling that is to not check, but just do the 2350 * operation and handle the errors as they come. 2351 * 2352 * As an example of race-free checking, take the case of reading a file, 2353 * and if it doesn't exist, creating it. There are two racy versions: read 2354 * it, and on error create it; and: check if it exists, if not create it. 2355 * These can both result in two processes creating the file (with perhaps 2356 * a partially written file as the result). The correct approach is to 2357 * always try to create the file with g_file_create() which will either 2358 * atomically create the file or fail with a %G_IO_ERROR_EXISTS error. 2359 * 2360 * However, in many cases an existence check is useful in a user interface, 2361 * for instance to make a menu item sensitive/insensitive, so that you don't 2362 * have to fool users that something is possible and then just show an error 2363 * dialog. If you do this, you should make sure to also handle the errors 2364 * that can happen due to races when you execute the operation. 2365 * 2366 * Params: 2367 * cancellable = optional #GCancellable object, 2368 * %NULL to ignore 2369 * 2370 * Returns: %TRUE if the file exists (and can be detected without error), 2371 * %FALSE otherwise (or if cancelled). 2372 */ 2373 public bool queryExists(Cancellable cancellable) 2374 { 2375 return g_file_query_exists(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct()) != 0; 2376 } 2377 2378 /** 2379 * Utility function to inspect the #GFileType of a file. This is 2380 * implemented using g_file_query_info() and as such does blocking I/O. 2381 * 2382 * The primary use case of this method is to check if a file is 2383 * a regular file, directory, or symlink. 2384 * 2385 * Params: 2386 * flags = a set of #GFileQueryInfoFlags passed to g_file_query_info() 2387 * cancellable = optional #GCancellable object, 2388 * %NULL to ignore 2389 * 2390 * Returns: The #GFileType of the file and #G_FILE_TYPE_UNKNOWN 2391 * if the file does not exist 2392 * 2393 * Since: 2.18 2394 */ 2395 public GFileType queryFileType(GFileQueryInfoFlags flags, Cancellable cancellable) 2396 { 2397 return g_file_query_file_type(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct()); 2398 } 2399 2400 /** 2401 * Similar to g_file_query_info(), but obtains information 2402 * about the filesystem the @file is on, rather than the file itself. 2403 * For instance the amount of space available and the type of 2404 * the filesystem. 2405 * 2406 * The @attributes value is a string that specifies the attributes 2407 * that should be gathered. It is not an error if it's not possible 2408 * to read a particular requested attribute from a file - it just 2409 * won't be set. @attributes should be a comma-separated list of 2410 * attributes or attribute wildcards. The wildcard "*" means all 2411 * attributes, and a wildcard like "filesystem::*" means all attributes 2412 * in the filesystem namespace. The standard namespace for filesystem 2413 * attributes is "filesystem". Common attributes of interest are 2414 * #G_FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem 2415 * in bytes), #G_FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes available), 2416 * and #G_FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem). 2417 * 2418 * If @cancellable is not %NULL, then the operation can be cancelled 2419 * by triggering the cancellable object from another thread. If the 2420 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2421 * returned. 2422 * 2423 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 2424 * be returned. Other errors are possible too, and depend on what 2425 * kind of filesystem the file is on. 2426 * 2427 * Params: 2428 * attributes = an attribute query string 2429 * cancellable = optional #GCancellable object, 2430 * %NULL to ignore 2431 * 2432 * Returns: a #GFileInfo or %NULL if there was an error. 2433 * Free the returned object with g_object_unref(). 2434 * 2435 * Throws: GException on failure. 2436 */ 2437 public FileInfo queryFilesystemInfo(string attributes, Cancellable cancellable) 2438 { 2439 GError* err = null; 2440 2441 auto p = g_file_query_filesystem_info(getFileStruct(), Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2442 2443 if (err !is null) 2444 { 2445 throw new GException( new ErrorG(err) ); 2446 } 2447 2448 if(p is null) 2449 { 2450 return null; 2451 } 2452 2453 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true); 2454 } 2455 2456 /** 2457 * Asynchronously gets the requested information about the filesystem 2458 * that the specified @file is on. The result is a #GFileInfo object 2459 * that contains key-value attributes (such as type or size for the 2460 * file). 2461 * 2462 * For more details, see g_file_query_filesystem_info() which is the 2463 * synchronous version of this call. 2464 * 2465 * When the operation is finished, @callback will be called. You can 2466 * then call g_file_query_info_finish() to get the result of the 2467 * operation. 2468 * 2469 * Params: 2470 * attributes = an attribute query string 2471 * ioPriority = the [I/O priority][io-priority] of the request 2472 * cancellable = optional #GCancellable object, 2473 * %NULL to ignore 2474 * callback = a #GAsyncReadyCallback to call 2475 * when the request is satisfied 2476 * userData = the data to pass to callback function 2477 */ 2478 public void queryFilesystemInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2479 { 2480 g_file_query_filesystem_info_async(getFileStruct(), Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2481 } 2482 2483 /** 2484 * Finishes an asynchronous filesystem info query. 2485 * See g_file_query_filesystem_info_async(). 2486 * 2487 * Params: 2488 * res = a #GAsyncResult 2489 * 2490 * Returns: #GFileInfo for given @file 2491 * or %NULL on error. 2492 * Free the returned object with g_object_unref(). 2493 * 2494 * Throws: GException on failure. 2495 */ 2496 public FileInfo queryFilesystemInfoFinish(AsyncResultIF res) 2497 { 2498 GError* err = null; 2499 2500 auto p = g_file_query_filesystem_info_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2501 2502 if (err !is null) 2503 { 2504 throw new GException( new ErrorG(err) ); 2505 } 2506 2507 if(p is null) 2508 { 2509 return null; 2510 } 2511 2512 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true); 2513 } 2514 2515 /** 2516 * Gets the requested information about specified @file. 2517 * The result is a #GFileInfo object that contains key-value 2518 * attributes (such as the type or size of the file). 2519 * 2520 * The @attributes value is a string that specifies the file 2521 * attributes that should be gathered. It is not an error if 2522 * it's not possible to read a particular requested attribute 2523 * from a file - it just won't be set. @attributes should be a 2524 * comma-separated list of attributes or attribute wildcards. 2525 * The wildcard "*" means all attributes, and a wildcard like 2526 * "standard::*" means all attributes in the standard namespace. 2527 * An example attribute query be "standard::*,owner::user". 2528 * The standard attributes are available as defines, like 2529 * #G_FILE_ATTRIBUTE_STANDARD_NAME. 2530 * 2531 * If @cancellable is not %NULL, then the operation can be cancelled 2532 * by triggering the cancellable object from another thread. If the 2533 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2534 * returned. 2535 * 2536 * For symlinks, normally the information about the target of the 2537 * symlink is returned, rather than information about the symlink 2538 * itself. However if you pass #G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS 2539 * in @flags the information about the symlink itself will be returned. 2540 * Also, for symlinks that point to non-existing files the information 2541 * about the symlink itself will be returned. 2542 * 2543 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be 2544 * returned. Other errors are possible too, and depend on what kind of 2545 * filesystem the file is on. 2546 * 2547 * Params: 2548 * attributes = an attribute query string 2549 * flags = a set of #GFileQueryInfoFlags 2550 * cancellable = optional #GCancellable object, 2551 * %NULL to ignore 2552 * 2553 * Returns: a #GFileInfo for the given @file, or %NULL 2554 * on error. Free the returned object with g_object_unref(). 2555 * 2556 * Throws: GException on failure. 2557 */ 2558 public FileInfo queryInfo(string attributes, GFileQueryInfoFlags flags, Cancellable cancellable) 2559 { 2560 GError* err = null; 2561 2562 auto p = g_file_query_info(getFileStruct(), Str.toStringz(attributes), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2563 2564 if (err !is null) 2565 { 2566 throw new GException( new ErrorG(err) ); 2567 } 2568 2569 if(p is null) 2570 { 2571 return null; 2572 } 2573 2574 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true); 2575 } 2576 2577 /** 2578 * Asynchronously gets the requested information about specified @file. 2579 * The result is a #GFileInfo object that contains key-value attributes 2580 * (such as type or size for the file). 2581 * 2582 * For more details, see g_file_query_info() which is the synchronous 2583 * version of this call. 2584 * 2585 * When the operation is finished, @callback will be called. You can 2586 * then call g_file_query_info_finish() to get the result of the operation. 2587 * 2588 * Params: 2589 * attributes = an attribute query string 2590 * flags = a set of #GFileQueryInfoFlags 2591 * ioPriority = the [I/O priority][io-priority] of the request 2592 * cancellable = optional #GCancellable object, 2593 * %NULL to ignore 2594 * callback = a #GAsyncReadyCallback to call when the 2595 * request is satisfied 2596 * userData = the data to pass to callback function 2597 */ 2598 public void queryInfoAsync(string attributes, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2599 { 2600 g_file_query_info_async(getFileStruct(), Str.toStringz(attributes), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2601 } 2602 2603 /** 2604 * Finishes an asynchronous file info query. 2605 * See g_file_query_info_async(). 2606 * 2607 * Params: 2608 * res = a #GAsyncResult 2609 * 2610 * Returns: #GFileInfo for given @file 2611 * or %NULL on error. Free the returned object with 2612 * g_object_unref(). 2613 * 2614 * Throws: GException on failure. 2615 */ 2616 public FileInfo queryInfoFinish(AsyncResultIF res) 2617 { 2618 GError* err = null; 2619 2620 auto p = g_file_query_info_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2621 2622 if (err !is null) 2623 { 2624 throw new GException( new ErrorG(err) ); 2625 } 2626 2627 if(p is null) 2628 { 2629 return null; 2630 } 2631 2632 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true); 2633 } 2634 2635 /** 2636 * Obtain the list of settable attributes for the file. 2637 * 2638 * Returns the type and full attribute name of all the attributes 2639 * that can be set on this file. This doesn't mean setting it will 2640 * always succeed though, you might get an access failure, or some 2641 * specific file may not support a specific attribute. 2642 * 2643 * If @cancellable is not %NULL, then the operation can be cancelled by 2644 * triggering the cancellable object from another thread. If the operation 2645 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2646 * 2647 * Params: 2648 * cancellable = optional #GCancellable object, 2649 * %NULL to ignore 2650 * 2651 * Returns: a #GFileAttributeInfoList describing the settable attributes. 2652 * When you are done with it, release it with 2653 * g_file_attribute_info_list_unref() 2654 * 2655 * Throws: GException on failure. 2656 */ 2657 public FileAttributeInfoList querySettableAttributes(Cancellable cancellable) 2658 { 2659 GError* err = null; 2660 2661 auto p = g_file_query_settable_attributes(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2662 2663 if (err !is null) 2664 { 2665 throw new GException( new ErrorG(err) ); 2666 } 2667 2668 if(p is null) 2669 { 2670 return null; 2671 } 2672 2673 return ObjectG.getDObject!(FileAttributeInfoList)(cast(GFileAttributeInfoList*) p, true); 2674 } 2675 2676 /** 2677 * Obtain the list of attribute namespaces where new attributes 2678 * can be created by a user. An example of this is extended 2679 * attributes (in the "xattr" namespace). 2680 * 2681 * If @cancellable is not %NULL, then the operation can be cancelled by 2682 * triggering the cancellable object from another thread. If the operation 2683 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2684 * 2685 * Params: 2686 * cancellable = optional #GCancellable object, 2687 * %NULL to ignore 2688 * 2689 * Returns: a #GFileAttributeInfoList describing the writable namespaces. 2690 * When you are done with it, release it with 2691 * g_file_attribute_info_list_unref() 2692 * 2693 * Throws: GException on failure. 2694 */ 2695 public FileAttributeInfoList queryWritableNamespaces(Cancellable cancellable) 2696 { 2697 GError* err = null; 2698 2699 auto p = g_file_query_writable_namespaces(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2700 2701 if (err !is null) 2702 { 2703 throw new GException( new ErrorG(err) ); 2704 } 2705 2706 if(p is null) 2707 { 2708 return null; 2709 } 2710 2711 return ObjectG.getDObject!(FileAttributeInfoList)(cast(GFileAttributeInfoList*) p, true); 2712 } 2713 2714 /** 2715 * Opens a file for reading. The result is a #GFileInputStream that 2716 * can be used to read the contents of the file. 2717 * 2718 * If @cancellable is not %NULL, then the operation can be cancelled by 2719 * triggering the cancellable object from another thread. If the operation 2720 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2721 * 2722 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be 2723 * returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY 2724 * error will be returned. Other errors are possible too, and depend 2725 * on what kind of filesystem the file is on. 2726 * 2727 * Params: 2728 * cancellable = a #GCancellable 2729 * 2730 * Returns: #GFileInputStream or %NULL on error. 2731 * Free the returned object with g_object_unref(). 2732 * 2733 * Throws: GException on failure. 2734 */ 2735 public FileInputStream read(Cancellable cancellable) 2736 { 2737 GError* err = null; 2738 2739 auto p = g_file_read(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2740 2741 if (err !is null) 2742 { 2743 throw new GException( new ErrorG(err) ); 2744 } 2745 2746 if(p is null) 2747 { 2748 return null; 2749 } 2750 2751 return ObjectG.getDObject!(FileInputStream)(cast(GFileInputStream*) p, true); 2752 } 2753 2754 /** 2755 * Asynchronously opens @file for reading. 2756 * 2757 * For more details, see g_file_read() which is 2758 * the synchronous version of this call. 2759 * 2760 * When the operation is finished, @callback will be called. 2761 * You can then call g_file_read_finish() to get the result 2762 * of the operation. 2763 * 2764 * Params: 2765 * ioPriority = the [I/O priority][io-priority] of the request 2766 * cancellable = optional #GCancellable object, 2767 * %NULL to ignore 2768 * callback = a #GAsyncReadyCallback to call 2769 * when the request is satisfied 2770 * userData = the data to pass to callback function 2771 */ 2772 public void readAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2773 { 2774 g_file_read_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2775 } 2776 2777 /** 2778 * Finishes an asynchronous file read operation started with 2779 * g_file_read_async(). 2780 * 2781 * Params: 2782 * res = a #GAsyncResult 2783 * 2784 * Returns: a #GFileInputStream or %NULL on error. 2785 * Free the returned object with g_object_unref(). 2786 * 2787 * Throws: GException on failure. 2788 */ 2789 public FileInputStream readFinish(AsyncResultIF res) 2790 { 2791 GError* err = null; 2792 2793 auto p = g_file_read_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2794 2795 if (err !is null) 2796 { 2797 throw new GException( new ErrorG(err) ); 2798 } 2799 2800 if(p is null) 2801 { 2802 return null; 2803 } 2804 2805 return ObjectG.getDObject!(FileInputStream)(cast(GFileInputStream*) p, true); 2806 } 2807 2808 /** 2809 * Returns an output stream for overwriting the file, possibly 2810 * creating a backup copy of the file first. If the file doesn't exist, 2811 * it will be created. 2812 * 2813 * This will try to replace the file in the safest way possible so 2814 * that any errors during the writing will not affect an already 2815 * existing copy of the file. For instance, for local files it 2816 * may write to a temporary file and then atomically rename over 2817 * the destination when the stream is closed. 2818 * 2819 * By default files created are generally readable by everyone, 2820 * but if you pass #G_FILE_CREATE_PRIVATE in @flags the file 2821 * will be made readable only to the current user, to the level that 2822 * is supported on the target filesystem. 2823 * 2824 * If @cancellable is not %NULL, then the operation can be cancelled 2825 * by triggering the cancellable object from another thread. If the 2826 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2827 * returned. 2828 * 2829 * If you pass in a non-%NULL @etag value and @file already exists, then 2830 * this value is compared to the current entity tag of the file, and if 2831 * they differ an %G_IO_ERROR_WRONG_ETAG error is returned. This 2832 * generally means that the file has been changed since you last read 2833 * it. You can get the new etag from g_file_output_stream_get_etag() 2834 * after you've finished writing and closed the #GFileOutputStream. When 2835 * you load a new file you can use g_file_input_stream_query_info() to 2836 * get the etag of the file. 2837 * 2838 * If @make_backup is %TRUE, this function will attempt to make a 2839 * backup of the current file before overwriting it. If this fails 2840 * a %G_IO_ERROR_CANT_CREATE_BACKUP error will be returned. If you 2841 * want to replace anyway, try again with @make_backup set to %FALSE. 2842 * 2843 * If the file is a directory the %G_IO_ERROR_IS_DIRECTORY error will 2844 * be returned, and if the file is some other form of non-regular file 2845 * then a %G_IO_ERROR_NOT_REGULAR_FILE error will be returned. Some 2846 * file systems don't allow all file names, and may return an 2847 * %G_IO_ERROR_INVALID_FILENAME error, and if the name is to long 2848 * %G_IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are 2849 * possible too, and depend on what kind of filesystem the file is on. 2850 * 2851 * Params: 2852 * etag = an optional [entity tag][gfile-etag] 2853 * for the current #GFile, or #NULL to ignore 2854 * makeBackup = %TRUE if a backup should be created 2855 * flags = a set of #GFileCreateFlags 2856 * cancellable = optional #GCancellable object, 2857 * %NULL to ignore 2858 * 2859 * Returns: a #GFileOutputStream or %NULL on error. 2860 * Free the returned object with g_object_unref(). 2861 * 2862 * Throws: GException on failure. 2863 */ 2864 public FileOutputStream replace(string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable) 2865 { 2866 GError* err = null; 2867 2868 auto p = g_file_replace(getFileStruct(), Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2869 2870 if (err !is null) 2871 { 2872 throw new GException( new ErrorG(err) ); 2873 } 2874 2875 if(p is null) 2876 { 2877 return null; 2878 } 2879 2880 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) p, true); 2881 } 2882 2883 /** 2884 * Asynchronously overwrites the file, replacing the contents, 2885 * possibly creating a backup copy of the file first. 2886 * 2887 * For more details, see g_file_replace() which is 2888 * the synchronous version of this call. 2889 * 2890 * When the operation is finished, @callback will be called. 2891 * You can then call g_file_replace_finish() to get the result 2892 * of the operation. 2893 * 2894 * Params: 2895 * etag = an [entity tag][gfile-etag] for the current #GFile, 2896 * or %NULL to ignore 2897 * makeBackup = %TRUE if a backup should be created 2898 * flags = a set of #GFileCreateFlags 2899 * ioPriority = the [I/O priority][io-priority] of the request 2900 * cancellable = optional #GCancellable object, 2901 * %NULL to ignore 2902 * callback = a #GAsyncReadyCallback to call 2903 * when the request is satisfied 2904 * userData = the data to pass to callback function 2905 */ 2906 public void replaceAsync(string etag, bool makeBackup, GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2907 { 2908 g_file_replace_async(getFileStruct(), Str.toStringz(etag), makeBackup, flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2909 } 2910 2911 /** 2912 * Replaces the contents of @file with @contents of @length bytes. 2913 * 2914 * If @etag is specified (not %NULL), any existing file must have that etag, 2915 * or the error %G_IO_ERROR_WRONG_ETAG will be returned. 2916 * 2917 * If @make_backup is %TRUE, this function will attempt to make a backup 2918 * of @file. Internally, it uses g_file_replace(), so will try to replace the 2919 * file contents in the safest way possible. For example, atomic renames are 2920 * used when replacing local files’ contents. 2921 * 2922 * If @cancellable is not %NULL, then the operation can be cancelled by 2923 * triggering the cancellable object from another thread. If the operation 2924 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2925 * 2926 * The returned @new_etag can be used to verify that the file hasn't 2927 * changed the next time it is saved over. 2928 * 2929 * Params: 2930 * contents = a string containing the new contents for @file 2931 * length = the length of @contents in bytes 2932 * etag = the old [entity-tag][gfile-etag] for the document, 2933 * or %NULL 2934 * makeBackup = %TRUE if a backup should be created 2935 * flags = a set of #GFileCreateFlags 2936 * newEtag = a location to a new [entity tag][gfile-etag] 2937 * for the document. This should be freed with g_free() when no longer 2938 * needed, or %NULL 2939 * cancellable = optional #GCancellable object, %NULL to ignore 2940 * 2941 * Returns: %TRUE if successful. If an error has occurred, this function 2942 * will return %FALSE and set @error appropriately if present. 2943 * 2944 * Throws: GException on failure. 2945 */ 2946 public bool replaceContents(string contents, string etag, bool makeBackup, GFileCreateFlags flags, out string newEtag, Cancellable cancellable) 2947 { 2948 char* outnewEtag = null; 2949 GError* err = null; 2950 2951 auto p = g_file_replace_contents(getFileStruct(), Str.toStringz(contents), cast(size_t)contents.length, Str.toStringz(etag), makeBackup, flags, &outnewEtag, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 2952 2953 if (err !is null) 2954 { 2955 throw new GException( new ErrorG(err) ); 2956 } 2957 2958 newEtag = Str.toString(outnewEtag); 2959 2960 return p; 2961 } 2962 2963 /** 2964 * Starts an asynchronous replacement of @file with the given 2965 * @contents of @length bytes. @etag will replace the document's 2966 * current entity tag. 2967 * 2968 * When this operation has completed, @callback will be called with 2969 * @user_user data, and the operation can be finalized with 2970 * g_file_replace_contents_finish(). 2971 * 2972 * If @cancellable is not %NULL, then the operation can be cancelled by 2973 * triggering the cancellable object from another thread. If the operation 2974 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2975 * 2976 * If @make_backup is %TRUE, this function will attempt to 2977 * make a backup of @file. 2978 * 2979 * Note that no copy of @content will be made, so it must stay valid 2980 * until @callback is called. See g_file_replace_contents_bytes_async() 2981 * for a #GBytes version that will automatically hold a reference to the 2982 * contents (without copying) for the duration of the call. 2983 * 2984 * Params: 2985 * contents = string of contents to replace the file with 2986 * length = the length of @contents in bytes 2987 * etag = a new [entity tag][gfile-etag] for the @file, or %NULL 2988 * makeBackup = %TRUE if a backup should be created 2989 * flags = a set of #GFileCreateFlags 2990 * cancellable = optional #GCancellable object, %NULL to ignore 2991 * callback = a #GAsyncReadyCallback to call when the request is satisfied 2992 * userData = the data to pass to callback function 2993 */ 2994 public void replaceContentsAsync(string contents, string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2995 { 2996 g_file_replace_contents_async(getFileStruct(), Str.toStringz(contents), cast(size_t)contents.length, Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2997 } 2998 2999 /** 3000 * Same as g_file_replace_contents_async() but takes a #GBytes input instead. 3001 * This function will keep a ref on @contents until the operation is done. 3002 * Unlike g_file_replace_contents_async() this allows forgetting about the 3003 * content without waiting for the callback. 3004 * 3005 * When this operation has completed, @callback will be called with 3006 * @user_user data, and the operation can be finalized with 3007 * g_file_replace_contents_finish(). 3008 * 3009 * Params: 3010 * contents = a #GBytes 3011 * etag = a new [entity tag][gfile-etag] for the @file, or %NULL 3012 * makeBackup = %TRUE if a backup should be created 3013 * flags = a set of #GFileCreateFlags 3014 * cancellable = optional #GCancellable object, %NULL to ignore 3015 * callback = a #GAsyncReadyCallback to call when the request is satisfied 3016 * userData = the data to pass to callback function 3017 * 3018 * Since: 2.40 3019 */ 3020 public void replaceContentsBytesAsync(Bytes contents, string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3021 { 3022 g_file_replace_contents_bytes_async(getFileStruct(), (contents is null) ? null : contents.getBytesStruct(), Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3023 } 3024 3025 /** 3026 * Finishes an asynchronous replace of the given @file. See 3027 * g_file_replace_contents_async(). Sets @new_etag to the new entity 3028 * tag for the document, if present. 3029 * 3030 * Params: 3031 * res = a #GAsyncResult 3032 * newEtag = a location of a new [entity tag][gfile-etag] 3033 * for the document. This should be freed with g_free() when it is no 3034 * longer needed, or %NULL 3035 * 3036 * Returns: %TRUE on success, %FALSE on failure. 3037 * 3038 * Throws: GException on failure. 3039 */ 3040 public bool replaceContentsFinish(AsyncResultIF res, out string newEtag) 3041 { 3042 char* outnewEtag = null; 3043 GError* err = null; 3044 3045 auto p = g_file_replace_contents_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &outnewEtag, &err) != 0; 3046 3047 if (err !is null) 3048 { 3049 throw new GException( new ErrorG(err) ); 3050 } 3051 3052 newEtag = Str.toString(outnewEtag); 3053 3054 return p; 3055 } 3056 3057 /** 3058 * Finishes an asynchronous file replace operation started with 3059 * g_file_replace_async(). 3060 * 3061 * Params: 3062 * res = a #GAsyncResult 3063 * 3064 * Returns: a #GFileOutputStream, or %NULL on error. 3065 * Free the returned object with g_object_unref(). 3066 * 3067 * Throws: GException on failure. 3068 */ 3069 public FileOutputStream replaceFinish(AsyncResultIF res) 3070 { 3071 GError* err = null; 3072 3073 auto p = g_file_replace_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3074 3075 if (err !is null) 3076 { 3077 throw new GException( new ErrorG(err) ); 3078 } 3079 3080 if(p is null) 3081 { 3082 return null; 3083 } 3084 3085 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) p, true); 3086 } 3087 3088 /** 3089 * Returns an output stream for overwriting the file in readwrite mode, 3090 * possibly creating a backup copy of the file first. If the file doesn't 3091 * exist, it will be created. 3092 * 3093 * For details about the behaviour, see g_file_replace() which does the 3094 * same thing but returns an output stream only. 3095 * 3096 * Note that in many non-local file cases read and write streams are not 3097 * supported, so make sure you really need to do read and write streaming, 3098 * rather than just opening for reading or writing. 3099 * 3100 * Params: 3101 * etag = an optional [entity tag][gfile-etag] 3102 * for the current #GFile, or #NULL to ignore 3103 * makeBackup = %TRUE if a backup should be created 3104 * flags = a set of #GFileCreateFlags 3105 * cancellable = optional #GCancellable object, 3106 * %NULL to ignore 3107 * 3108 * Returns: a #GFileIOStream or %NULL on error. 3109 * Free the returned object with g_object_unref(). 3110 * 3111 * Since: 2.22 3112 * 3113 * Throws: GException on failure. 3114 */ 3115 public FileIOStream replaceReadwrite(string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable) 3116 { 3117 GError* err = null; 3118 3119 auto p = g_file_replace_readwrite(getFileStruct(), Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 3120 3121 if (err !is null) 3122 { 3123 throw new GException( new ErrorG(err) ); 3124 } 3125 3126 if(p is null) 3127 { 3128 return null; 3129 } 3130 3131 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 3132 } 3133 3134 /** 3135 * Asynchronously overwrites the file in read-write mode, 3136 * replacing the contents, possibly creating a backup copy 3137 * of the file first. 3138 * 3139 * For more details, see g_file_replace_readwrite() which is 3140 * the synchronous version of this call. 3141 * 3142 * When the operation is finished, @callback will be called. 3143 * You can then call g_file_replace_readwrite_finish() to get 3144 * the result of the operation. 3145 * 3146 * Params: 3147 * etag = an [entity tag][gfile-etag] for the current #GFile, 3148 * or %NULL to ignore 3149 * makeBackup = %TRUE if a backup should be created 3150 * flags = a set of #GFileCreateFlags 3151 * ioPriority = the [I/O priority][io-priority] of the request 3152 * cancellable = optional #GCancellable object, 3153 * %NULL to ignore 3154 * callback = a #GAsyncReadyCallback to call 3155 * when the request is satisfied 3156 * userData = the data to pass to callback function 3157 * 3158 * Since: 2.22 3159 */ 3160 public void replaceReadwriteAsync(string etag, bool makeBackup, GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3161 { 3162 g_file_replace_readwrite_async(getFileStruct(), Str.toStringz(etag), makeBackup, flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3163 } 3164 3165 /** 3166 * Finishes an asynchronous file replace operation started with 3167 * g_file_replace_readwrite_async(). 3168 * 3169 * Params: 3170 * res = a #GAsyncResult 3171 * 3172 * Returns: a #GFileIOStream, or %NULL on error. 3173 * Free the returned object with g_object_unref(). 3174 * 3175 * Since: 2.22 3176 * 3177 * Throws: GException on failure. 3178 */ 3179 public FileIOStream replaceReadwriteFinish(AsyncResultIF res) 3180 { 3181 GError* err = null; 3182 3183 auto p = g_file_replace_readwrite_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3184 3185 if (err !is null) 3186 { 3187 throw new GException( new ErrorG(err) ); 3188 } 3189 3190 if(p is null) 3191 { 3192 return null; 3193 } 3194 3195 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 3196 } 3197 3198 /** 3199 * Resolves a relative path for @file to an absolute path. 3200 * 3201 * This call does no blocking I/O. 3202 * 3203 * Params: 3204 * relativePath = a given relative path string 3205 * 3206 * Returns: #GFile to the resolved path. 3207 * %NULL if @relative_path is %NULL or if @file is invalid. 3208 * Free the returned object with g_object_unref(). 3209 */ 3210 public FileIF resolveRelativePath(string relativePath) 3211 { 3212 auto p = g_file_resolve_relative_path(getFileStruct(), Str.toStringz(relativePath)); 3213 3214 if(p is null) 3215 { 3216 return null; 3217 } 3218 3219 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 3220 } 3221 3222 /** 3223 * Sets an attribute in the file with attribute name @attribute to @value. 3224 * 3225 * Some attributes can be unset by setting @attribute to 3226 * %G_FILE_ATTRIBUTE_TYPE_INVALID and @value_p to %NULL. 3227 * 3228 * If @cancellable is not %NULL, then the operation can be cancelled by 3229 * triggering the cancellable object from another thread. If the operation 3230 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3231 * 3232 * Params: 3233 * attribute = a string containing the attribute's name 3234 * type = The type of the attribute 3235 * valueP = a pointer to the value (or the pointer 3236 * itself if the type is a pointer type) 3237 * flags = a set of #GFileQueryInfoFlags 3238 * cancellable = optional #GCancellable object, 3239 * %NULL to ignore 3240 * 3241 * Returns: %TRUE if the attribute was set, %FALSE otherwise. 3242 * 3243 * Throws: GException on failure. 3244 */ 3245 public bool setAttribute(string attribute, GFileAttributeType type, void* valueP, GFileQueryInfoFlags flags, Cancellable cancellable) 3246 { 3247 GError* err = null; 3248 3249 auto p = g_file_set_attribute(getFileStruct(), Str.toStringz(attribute), type, valueP, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3250 3251 if (err !is null) 3252 { 3253 throw new GException( new ErrorG(err) ); 3254 } 3255 3256 return p; 3257 } 3258 3259 /** 3260 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to @value. 3261 * If @attribute is of a different type, this operation will fail, 3262 * returning %FALSE. 3263 * 3264 * If @cancellable is not %NULL, then the operation can be cancelled by 3265 * triggering the cancellable object from another thread. If the operation 3266 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3267 * 3268 * Params: 3269 * attribute = a string containing the attribute's name 3270 * value = a string containing the attribute's new value 3271 * flags = a #GFileQueryInfoFlags 3272 * cancellable = optional #GCancellable object, 3273 * %NULL to ignore 3274 * 3275 * Returns: %TRUE if the @attribute was successfully set to @value 3276 * in the @file, %FALSE otherwise. 3277 * 3278 * Throws: GException on failure. 3279 */ 3280 public bool setAttributeByteString(string attribute, string value, GFileQueryInfoFlags flags, Cancellable cancellable) 3281 { 3282 GError* err = null; 3283 3284 auto p = g_file_set_attribute_byte_string(getFileStruct(), Str.toStringz(attribute), Str.toStringz(value), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3285 3286 if (err !is null) 3287 { 3288 throw new GException( new ErrorG(err) ); 3289 } 3290 3291 return p; 3292 } 3293 3294 /** 3295 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT32 to @value. 3296 * If @attribute is of a different type, this operation will fail. 3297 * 3298 * If @cancellable is not %NULL, then the operation can be cancelled by 3299 * triggering the cancellable object from another thread. If the operation 3300 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3301 * 3302 * Params: 3303 * attribute = a string containing the attribute's name 3304 * value = a #gint32 containing the attribute's new value 3305 * flags = a #GFileQueryInfoFlags 3306 * cancellable = optional #GCancellable object, 3307 * %NULL to ignore 3308 * 3309 * Returns: %TRUE if the @attribute was successfully set to @value 3310 * in the @file, %FALSE otherwise. 3311 * 3312 * Throws: GException on failure. 3313 */ 3314 public bool setAttributeInt32(string attribute, int value, GFileQueryInfoFlags flags, Cancellable cancellable) 3315 { 3316 GError* err = null; 3317 3318 auto p = g_file_set_attribute_int32(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3319 3320 if (err !is null) 3321 { 3322 throw new GException( new ErrorG(err) ); 3323 } 3324 3325 return p; 3326 } 3327 3328 /** 3329 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT64 to @value. 3330 * If @attribute is of a different type, this operation will fail. 3331 * 3332 * If @cancellable is not %NULL, then the operation can be cancelled by 3333 * triggering the cancellable object from another thread. If the operation 3334 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3335 * 3336 * Params: 3337 * attribute = a string containing the attribute's name 3338 * value = a #guint64 containing the attribute's new value 3339 * flags = a #GFileQueryInfoFlags 3340 * cancellable = optional #GCancellable object, 3341 * %NULL to ignore 3342 * 3343 * Returns: %TRUE if the @attribute was successfully set, %FALSE otherwise. 3344 * 3345 * Throws: GException on failure. 3346 */ 3347 public bool setAttributeInt64(string attribute, long value, GFileQueryInfoFlags flags, Cancellable cancellable) 3348 { 3349 GError* err = null; 3350 3351 auto p = g_file_set_attribute_int64(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3352 3353 if (err !is null) 3354 { 3355 throw new GException( new ErrorG(err) ); 3356 } 3357 3358 return p; 3359 } 3360 3361 /** 3362 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_STRING to @value. 3363 * If @attribute is of a different type, this operation will fail. 3364 * 3365 * If @cancellable is not %NULL, then the operation can be cancelled by 3366 * triggering the cancellable object from another thread. If the operation 3367 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3368 * 3369 * Params: 3370 * attribute = a string containing the attribute's name 3371 * value = a string containing the attribute's value 3372 * flags = #GFileQueryInfoFlags 3373 * cancellable = optional #GCancellable object, 3374 * %NULL to ignore 3375 * 3376 * Returns: %TRUE if the @attribute was successfully set, %FALSE otherwise. 3377 * 3378 * Throws: GException on failure. 3379 */ 3380 public bool setAttributeString(string attribute, string value, GFileQueryInfoFlags flags, Cancellable cancellable) 3381 { 3382 GError* err = null; 3383 3384 auto p = g_file_set_attribute_string(getFileStruct(), Str.toStringz(attribute), Str.toStringz(value), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3385 3386 if (err !is null) 3387 { 3388 throw new GException( new ErrorG(err) ); 3389 } 3390 3391 return p; 3392 } 3393 3394 /** 3395 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT32 to @value. 3396 * If @attribute is of a different type, this operation will fail. 3397 * 3398 * If @cancellable is not %NULL, then the operation can be cancelled by 3399 * triggering the cancellable object from another thread. If the operation 3400 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3401 * 3402 * Params: 3403 * attribute = a string containing the attribute's name 3404 * value = a #guint32 containing the attribute's new value 3405 * flags = a #GFileQueryInfoFlags 3406 * cancellable = optional #GCancellable object, 3407 * %NULL to ignore 3408 * 3409 * Returns: %TRUE if the @attribute was successfully set to @value 3410 * in the @file, %FALSE otherwise. 3411 * 3412 * Throws: GException on failure. 3413 */ 3414 public bool setAttributeUint32(string attribute, uint value, GFileQueryInfoFlags flags, Cancellable cancellable) 3415 { 3416 GError* err = null; 3417 3418 auto p = g_file_set_attribute_uint32(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3419 3420 if (err !is null) 3421 { 3422 throw new GException( new ErrorG(err) ); 3423 } 3424 3425 return p; 3426 } 3427 3428 /** 3429 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT64 to @value. 3430 * If @attribute is of a different type, this operation will fail. 3431 * 3432 * If @cancellable is not %NULL, then the operation can be cancelled by 3433 * triggering the cancellable object from another thread. If the operation 3434 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3435 * 3436 * Params: 3437 * attribute = a string containing the attribute's name 3438 * value = a #guint64 containing the attribute's new value 3439 * flags = a #GFileQueryInfoFlags 3440 * cancellable = optional #GCancellable object, 3441 * %NULL to ignore 3442 * 3443 * Returns: %TRUE if the @attribute was successfully set to @value 3444 * in the @file, %FALSE otherwise. 3445 * 3446 * Throws: GException on failure. 3447 */ 3448 public bool setAttributeUint64(string attribute, ulong value, GFileQueryInfoFlags flags, Cancellable cancellable) 3449 { 3450 GError* err = null; 3451 3452 auto p = g_file_set_attribute_uint64(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3453 3454 if (err !is null) 3455 { 3456 throw new GException( new ErrorG(err) ); 3457 } 3458 3459 return p; 3460 } 3461 3462 /** 3463 * Asynchronously sets the attributes of @file with @info. 3464 * 3465 * For more details, see g_file_set_attributes_from_info(), 3466 * which is the synchronous version of this call. 3467 * 3468 * When the operation is finished, @callback will be called. 3469 * You can then call g_file_set_attributes_finish() to get 3470 * the result of the operation. 3471 * 3472 * Params: 3473 * info = a #GFileInfo 3474 * flags = a #GFileQueryInfoFlags 3475 * ioPriority = the [I/O priority][io-priority] of the request 3476 * cancellable = optional #GCancellable object, 3477 * %NULL to ignore 3478 * callback = a #GAsyncReadyCallback 3479 * userData = a #gpointer 3480 */ 3481 public void setAttributesAsync(FileInfo info, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3482 { 3483 g_file_set_attributes_async(getFileStruct(), (info is null) ? null : info.getFileInfoStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3484 } 3485 3486 /** 3487 * Finishes setting an attribute started in g_file_set_attributes_async(). 3488 * 3489 * Params: 3490 * result = a #GAsyncResult 3491 * info = a #GFileInfo 3492 * 3493 * Returns: %TRUE if the attributes were set correctly, %FALSE otherwise. 3494 * 3495 * Throws: GException on failure. 3496 */ 3497 public bool setAttributesFinish(AsyncResultIF result, out FileInfo info) 3498 { 3499 GFileInfo* outinfo = null; 3500 GError* err = null; 3501 3502 auto p = g_file_set_attributes_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &outinfo, &err) != 0; 3503 3504 if (err !is null) 3505 { 3506 throw new GException( new ErrorG(err) ); 3507 } 3508 3509 info = ObjectG.getDObject!(FileInfo)(outinfo); 3510 3511 return p; 3512 } 3513 3514 /** 3515 * Tries to set all attributes in the #GFileInfo on the target 3516 * values, not stopping on the first error. 3517 * 3518 * If there is any error during this operation then @error will 3519 * be set to the first error. Error on particular fields are flagged 3520 * by setting the "status" field in the attribute value to 3521 * %G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING, which means you can 3522 * also detect further errors. 3523 * 3524 * If @cancellable is not %NULL, then the operation can be cancelled by 3525 * triggering the cancellable object from another thread. If the operation 3526 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3527 * 3528 * Params: 3529 * info = a #GFileInfo 3530 * flags = #GFileQueryInfoFlags 3531 * cancellable = optional #GCancellable object, 3532 * %NULL to ignore 3533 * 3534 * Returns: %FALSE if there was any error, %TRUE otherwise. 3535 * 3536 * Throws: GException on failure. 3537 */ 3538 public bool setAttributesFromInfo(FileInfo info, GFileQueryInfoFlags flags, Cancellable cancellable) 3539 { 3540 GError* err = null; 3541 3542 auto p = g_file_set_attributes_from_info(getFileStruct(), (info is null) ? null : info.getFileInfoStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3543 3544 if (err !is null) 3545 { 3546 throw new GException( new ErrorG(err) ); 3547 } 3548 3549 return p; 3550 } 3551 3552 /** 3553 * Renames @file to the specified display name. 3554 * 3555 * The display name is converted from UTF-8 to the correct encoding 3556 * for the target filesystem if possible and the @file is renamed to this. 3557 * 3558 * If you want to implement a rename operation in the user interface the 3559 * edit name (#G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) should be used as the 3560 * initial value in the rename widget, and then the result after editing 3561 * should be passed to g_file_set_display_name(). 3562 * 3563 * On success the resulting converted filename is returned. 3564 * 3565 * If @cancellable is not %NULL, then the operation can be cancelled by 3566 * triggering the cancellable object from another thread. If the operation 3567 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3568 * 3569 * Params: 3570 * displayName = a string 3571 * cancellable = optional #GCancellable object, 3572 * %NULL to ignore 3573 * 3574 * Returns: a #GFile specifying what @file was renamed to, 3575 * or %NULL if there was an error. 3576 * Free the returned object with g_object_unref(). 3577 * 3578 * Throws: GException on failure. 3579 */ 3580 public FileIF setDisplayName(string displayName, Cancellable cancellable) 3581 { 3582 GError* err = null; 3583 3584 auto p = g_file_set_display_name(getFileStruct(), Str.toStringz(displayName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 3585 3586 if (err !is null) 3587 { 3588 throw new GException( new ErrorG(err) ); 3589 } 3590 3591 if(p is null) 3592 { 3593 return null; 3594 } 3595 3596 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 3597 } 3598 3599 /** 3600 * Asynchronously sets the display name for a given #GFile. 3601 * 3602 * For more details, see g_file_set_display_name() which is 3603 * the synchronous version of this call. 3604 * 3605 * When the operation is finished, @callback will be called. 3606 * You can then call g_file_set_display_name_finish() to get 3607 * the result of the operation. 3608 * 3609 * Params: 3610 * displayName = a string 3611 * ioPriority = the [I/O priority][io-priority] of the request 3612 * cancellable = optional #GCancellable object, 3613 * %NULL to ignore 3614 * callback = a #GAsyncReadyCallback to call 3615 * when the request is satisfied 3616 * userData = the data to pass to callback function 3617 */ 3618 public void setDisplayNameAsync(string displayName, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3619 { 3620 g_file_set_display_name_async(getFileStruct(), Str.toStringz(displayName), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3621 } 3622 3623 /** 3624 * Finishes setting a display name started with 3625 * g_file_set_display_name_async(). 3626 * 3627 * Params: 3628 * res = a #GAsyncResult 3629 * 3630 * Returns: a #GFile or %NULL on error. 3631 * Free the returned object with g_object_unref(). 3632 * 3633 * Throws: GException on failure. 3634 */ 3635 public FileIF setDisplayNameFinish(AsyncResultIF res) 3636 { 3637 GError* err = null; 3638 3639 auto p = g_file_set_display_name_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3640 3641 if (err !is null) 3642 { 3643 throw new GException( new ErrorG(err) ); 3644 } 3645 3646 if(p is null) 3647 { 3648 return null; 3649 } 3650 3651 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 3652 } 3653 3654 /** 3655 * Starts a file of type #G_FILE_TYPE_MOUNTABLE. 3656 * Using @start_operation, you can request callbacks when, for instance, 3657 * passwords are needed during authentication. 3658 * 3659 * If @cancellable is not %NULL, then the operation can be cancelled by 3660 * triggering the cancellable object from another thread. If the operation 3661 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3662 * 3663 * When the operation is finished, @callback will be called. 3664 * You can then call g_file_mount_mountable_finish() to get 3665 * the result of the operation. 3666 * 3667 * Params: 3668 * flags = flags affecting the operation 3669 * startOperation = a #GMountOperation, or %NULL to avoid user interaction 3670 * cancellable = optional #GCancellable object, %NULL to ignore 3671 * callback = a #GAsyncReadyCallback to call when the request is satisfied, or %NULL 3672 * userData = the data to pass to callback function 3673 * 3674 * Since: 2.22 3675 */ 3676 public void startMountable(GDriveStartFlags flags, MountOperation startOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3677 { 3678 g_file_start_mountable(getFileStruct(), flags, (startOperation is null) ? null : startOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3679 } 3680 3681 /** 3682 * Finishes a start operation. See g_file_start_mountable() for details. 3683 * 3684 * Finish an asynchronous start operation that was started 3685 * with g_file_start_mountable(). 3686 * 3687 * Params: 3688 * result = a #GAsyncResult 3689 * 3690 * Returns: %TRUE if the operation finished successfully. %FALSE 3691 * otherwise. 3692 * 3693 * Since: 2.22 3694 * 3695 * Throws: GException on failure. 3696 */ 3697 public bool startMountableFinish(AsyncResultIF result) 3698 { 3699 GError* err = null; 3700 3701 auto p = g_file_start_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3702 3703 if (err !is null) 3704 { 3705 throw new GException( new ErrorG(err) ); 3706 } 3707 3708 return p; 3709 } 3710 3711 /** 3712 * Stops a file of type #G_FILE_TYPE_MOUNTABLE. 3713 * 3714 * If @cancellable is not %NULL, then the operation can be cancelled by 3715 * triggering the cancellable object from another thread. If the operation 3716 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3717 * 3718 * When the operation is finished, @callback will be called. 3719 * You can then call g_file_stop_mountable_finish() to get 3720 * the result of the operation. 3721 * 3722 * Params: 3723 * flags = flags affecting the operation 3724 * mountOperation = a #GMountOperation, 3725 * or %NULL to avoid user interaction. 3726 * cancellable = optional #GCancellable object, 3727 * %NULL to ignore 3728 * callback = a #GAsyncReadyCallback to call 3729 * when the request is satisfied, or %NULL 3730 * userData = the data to pass to callback function 3731 * 3732 * Since: 2.22 3733 */ 3734 public void stopMountable(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3735 { 3736 g_file_stop_mountable(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3737 } 3738 3739 /** 3740 * Finishes an stop operation, see g_file_stop_mountable() for details. 3741 * 3742 * Finish an asynchronous stop operation that was started 3743 * with g_file_stop_mountable(). 3744 * 3745 * Params: 3746 * result = a #GAsyncResult 3747 * 3748 * Returns: %TRUE if the operation finished successfully. 3749 * %FALSE otherwise. 3750 * 3751 * Since: 2.22 3752 * 3753 * Throws: GException on failure. 3754 */ 3755 public bool stopMountableFinish(AsyncResultIF result) 3756 { 3757 GError* err = null; 3758 3759 auto p = g_file_stop_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3760 3761 if (err !is null) 3762 { 3763 throw new GException( new ErrorG(err) ); 3764 } 3765 3766 return p; 3767 } 3768 3769 /** 3770 * Checks if @file supports 3771 * [thread-default contexts][g-main-context-push-thread-default-context]. 3772 * If this returns %FALSE, you cannot perform asynchronous operations on 3773 * @file in a thread that has a thread-default context. 3774 * 3775 * Returns: Whether or not @file supports thread-default contexts. 3776 * 3777 * Since: 2.22 3778 */ 3779 public bool supportsThreadContexts() 3780 { 3781 return g_file_supports_thread_contexts(getFileStruct()) != 0; 3782 } 3783 3784 /** 3785 * Sends @file to the "Trashcan", if possible. This is similar to 3786 * deleting it, but the user can recover it before emptying the trashcan. 3787 * Not all file systems support trashing, so this call can return the 3788 * %G_IO_ERROR_NOT_SUPPORTED error. 3789 * 3790 * If @cancellable is not %NULL, then the operation can be cancelled by 3791 * triggering the cancellable object from another thread. If the operation 3792 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3793 * 3794 * Params: 3795 * cancellable = optional #GCancellable object, 3796 * %NULL to ignore 3797 * 3798 * Returns: %TRUE on successful trash, %FALSE otherwise. 3799 * 3800 * Throws: GException on failure. 3801 */ 3802 public bool trash(Cancellable cancellable) 3803 { 3804 GError* err = null; 3805 3806 auto p = g_file_trash(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3807 3808 if (err !is null) 3809 { 3810 throw new GException( new ErrorG(err) ); 3811 } 3812 3813 return p; 3814 } 3815 3816 /** 3817 * Asynchronously sends @file to the Trash location, if possible. 3818 * 3819 * Params: 3820 * ioPriority = the [I/O priority][io-priority] of the request 3821 * cancellable = optional #GCancellable object, 3822 * %NULL to ignore 3823 * callback = a #GAsyncReadyCallback to call 3824 * when the request is satisfied 3825 * userData = the data to pass to callback function 3826 * 3827 * Since: 2.38 3828 */ 3829 public void trashAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3830 { 3831 g_file_trash_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3832 } 3833 3834 /** 3835 * Finishes an asynchronous file trashing operation, started with 3836 * g_file_trash_async(). 3837 * 3838 * Params: 3839 * result = a #GAsyncResult 3840 * 3841 * Returns: %TRUE on successful trash, %FALSE otherwise. 3842 * 3843 * Since: 2.38 3844 * 3845 * Throws: GException on failure. 3846 */ 3847 public bool trashFinish(AsyncResultIF result) 3848 { 3849 GError* err = null; 3850 3851 auto p = g_file_trash_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3852 3853 if (err !is null) 3854 { 3855 throw new GException( new ErrorG(err) ); 3856 } 3857 3858 return p; 3859 } 3860 3861 /** 3862 * Unmounts a file of type G_FILE_TYPE_MOUNTABLE. 3863 * 3864 * If @cancellable is not %NULL, then the operation can be cancelled by 3865 * triggering the cancellable object from another thread. If the operation 3866 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3867 * 3868 * When the operation is finished, @callback will be called. 3869 * You can then call g_file_unmount_mountable_finish() to get 3870 * the result of the operation. 3871 * 3872 * Deprecated: Use g_file_unmount_mountable_with_operation() instead. 3873 * 3874 * Params: 3875 * flags = flags affecting the operation 3876 * cancellable = optional #GCancellable object, 3877 * %NULL to ignore 3878 * callback = a #GAsyncReadyCallback to call 3879 * when the request is satisfied, or %NULL 3880 * userData = the data to pass to callback function 3881 */ 3882 public void unmountMountable(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3883 { 3884 g_file_unmount_mountable(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3885 } 3886 3887 /** 3888 * Finishes an unmount operation, see g_file_unmount_mountable() for details. 3889 * 3890 * Finish an asynchronous unmount operation that was started 3891 * with g_file_unmount_mountable(). 3892 * 3893 * Deprecated: Use g_file_unmount_mountable_with_operation_finish() 3894 * instead. 3895 * 3896 * Params: 3897 * result = a #GAsyncResult 3898 * 3899 * Returns: %TRUE if the operation finished successfully. 3900 * %FALSE otherwise. 3901 * 3902 * Throws: GException on failure. 3903 */ 3904 public bool unmountMountableFinish(AsyncResultIF result) 3905 { 3906 GError* err = null; 3907 3908 auto p = g_file_unmount_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3909 3910 if (err !is null) 3911 { 3912 throw new GException( new ErrorG(err) ); 3913 } 3914 3915 return p; 3916 } 3917 3918 /** 3919 * Unmounts a file of type #G_FILE_TYPE_MOUNTABLE. 3920 * 3921 * If @cancellable is not %NULL, then the operation can be cancelled by 3922 * triggering the cancellable object from another thread. If the operation 3923 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3924 * 3925 * When the operation is finished, @callback will be called. 3926 * You can then call g_file_unmount_mountable_finish() to get 3927 * the result of the operation. 3928 * 3929 * Params: 3930 * flags = flags affecting the operation 3931 * mountOperation = a #GMountOperation, 3932 * or %NULL to avoid user interaction 3933 * cancellable = optional #GCancellable object, 3934 * %NULL to ignore 3935 * callback = a #GAsyncReadyCallback to call 3936 * when the request is satisfied, or %NULL 3937 * userData = the data to pass to callback function 3938 * 3939 * Since: 2.22 3940 */ 3941 public void unmountMountableWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3942 { 3943 g_file_unmount_mountable_with_operation(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3944 } 3945 3946 /** 3947 * Finishes an unmount operation, 3948 * see g_file_unmount_mountable_with_operation() for details. 3949 * 3950 * Finish an asynchronous unmount operation that was started 3951 * with g_file_unmount_mountable_with_operation(). 3952 * 3953 * Params: 3954 * result = a #GAsyncResult 3955 * 3956 * Returns: %TRUE if the operation finished successfully. 3957 * %FALSE otherwise. 3958 * 3959 * Since: 2.22 3960 * 3961 * Throws: GException on failure. 3962 */ 3963 public bool unmountMountableWithOperationFinish(AsyncResultIF result) 3964 { 3965 GError* err = null; 3966 3967 auto p = g_file_unmount_mountable_with_operation_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3968 3969 if (err !is null) 3970 { 3971 throw new GException( new ErrorG(err) ); 3972 } 3973 3974 return p; 3975 } 3976 }