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