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