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 base name, or 1098 * %NULL if given #GFile is invalid. The returned string should be 1099 * 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, or %NULL 1232 * 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 @descendant 1252 * 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 of the new symlink 1708 * cancellable = optional #GCancellable object, 1709 * %NULL to ignore 1710 * 1711 * Return: %TRUE on the creation of a new symlink, %FALSE otherwise. 1712 * 1713 * Throws: GException on failure. 1714 */ 1715 public bool makeSymbolicLink(string symlinkValue, Cancellable cancellable) 1716 { 1717 GError* err = null; 1718 1719 auto p = g_file_make_symbolic_link(getFileStruct(), Str.toStringz(symlinkValue), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1720 1721 if (err !is null) 1722 { 1723 throw new GException( new ErrorG(err) ); 1724 } 1725 1726 return p; 1727 } 1728 1729 /** 1730 * Recursively measures the disk usage of @file. 1731 * 1732 * This is essentially an analog of the 'du' command, but it also 1733 * reports the number of directories and non-directory files encountered 1734 * (including things like symbolic links). 1735 * 1736 * By default, errors are only reported against the toplevel file 1737 * itself. Errors found while recursing are silently ignored, unless 1738 * %G_FILE_DISK_USAGE_REPORT_ALL_ERRORS is given in @flags. 1739 * 1740 * The returned size, @disk_usage, is in bytes and should be formatted 1741 * with g_format_size() in order to get something reasonable for showing 1742 * in a user interface. 1743 * 1744 * @progress_callback and @progress_data can be given to request 1745 * periodic progress updates while scanning. See the documentation for 1746 * #GFileMeasureProgressCallback for information about when and how the 1747 * callback will be invoked. 1748 * 1749 * Params: 1750 * flags = #GFileMeasureFlags 1751 * cancellable = optional #GCancellable 1752 * progressCallback = a #GFileMeasureProgressCallback 1753 * progressData = user_data for @progress_callback 1754 * diskUsage = the number of bytes of disk space used 1755 * numDirs = the number of directories encountered 1756 * numFiles = the number of non-directories encountered 1757 * 1758 * Return: %TRUE if successful, with the out parameters set. 1759 * %FALSE otherwise, with @error set. 1760 * 1761 * Since: 2.38 1762 * 1763 * Throws: GException on failure. 1764 */ 1765 public bool measureDiskUsage(GFileMeasureFlags flags, Cancellable cancellable, GFileMeasureProgressCallback progressCallback, void* progressData, out ulong diskUsage, out ulong numDirs, out ulong numFiles) 1766 { 1767 GError* err = null; 1768 1769 auto p = g_file_measure_disk_usage(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressData, &diskUsage, &numDirs, &numFiles, &err) != 0; 1770 1771 if (err !is null) 1772 { 1773 throw new GException( new ErrorG(err) ); 1774 } 1775 1776 return p; 1777 } 1778 1779 /** 1780 * Recursively measures the disk usage of @file. 1781 * 1782 * This is the asynchronous version of g_file_measure_disk_usage(). See 1783 * there for more information. 1784 * 1785 * Params: 1786 * flags = #GFileMeasureFlags 1787 * ioPriority = the [I/O priority][io-priority] of the request 1788 * cancellable = optional #GCancellable 1789 * progressCallback = a #GFileMeasureProgressCallback 1790 * progressData = user_data for @progress_callback 1791 * callback = a #GAsyncReadyCallback to call when complete 1792 * userData = the data to pass to callback function 1793 * 1794 * Since: 2.38 1795 */ 1796 public void measureDiskUsageAsync(GFileMeasureFlags flags, int ioPriority, Cancellable cancellable, GFileMeasureProgressCallback progressCallback, void* progressData, GAsyncReadyCallback callback, void* userData) 1797 { 1798 g_file_measure_disk_usage_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressData, callback, userData); 1799 } 1800 1801 /** 1802 * Collects the results from an earlier call to 1803 * g_file_measure_disk_usage_async(). See g_file_measure_disk_usage() for 1804 * more information. 1805 * 1806 * Params: 1807 * result = the #GAsyncResult passed to your #GAsyncReadyCallback 1808 * diskUsage = the number of bytes of disk space used 1809 * numDirs = the number of directories encountered 1810 * numFiles = the number of non-directories encountered 1811 * 1812 * Return: %TRUE if successful, with the out parameters set. 1813 * %FALSE otherwise, with @error set. 1814 * 1815 * Since: 2.38 1816 * 1817 * Throws: GException on failure. 1818 */ 1819 public bool measureDiskUsageFinish(AsyncResultIF result, out ulong diskUsage, out ulong numDirs, out ulong numFiles) 1820 { 1821 GError* err = null; 1822 1823 auto p = g_file_measure_disk_usage_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &diskUsage, &numDirs, &numFiles, &err) != 0; 1824 1825 if (err !is null) 1826 { 1827 throw new GException( new ErrorG(err) ); 1828 } 1829 1830 return p; 1831 } 1832 1833 /** 1834 * Obtains a file or directory monitor for the given file, 1835 * depending on the type of the file. 1836 * 1837 * If @cancellable is not %NULL, then the operation can be cancelled by 1838 * triggering the cancellable object from another thread. If the operation 1839 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1840 * 1841 * Params: 1842 * flags = a set of #GFileMonitorFlags 1843 * cancellable = optional #GCancellable object, 1844 * %NULL to ignore 1845 * 1846 * Return: a #GFileMonitor for the given @file, 1847 * or %NULL on error. 1848 * Free the returned object with g_object_unref(). 1849 * 1850 * Since: 2.18 1851 * 1852 * Throws: GException on failure. 1853 */ 1854 public FileMonitor monitor(GFileMonitorFlags flags, Cancellable cancellable) 1855 { 1856 GError* err = null; 1857 1858 auto p = g_file_monitor(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1859 1860 if (err !is null) 1861 { 1862 throw new GException( new ErrorG(err) ); 1863 } 1864 1865 if(p is null) 1866 { 1867 return null; 1868 } 1869 1870 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) p, true); 1871 } 1872 1873 /** 1874 * Obtains a directory monitor for the given file. 1875 * This may fail if directory monitoring is not supported. 1876 * 1877 * If @cancellable is not %NULL, then the operation can be cancelled by 1878 * triggering the cancellable object from another thread. If the operation 1879 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1880 * 1881 * It does not make sense for @flags to contain 1882 * %G_FILE_MONITOR_WATCH_HARD_LINKS, since hard links can not be made to 1883 * directories. It is not possible to monitor all the files in a 1884 * directory for changes made via hard links; if you want to do this then 1885 * you must register individual watches with g_file_monitor(). 1886 * 1887 * Params: 1888 * flags = a set of #GFileMonitorFlags 1889 * cancellable = optional #GCancellable object, 1890 * %NULL to ignore 1891 * 1892 * Return: a #GFileMonitor for the given @file, 1893 * or %NULL on error. 1894 * Free the returned object with g_object_unref(). 1895 * 1896 * Throws: GException on failure. 1897 */ 1898 public FileMonitor monitorDirectory(GFileMonitorFlags flags, Cancellable cancellable) 1899 { 1900 GError* err = null; 1901 1902 auto p = g_file_monitor_directory(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1903 1904 if (err !is null) 1905 { 1906 throw new GException( new ErrorG(err) ); 1907 } 1908 1909 if(p is null) 1910 { 1911 return null; 1912 } 1913 1914 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) p, true); 1915 } 1916 1917 /** 1918 * Obtains a file monitor for the given file. If no file notification 1919 * mechanism exists, then regular polling of the file is used. 1920 * 1921 * If @cancellable is not %NULL, then the operation can be cancelled by 1922 * triggering the cancellable object from another thread. If the operation 1923 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1924 * 1925 * If @flags contains %G_FILE_MONITOR_WATCH_HARD_LINKS then the monitor 1926 * will also attempt to report changes made to the file via another 1927 * filename (ie, a hard link). Without this flag, you can only rely on 1928 * changes made through the filename contained in @file to be 1929 * reported. Using this flag may result in an increase in resource 1930 * usage, and may not have any effect depending on the #GFileMonitor 1931 * backend and/or filesystem type. 1932 * 1933 * Params: 1934 * flags = a set of #GFileMonitorFlags 1935 * cancellable = optional #GCancellable object, 1936 * %NULL to ignore 1937 * 1938 * Return: a #GFileMonitor for the given @file, 1939 * or %NULL on error. 1940 * Free the returned object with g_object_unref(). 1941 * 1942 * Throws: GException on failure. 1943 */ 1944 public FileMonitor monitorFile(GFileMonitorFlags flags, Cancellable cancellable) 1945 { 1946 GError* err = null; 1947 1948 auto p = g_file_monitor_file(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1949 1950 if (err !is null) 1951 { 1952 throw new GException( new ErrorG(err) ); 1953 } 1954 1955 if(p is null) 1956 { 1957 return null; 1958 } 1959 1960 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) p, true); 1961 } 1962 1963 /** 1964 * Starts a @mount_operation, mounting the volume that contains 1965 * the file @location. 1966 * 1967 * When this operation has completed, @callback will be called with 1968 * @user_user data, and the operation can be finalized with 1969 * g_file_mount_enclosing_volume_finish(). 1970 * 1971 * If @cancellable is not %NULL, then the operation can be cancelled by 1972 * triggering the cancellable object from another thread. If the operation 1973 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1974 * 1975 * Params: 1976 * flags = flags affecting the operation 1977 * mountOperation = a #GMountOperation 1978 * or %NULL to avoid user interaction 1979 * cancellable = optional #GCancellable object, 1980 * %NULL to ignore 1981 * callback = a #GAsyncReadyCallback to call 1982 * when the request is satisfied, or %NULL 1983 * userData = the data to pass to callback function 1984 */ 1985 public void mountEnclosingVolume(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1986 { 1987 g_file_mount_enclosing_volume(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1988 } 1989 1990 /** 1991 * Finishes a mount operation started by g_file_mount_enclosing_volume(). 1992 * 1993 * Params: 1994 * result = a #GAsyncResult 1995 * 1996 * Return: %TRUE if successful. If an error has occurred, 1997 * this function will return %FALSE and set @error 1998 * appropriately if present. 1999 * 2000 * Throws: GException on failure. 2001 */ 2002 public bool mountEnclosingVolumeFinish(AsyncResultIF result) 2003 { 2004 GError* err = null; 2005 2006 auto p = g_file_mount_enclosing_volume_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2007 2008 if (err !is null) 2009 { 2010 throw new GException( new ErrorG(err) ); 2011 } 2012 2013 return p; 2014 } 2015 2016 /** 2017 * Mounts a file of type G_FILE_TYPE_MOUNTABLE. 2018 * Using @mount_operation, you can request callbacks when, for instance, 2019 * passwords are needed during authentication. 2020 * 2021 * If @cancellable is not %NULL, then the operation can be cancelled by 2022 * triggering the cancellable object from another thread. If the operation 2023 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2024 * 2025 * When the operation is finished, @callback will be called. 2026 * You can then call g_file_mount_mountable_finish() to get 2027 * the result of the operation. 2028 * 2029 * Params: 2030 * flags = flags affecting the operation 2031 * mountOperation = a #GMountOperation, 2032 * or %NULL to avoid user interaction 2033 * cancellable = optional #GCancellable object, 2034 * %NULL to ignore 2035 * callback = a #GAsyncReadyCallback to call 2036 * when the request is satisfied, or %NULL 2037 * userData = the data to pass to callback function 2038 */ 2039 public void mountMountable(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2040 { 2041 g_file_mount_mountable(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2042 } 2043 2044 /** 2045 * Finishes a mount operation. See g_file_mount_mountable() for details. 2046 * 2047 * Finish an asynchronous mount operation that was started 2048 * with g_file_mount_mountable(). 2049 * 2050 * Params: 2051 * result = a #GAsyncResult 2052 * 2053 * Return: a #GFile or %NULL on error. 2054 * Free the returned object with g_object_unref(). 2055 * 2056 * Throws: GException on failure. 2057 */ 2058 public FileIF mountMountableFinish(AsyncResultIF result) 2059 { 2060 GError* err = null; 2061 2062 auto p = g_file_mount_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err); 2063 2064 if (err !is null) 2065 { 2066 throw new GException( new ErrorG(err) ); 2067 } 2068 2069 if(p is null) 2070 { 2071 return null; 2072 } 2073 2074 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 2075 } 2076 2077 /** 2078 * Tries to move the file or directory @source to the location specified 2079 * by @destination. If native move operations are supported then this is 2080 * used, otherwise a copy + delete fallback is used. The native 2081 * implementation may support moving directories (for instance on moves 2082 * inside the same filesystem), but the fallback code does not. 2083 * 2084 * If the flag #G_FILE_COPY_OVERWRITE is specified an already 2085 * existing @destination file is overwritten. 2086 * 2087 * If the flag #G_FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks 2088 * will be copied as symlinks, otherwise the target of the 2089 * @source symlink will be copied. 2090 * 2091 * If @cancellable is not %NULL, then the operation can be cancelled by 2092 * triggering the cancellable object from another thread. If the operation 2093 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2094 * 2095 * If @progress_callback is not %NULL, then the operation can be monitored 2096 * by setting this to a #GFileProgressCallback function. 2097 * @progress_callback_data will be passed to this function. It is 2098 * guaranteed that this callback will be called after all data has been 2099 * transferred with the total number of bytes copied during the operation. 2100 * 2101 * If the @source file does not exist, then the %G_IO_ERROR_NOT_FOUND 2102 * error is returned, independent on the status of the @destination. 2103 * 2104 * If #G_FILE_COPY_OVERWRITE is not specified and the target exists, 2105 * then the error %G_IO_ERROR_EXISTS is returned. 2106 * 2107 * If trying to overwrite a file over a directory, the %G_IO_ERROR_IS_DIRECTORY 2108 * error is returned. If trying to overwrite a directory with a directory the 2109 * %G_IO_ERROR_WOULD_MERGE error is returned. 2110 * 2111 * If the source is a directory and the target does not exist, or 2112 * #G_FILE_COPY_OVERWRITE is specified and the target is a file, then 2113 * the %G_IO_ERROR_WOULD_RECURSE error may be returned (if the native 2114 * move operation isn't available). 2115 * 2116 * Params: 2117 * destination = #GFile pointing to the destination location 2118 * flags = set of #GFileCopyFlags 2119 * cancellable = optional #GCancellable object, 2120 * %NULL to ignore 2121 * progressCallback = #GFileProgressCallback 2122 * function for updates 2123 * progressCallbackData = gpointer to user data for 2124 * the callback function 2125 * 2126 * Return: %TRUE on successful move, %FALSE otherwise. 2127 * 2128 * Throws: GException on failure. 2129 */ 2130 public bool move(FileIF destination, GFileCopyFlags flags, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData) 2131 { 2132 GError* err = null; 2133 2134 auto p = g_file_move(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressCallbackData, &err) != 0; 2135 2136 if (err !is null) 2137 { 2138 throw new GException( new ErrorG(err) ); 2139 } 2140 2141 return p; 2142 } 2143 2144 /** 2145 * Opens an existing file for reading and writing. The result is 2146 * a #GFileIOStream that can be used to read and write the contents 2147 * of the file. 2148 * 2149 * If @cancellable is not %NULL, then the operation can be cancelled 2150 * by triggering the cancellable object from another thread. If the 2151 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2152 * returned. 2153 * 2154 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 2155 * be returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY 2156 * error will be returned. Other errors are possible too, and depend on 2157 * what kind of filesystem the file is on. Note that in many non-local 2158 * file cases read and write streams are not supported, so make sure you 2159 * really need to do read and write streaming, rather than just opening 2160 * for reading or writing. 2161 * 2162 * Params: 2163 * cancellable = a #GCancellable 2164 * 2165 * Return: #GFileIOStream or %NULL on error. 2166 * Free the returned object with g_object_unref(). 2167 * 2168 * Since: 2.22 2169 * 2170 * Throws: GException on failure. 2171 */ 2172 public FileIOStream openReadwrite(Cancellable cancellable) 2173 { 2174 GError* err = null; 2175 2176 auto p = g_file_open_readwrite(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2177 2178 if (err !is null) 2179 { 2180 throw new GException( new ErrorG(err) ); 2181 } 2182 2183 if(p is null) 2184 { 2185 return null; 2186 } 2187 2188 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 2189 } 2190 2191 /** 2192 * Asynchronously opens @file for reading and writing. 2193 * 2194 * For more details, see g_file_open_readwrite() which is 2195 * the synchronous version of this call. 2196 * 2197 * When the operation is finished, @callback will be called. 2198 * You can then call g_file_open_readwrite_finish() to get 2199 * the result of the operation. 2200 * 2201 * Params: 2202 * ioPriority = the [I/O priority][io-priority] of the request 2203 * cancellable = optional #GCancellable object, 2204 * %NULL to ignore 2205 * callback = a #GAsyncReadyCallback to call 2206 * when the request is satisfied 2207 * userData = the data to pass to callback function 2208 * 2209 * Since: 2.22 2210 */ 2211 public void openReadwriteAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2212 { 2213 g_file_open_readwrite_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2214 } 2215 2216 /** 2217 * Finishes an asynchronous file read operation started with 2218 * g_file_open_readwrite_async(). 2219 * 2220 * Params: 2221 * res = a #GAsyncResult 2222 * 2223 * Return: a #GFileIOStream or %NULL on error. 2224 * Free the returned object with g_object_unref(). 2225 * 2226 * Since: 2.22 2227 * 2228 * Throws: GException on failure. 2229 */ 2230 public FileIOStream openReadwriteFinish(AsyncResultIF res) 2231 { 2232 GError* err = null; 2233 2234 auto p = g_file_open_readwrite_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2235 2236 if (err !is null) 2237 { 2238 throw new GException( new ErrorG(err) ); 2239 } 2240 2241 if(p is null) 2242 { 2243 return null; 2244 } 2245 2246 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 2247 } 2248 2249 /** 2250 * Polls a file of type #G_FILE_TYPE_MOUNTABLE. 2251 * 2252 * If @cancellable is not %NULL, then the operation can be cancelled by 2253 * triggering the cancellable object from another thread. If the operation 2254 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2255 * 2256 * When the operation is finished, @callback will be called. 2257 * You can then call g_file_mount_mountable_finish() to get 2258 * the result of the operation. 2259 * 2260 * Params: 2261 * cancellable = optional #GCancellable object, %NULL to ignore 2262 * callback = a #GAsyncReadyCallback to call 2263 * when the request is satisfied, or %NULL 2264 * userData = the data to pass to callback function 2265 * 2266 * Since: 2.22 2267 */ 2268 public void pollMountable(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2269 { 2270 g_file_poll_mountable(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2271 } 2272 2273 /** 2274 * Finishes a poll operation. See g_file_poll_mountable() for details. 2275 * 2276 * Finish an asynchronous poll operation that was polled 2277 * with g_file_poll_mountable(). 2278 * 2279 * Params: 2280 * result = a #GAsyncResult 2281 * 2282 * Return: %TRUE if the operation finished successfully. %FALSE 2283 * otherwise. 2284 * 2285 * Since: 2.22 2286 * 2287 * Throws: GException on failure. 2288 */ 2289 public bool pollMountableFinish(AsyncResultIF result) 2290 { 2291 GError* err = null; 2292 2293 auto p = g_file_poll_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2294 2295 if (err !is null) 2296 { 2297 throw new GException( new ErrorG(err) ); 2298 } 2299 2300 return p; 2301 } 2302 2303 /** 2304 * Returns the #GAppInfo that is registered as the default 2305 * application to handle the file specified by @file. 2306 * 2307 * If @cancellable is not %NULL, then the operation can be cancelled by 2308 * triggering the cancellable object from another thread. If the operation 2309 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2310 * 2311 * Params: 2312 * cancellable = optional #GCancellable object, %NULL to ignore 2313 * 2314 * Return: a #GAppInfo if the handle was found, 2315 * %NULL if there were errors. 2316 * When you are done with it, release it with g_object_unref() 2317 * 2318 * Throws: GException on failure. 2319 */ 2320 public AppInfoIF queryDefaultHandler(Cancellable cancellable) 2321 { 2322 GError* err = null; 2323 2324 auto p = g_file_query_default_handler(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2325 2326 if (err !is null) 2327 { 2328 throw new GException( new ErrorG(err) ); 2329 } 2330 2331 if(p is null) 2332 { 2333 return null; 2334 } 2335 2336 return ObjectG.getDObject!(AppInfo, AppInfoIF)(cast(GAppInfo*) p, true); 2337 } 2338 2339 /** 2340 * Utility function to check if a particular file exists. This is 2341 * implemented using g_file_query_info() and as such does blocking I/O. 2342 * 2343 * Note that in many cases it is racy to first check for file existence 2344 * and then execute something based on the outcome of that, because the 2345 * file might have been created or removed in between the operations. The 2346 * general approach to handling that is to not check, but just do the 2347 * operation and handle the errors as they come. 2348 * 2349 * As an example of race-free checking, take the case of reading a file, 2350 * and if it doesn't exist, creating it. There are two racy versions: read 2351 * it, and on error create it; and: check if it exists, if not create it. 2352 * These can both result in two processes creating the file (with perhaps 2353 * a partially written file as the result). The correct approach is to 2354 * always try to create the file with g_file_create() which will either 2355 * atomically create the file or fail with a %G_IO_ERROR_EXISTS error. 2356 * 2357 * However, in many cases an existence check is useful in a user interface, 2358 * for instance to make a menu item sensitive/insensitive, so that you don't 2359 * have to fool users that something is possible and then just show an error 2360 * dialog. If you do this, you should make sure to also handle the errors 2361 * that can happen due to races when you execute the operation. 2362 * 2363 * Params: 2364 * cancellable = optional #GCancellable object, 2365 * %NULL to ignore 2366 * 2367 * Return: %TRUE if the file exists (and can be detected without error), 2368 * %FALSE otherwise (or if cancelled). 2369 */ 2370 public bool queryExists(Cancellable cancellable) 2371 { 2372 return g_file_query_exists(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct()) != 0; 2373 } 2374 2375 /** 2376 * Utility function to inspect the #GFileType of a file. This is 2377 * implemented using g_file_query_info() and as such does blocking I/O. 2378 * 2379 * The primary use case of this method is to check if a file is 2380 * a regular file, directory, or symlink. 2381 * 2382 * Params: 2383 * flags = a set of #GFileQueryInfoFlags passed to g_file_query_info() 2384 * cancellable = optional #GCancellable object, 2385 * %NULL to ignore 2386 * 2387 * Return: The #GFileType of the file and #G_FILE_TYPE_UNKNOWN 2388 * if the file does not exist 2389 * 2390 * Since: 2.18 2391 */ 2392 public GFileType queryFileType(GFileQueryInfoFlags flags, Cancellable cancellable) 2393 { 2394 return g_file_query_file_type(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct()); 2395 } 2396 2397 /** 2398 * Similar to g_file_query_info(), but obtains information 2399 * about the filesystem the @file is on, rather than the file itself. 2400 * For instance the amount of space available and the type of 2401 * the filesystem. 2402 * 2403 * The @attributes value is a string that specifies the attributes 2404 * that should be gathered. It is not an error if it's not possible 2405 * to read a particular requested attribute from a file - it just 2406 * won't be set. @attributes should be a comma-separated list of 2407 * attributes or attribute wildcards. The wildcard "*" means all 2408 * attributes, and a wildcard like "filesystem::*" means all attributes 2409 * in the filesystem namespace. The standard namespace for filesystem 2410 * attributes is "filesystem". Common attributes of interest are 2411 * #G_FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem 2412 * in bytes), #G_FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes available), 2413 * and #G_FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem). 2414 * 2415 * If @cancellable is not %NULL, then the operation can be cancelled 2416 * by triggering the cancellable object from another thread. If the 2417 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2418 * returned. 2419 * 2420 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 2421 * be returned. Other errors are possible too, and depend on what 2422 * kind of filesystem the file is on. 2423 * 2424 * Params: 2425 * attributes = an attribute query string 2426 * cancellable = optional #GCancellable object, 2427 * %NULL to ignore 2428 * 2429 * Return: a #GFileInfo or %NULL if there was an error. 2430 * Free the returned object with g_object_unref(). 2431 * 2432 * Throws: GException on failure. 2433 */ 2434 public FileInfo queryFilesystemInfo(string attributes, Cancellable cancellable) 2435 { 2436 GError* err = null; 2437 2438 auto p = g_file_query_filesystem_info(getFileStruct(), Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2439 2440 if (err !is null) 2441 { 2442 throw new GException( new ErrorG(err) ); 2443 } 2444 2445 if(p is null) 2446 { 2447 return null; 2448 } 2449 2450 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true); 2451 } 2452 2453 /** 2454 * Asynchronously gets the requested information about the filesystem 2455 * that the specified @file is on. The result is a #GFileInfo object 2456 * that contains key-value attributes (such as type or size for the 2457 * file). 2458 * 2459 * For more details, see g_file_query_filesystem_info() which is the 2460 * synchronous version of this call. 2461 * 2462 * When the operation is finished, @callback will be called. You can 2463 * then call g_file_query_info_finish() to get the result of the 2464 * operation. 2465 * 2466 * Params: 2467 * attributes = an attribute query string 2468 * ioPriority = the [I/O priority][io-priority] of the request 2469 * cancellable = optional #GCancellable object, 2470 * %NULL to ignore 2471 * callback = a #GAsyncReadyCallback to call 2472 * when the request is satisfied 2473 * userData = the data to pass to callback function 2474 */ 2475 public void queryFilesystemInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2476 { 2477 g_file_query_filesystem_info_async(getFileStruct(), Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2478 } 2479 2480 /** 2481 * Finishes an asynchronous filesystem info query. 2482 * See g_file_query_filesystem_info_async(). 2483 * 2484 * Params: 2485 * res = a #GAsyncResult 2486 * 2487 * Return: #GFileInfo for given @file 2488 * or %NULL on error. 2489 * Free the returned object with g_object_unref(). 2490 * 2491 * Throws: GException on failure. 2492 */ 2493 public FileInfo queryFilesystemInfoFinish(AsyncResultIF res) 2494 { 2495 GError* err = null; 2496 2497 auto p = g_file_query_filesystem_info_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2498 2499 if (err !is null) 2500 { 2501 throw new GException( new ErrorG(err) ); 2502 } 2503 2504 if(p is null) 2505 { 2506 return null; 2507 } 2508 2509 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true); 2510 } 2511 2512 /** 2513 * Gets the requested information about specified @file. 2514 * The result is a #GFileInfo object that contains key-value 2515 * attributes (such as the type or size of the file). 2516 * 2517 * The @attributes value is a string that specifies the file 2518 * attributes that should be gathered. It is not an error if 2519 * it's not possible to read a particular requested attribute 2520 * from a file - it just won't be set. @attributes should be a 2521 * comma-separated list of attributes or attribute wildcards. 2522 * The wildcard "*" means all attributes, and a wildcard like 2523 * "standard::*" means all attributes in the standard namespace. 2524 * An example attribute query be "standard::*,owner::user". 2525 * The standard attributes are available as defines, like 2526 * #G_FILE_ATTRIBUTE_STANDARD_NAME. 2527 * 2528 * If @cancellable is not %NULL, then the operation can be cancelled 2529 * by triggering the cancellable object from another thread. If the 2530 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2531 * returned. 2532 * 2533 * For symlinks, normally the information about the target of the 2534 * symlink is returned, rather than information about the symlink 2535 * itself. However if you pass #G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS 2536 * in @flags the information about the symlink itself will be returned. 2537 * Also, for symlinks that point to non-existing files the information 2538 * about the symlink itself will be returned. 2539 * 2540 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be 2541 * returned. Other errors are possible too, and depend on what kind of 2542 * filesystem the file is on. 2543 * 2544 * Params: 2545 * attributes = an attribute query string 2546 * flags = a set of #GFileQueryInfoFlags 2547 * cancellable = optional #GCancellable object, 2548 * %NULL to ignore 2549 * 2550 * Return: a #GFileInfo for the given @file, or %NULL 2551 * on error. Free the returned object with g_object_unref(). 2552 * 2553 * Throws: GException on failure. 2554 */ 2555 public FileInfo queryInfo(string attributes, GFileQueryInfoFlags flags, Cancellable cancellable) 2556 { 2557 GError* err = null; 2558 2559 auto p = g_file_query_info(getFileStruct(), Str.toStringz(attributes), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2560 2561 if (err !is null) 2562 { 2563 throw new GException( new ErrorG(err) ); 2564 } 2565 2566 if(p is null) 2567 { 2568 return null; 2569 } 2570 2571 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true); 2572 } 2573 2574 /** 2575 * Asynchronously gets the requested information about specified @file. 2576 * The result is a #GFileInfo object that contains key-value attributes 2577 * (such as type or size for the file). 2578 * 2579 * For more details, see g_file_query_info() which is the synchronous 2580 * version of this call. 2581 * 2582 * When the operation is finished, @callback will be called. You can 2583 * then call g_file_query_info_finish() to get the result of the operation. 2584 * 2585 * Params: 2586 * attributes = an attribute query string 2587 * flags = a set of #GFileQueryInfoFlags 2588 * ioPriority = the [I/O priority][io-priority] of the request 2589 * cancellable = optional #GCancellable object, 2590 * %NULL to ignore 2591 * callback = a #GAsyncReadyCallback to call when the 2592 * request is satisfied 2593 * userData = the data to pass to callback function 2594 */ 2595 public void queryInfoAsync(string attributes, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2596 { 2597 g_file_query_info_async(getFileStruct(), Str.toStringz(attributes), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2598 } 2599 2600 /** 2601 * Finishes an asynchronous file info query. 2602 * See g_file_query_info_async(). 2603 * 2604 * Params: 2605 * res = a #GAsyncResult 2606 * 2607 * Return: #GFileInfo for given @file 2608 * or %NULL on error. Free the returned object with 2609 * g_object_unref(). 2610 * 2611 * Throws: GException on failure. 2612 */ 2613 public FileInfo queryInfoFinish(AsyncResultIF res) 2614 { 2615 GError* err = null; 2616 2617 auto p = g_file_query_info_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2618 2619 if (err !is null) 2620 { 2621 throw new GException( new ErrorG(err) ); 2622 } 2623 2624 if(p is null) 2625 { 2626 return null; 2627 } 2628 2629 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true); 2630 } 2631 2632 /** 2633 * Obtain the list of settable attributes for the file. 2634 * 2635 * Returns the type and full attribute name of all the attributes 2636 * that can be set on this file. This doesn't mean setting it will 2637 * always succeed though, you might get an access failure, or some 2638 * specific file may not support a specific attribute. 2639 * 2640 * If @cancellable is not %NULL, then the operation can be cancelled by 2641 * triggering the cancellable object from another thread. If the operation 2642 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2643 * 2644 * Params: 2645 * cancellable = optional #GCancellable object, 2646 * %NULL to ignore 2647 * 2648 * Return: a #GFileAttributeInfoList describing the settable attributes. 2649 * When you are done with it, release it with 2650 * g_file_attribute_info_list_unref() 2651 * 2652 * Throws: GException on failure. 2653 */ 2654 public FileAttributeInfoList querySettableAttributes(Cancellable cancellable) 2655 { 2656 GError* err = null; 2657 2658 auto p = g_file_query_settable_attributes(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2659 2660 if (err !is null) 2661 { 2662 throw new GException( new ErrorG(err) ); 2663 } 2664 2665 if(p is null) 2666 { 2667 return null; 2668 } 2669 2670 return ObjectG.getDObject!(FileAttributeInfoList)(cast(GFileAttributeInfoList*) p, true); 2671 } 2672 2673 /** 2674 * Obtain the list of attribute namespaces where new attributes 2675 * can be created by a user. An example of this is extended 2676 * attributes (in the "xattr" namespace). 2677 * 2678 * If @cancellable is not %NULL, then the operation can be cancelled by 2679 * triggering the cancellable object from another thread. If the operation 2680 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2681 * 2682 * Params: 2683 * cancellable = optional #GCancellable object, 2684 * %NULL to ignore 2685 * 2686 * Return: a #GFileAttributeInfoList describing the writable namespaces. 2687 * When you are done with it, release it with 2688 * g_file_attribute_info_list_unref() 2689 * 2690 * Throws: GException on failure. 2691 */ 2692 public FileAttributeInfoList queryWritableNamespaces(Cancellable cancellable) 2693 { 2694 GError* err = null; 2695 2696 auto p = g_file_query_writable_namespaces(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2697 2698 if (err !is null) 2699 { 2700 throw new GException( new ErrorG(err) ); 2701 } 2702 2703 if(p is null) 2704 { 2705 return null; 2706 } 2707 2708 return ObjectG.getDObject!(FileAttributeInfoList)(cast(GFileAttributeInfoList*) p, true); 2709 } 2710 2711 /** 2712 * Opens a file for reading. The result is a #GFileInputStream that 2713 * can be used to read the contents of the file. 2714 * 2715 * If @cancellable is not %NULL, then the operation can be cancelled by 2716 * triggering the cancellable object from another thread. If the operation 2717 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2718 * 2719 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be 2720 * returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY 2721 * error will be returned. Other errors are possible too, and depend 2722 * on what kind of filesystem the file is on. 2723 * 2724 * Params: 2725 * cancellable = a #GCancellable 2726 * 2727 * Return: #GFileInputStream or %NULL on error. 2728 * Free the returned object with g_object_unref(). 2729 * 2730 * Throws: GException on failure. 2731 */ 2732 public FileInputStream read(Cancellable cancellable) 2733 { 2734 GError* err = null; 2735 2736 auto p = g_file_read(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2737 2738 if (err !is null) 2739 { 2740 throw new GException( new ErrorG(err) ); 2741 } 2742 2743 if(p is null) 2744 { 2745 return null; 2746 } 2747 2748 return ObjectG.getDObject!(FileInputStream)(cast(GFileInputStream*) p, true); 2749 } 2750 2751 /** 2752 * Asynchronously opens @file for reading. 2753 * 2754 * For more details, see g_file_read() which is 2755 * the synchronous version of this call. 2756 * 2757 * When the operation is finished, @callback will be called. 2758 * You can then call g_file_read_finish() to get the result 2759 * of the operation. 2760 * 2761 * Params: 2762 * ioPriority = the [I/O priority][io-priority] of the request 2763 * cancellable = optional #GCancellable object, 2764 * %NULL to ignore 2765 * callback = a #GAsyncReadyCallback to call 2766 * when the request is satisfied 2767 * userData = the data to pass to callback function 2768 */ 2769 public void readAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2770 { 2771 g_file_read_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2772 } 2773 2774 /** 2775 * Finishes an asynchronous file read operation started with 2776 * g_file_read_async(). 2777 * 2778 * Params: 2779 * res = a #GAsyncResult 2780 * 2781 * Return: a #GFileInputStream or %NULL on error. 2782 * Free the returned object with g_object_unref(). 2783 * 2784 * Throws: GException on failure. 2785 */ 2786 public FileInputStream readFinish(AsyncResultIF res) 2787 { 2788 GError* err = null; 2789 2790 auto p = g_file_read_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2791 2792 if (err !is null) 2793 { 2794 throw new GException( new ErrorG(err) ); 2795 } 2796 2797 if(p is null) 2798 { 2799 return null; 2800 } 2801 2802 return ObjectG.getDObject!(FileInputStream)(cast(GFileInputStream*) p, true); 2803 } 2804 2805 /** 2806 * Returns an output stream for overwriting the file, possibly 2807 * creating a backup copy of the file first. If the file doesn't exist, 2808 * it will be created. 2809 * 2810 * This will try to replace the file in the safest way possible so 2811 * that any errors during the writing will not affect an already 2812 * existing copy of the file. For instance, for local files it 2813 * may write to a temporary file and then atomically rename over 2814 * the destination when the stream is closed. 2815 * 2816 * By default files created are generally readable by everyone, 2817 * but if you pass #G_FILE_CREATE_PRIVATE in @flags the file 2818 * will be made readable only to the current user, to the level that 2819 * is supported on the target filesystem. 2820 * 2821 * If @cancellable is not %NULL, then the operation can be cancelled 2822 * by triggering the cancellable object from another thread. If the 2823 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2824 * returned. 2825 * 2826 * If you pass in a non-%NULL @etag value and @file already exists, then 2827 * this value is compared to the current entity tag of the file, and if 2828 * they differ an %G_IO_ERROR_WRONG_ETAG error is returned. This 2829 * generally means that the file has been changed since you last read 2830 * it. You can get the new etag from g_file_output_stream_get_etag() 2831 * after you've finished writing and closed the #GFileOutputStream. When 2832 * you load a new file you can use g_file_input_stream_query_info() to 2833 * get the etag of the file. 2834 * 2835 * If @make_backup is %TRUE, this function will attempt to make a 2836 * backup of the current file before overwriting it. If this fails 2837 * a %G_IO_ERROR_CANT_CREATE_BACKUP error will be returned. If you 2838 * want to replace anyway, try again with @make_backup set to %FALSE. 2839 * 2840 * If the file is a directory the %G_IO_ERROR_IS_DIRECTORY error will 2841 * be returned, and if the file is some other form of non-regular file 2842 * then a %G_IO_ERROR_NOT_REGULAR_FILE error will be returned. Some 2843 * file systems don't allow all file names, and may return an 2844 * %G_IO_ERROR_INVALID_FILENAME error, and if the name is to long 2845 * %G_IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are 2846 * possible too, and depend on what kind of filesystem the file is on. 2847 * 2848 * Params: 2849 * etag = an optional [entity tag][gfile-etag] 2850 * for the current #GFile, or #NULL to ignore 2851 * makeBackup = %TRUE if a backup should be created 2852 * flags = a set of #GFileCreateFlags 2853 * cancellable = optional #GCancellable object, 2854 * %NULL to ignore 2855 * 2856 * Return: a #GFileOutputStream or %NULL on error. 2857 * Free the returned object with g_object_unref(). 2858 * 2859 * Throws: GException on failure. 2860 */ 2861 public FileOutputStream replace(string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable) 2862 { 2863 GError* err = null; 2864 2865 auto p = g_file_replace(getFileStruct(), Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2866 2867 if (err !is null) 2868 { 2869 throw new GException( new ErrorG(err) ); 2870 } 2871 2872 if(p is null) 2873 { 2874 return null; 2875 } 2876 2877 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) p, true); 2878 } 2879 2880 /** 2881 * Asynchronously overwrites the file, replacing the contents, 2882 * possibly creating a backup copy of the file first. 2883 * 2884 * For more details, see g_file_replace() which is 2885 * the synchronous version of this call. 2886 * 2887 * When the operation is finished, @callback will be called. 2888 * You can then call g_file_replace_finish() to get the result 2889 * of the operation. 2890 * 2891 * Params: 2892 * etag = an [entity tag][gfile-etag] for the current #GFile, 2893 * or %NULL to ignore 2894 * makeBackup = %TRUE if a backup should be created 2895 * flags = a set of #GFileCreateFlags 2896 * ioPriority = the [I/O priority][io-priority] of the request 2897 * cancellable = optional #GCancellable object, 2898 * %NULL to ignore 2899 * callback = a #GAsyncReadyCallback to call 2900 * when the request is satisfied 2901 * userData = the data to pass to callback function 2902 */ 2903 public void replaceAsync(string etag, bool makeBackup, GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2904 { 2905 g_file_replace_async(getFileStruct(), Str.toStringz(etag), makeBackup, flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2906 } 2907 2908 /** 2909 * Replaces the contents of @file with @contents of @length bytes. 2910 * 2911 * If @etag is specified (not %NULL), any existing file must have that etag, 2912 * or the error %G_IO_ERROR_WRONG_ETAG will be returned. 2913 * 2914 * If @make_backup is %TRUE, this function will attempt to make a backup 2915 * of @file. Internally, it uses g_file_replace(), so will try to replace the 2916 * file contents in the safest way possible. For example, atomic renames are 2917 * used when replacing local files’ contents. 2918 * 2919 * If @cancellable is not %NULL, then the operation can be cancelled by 2920 * triggering the cancellable object from another thread. If the operation 2921 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2922 * 2923 * The returned @new_etag can be used to verify that the file hasn't 2924 * changed the next time it is saved over. 2925 * 2926 * Params: 2927 * contents = a string containing the new contents for @file 2928 * length = the length of @contents in bytes 2929 * etag = the old [entity-tag][gfile-etag] for the document, 2930 * or %NULL 2931 * makeBackup = %TRUE if a backup should be created 2932 * flags = a set of #GFileCreateFlags 2933 * newEtag = a location to a new [entity tag][gfile-etag] 2934 * for the document. This should be freed with g_free() when no longer 2935 * needed, or %NULL 2936 * cancellable = optional #GCancellable object, %NULL to ignore 2937 * 2938 * Return: %TRUE if successful. If an error has occurred, this function 2939 * will return %FALSE and set @error appropriately if present. 2940 * 2941 * Throws: GException on failure. 2942 */ 2943 public bool replaceContents(string contents, string etag, bool makeBackup, GFileCreateFlags flags, out string newEtag, Cancellable cancellable) 2944 { 2945 char* outnewEtag = null; 2946 GError* err = null; 2947 2948 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; 2949 2950 if (err !is null) 2951 { 2952 throw new GException( new ErrorG(err) ); 2953 } 2954 2955 newEtag = Str.toString(outnewEtag); 2956 2957 return p; 2958 } 2959 2960 /** 2961 * Starts an asynchronous replacement of @file with the given 2962 * @contents of @length bytes. @etag will replace the document's 2963 * current entity tag. 2964 * 2965 * When this operation has completed, @callback will be called with 2966 * @user_user data, and the operation can be finalized with 2967 * g_file_replace_contents_finish(). 2968 * 2969 * If @cancellable is not %NULL, then the operation can be cancelled by 2970 * triggering the cancellable object from another thread. If the operation 2971 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2972 * 2973 * If @make_backup is %TRUE, this function will attempt to 2974 * make a backup of @file. 2975 * 2976 * Note that no copy of @content will be made, so it must stay valid 2977 * until @callback is called. See g_file_replace_contents_bytes_async() 2978 * for a #GBytes version that will automatically hold a reference to the 2979 * contents (without copying) for the duration of the call. 2980 * 2981 * Params: 2982 * contents = string of contents to replace the file with 2983 * length = the length of @contents in bytes 2984 * etag = a new [entity tag][gfile-etag] for the @file, or %NULL 2985 * makeBackup = %TRUE if a backup should be created 2986 * flags = a set of #GFileCreateFlags 2987 * cancellable = optional #GCancellable object, %NULL to ignore 2988 * callback = a #GAsyncReadyCallback to call when the request is satisfied 2989 * userData = the data to pass to callback function 2990 */ 2991 public void replaceContentsAsync(string contents, string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2992 { 2993 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); 2994 } 2995 2996 /** 2997 * Same as g_file_replace_contents_async() but takes a #GBytes input instead. 2998 * This function will keep a ref on @contents until the operation is done. 2999 * Unlike g_file_replace_contents_async() this allows forgetting about the 3000 * content without waiting for the callback. 3001 * 3002 * When this operation has completed, @callback will be called with 3003 * @user_user data, and the operation can be finalized with 3004 * g_file_replace_contents_finish(). 3005 * 3006 * Params: 3007 * contents = a #GBytes 3008 * etag = a new [entity tag][gfile-etag] for the @file, or %NULL 3009 * makeBackup = %TRUE if a backup should be created 3010 * flags = a set of #GFileCreateFlags 3011 * cancellable = optional #GCancellable object, %NULL to ignore 3012 * callback = a #GAsyncReadyCallback to call when the request is satisfied 3013 * userData = the data to pass to callback function 3014 * 3015 * Since: 2.40 3016 */ 3017 public void replaceContentsBytesAsync(Bytes contents, string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3018 { 3019 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); 3020 } 3021 3022 /** 3023 * Finishes an asynchronous replace of the given @file. See 3024 * g_file_replace_contents_async(). Sets @new_etag to the new entity 3025 * tag for the document, if present. 3026 * 3027 * Params: 3028 * res = a #GAsyncResult 3029 * newEtag = a location of a new [entity tag][gfile-etag] 3030 * for the document. This should be freed with g_free() when it is no 3031 * longer needed, or %NULL 3032 * 3033 * Return: %TRUE on success, %FALSE on failure. 3034 * 3035 * Throws: GException on failure. 3036 */ 3037 public bool replaceContentsFinish(AsyncResultIF res, out string newEtag) 3038 { 3039 char* outnewEtag = null; 3040 GError* err = null; 3041 3042 auto p = g_file_replace_contents_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &outnewEtag, &err) != 0; 3043 3044 if (err !is null) 3045 { 3046 throw new GException( new ErrorG(err) ); 3047 } 3048 3049 newEtag = Str.toString(outnewEtag); 3050 3051 return p; 3052 } 3053 3054 /** 3055 * Finishes an asynchronous file replace operation started with 3056 * g_file_replace_async(). 3057 * 3058 * Params: 3059 * res = a #GAsyncResult 3060 * 3061 * Return: a #GFileOutputStream, or %NULL on error. 3062 * Free the returned object with g_object_unref(). 3063 * 3064 * Throws: GException on failure. 3065 */ 3066 public FileOutputStream replaceFinish(AsyncResultIF res) 3067 { 3068 GError* err = null; 3069 3070 auto p = g_file_replace_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3071 3072 if (err !is null) 3073 { 3074 throw new GException( new ErrorG(err) ); 3075 } 3076 3077 if(p is null) 3078 { 3079 return null; 3080 } 3081 3082 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) p, true); 3083 } 3084 3085 /** 3086 * Returns an output stream for overwriting the file in readwrite mode, 3087 * possibly creating a backup copy of the file first. If the file doesn't 3088 * exist, it will be created. 3089 * 3090 * For details about the behaviour, see g_file_replace() which does the 3091 * same thing but returns an output stream only. 3092 * 3093 * Note that in many non-local file cases read and write streams are not 3094 * supported, so make sure you really need to do read and write streaming, 3095 * rather than just opening for reading or writing. 3096 * 3097 * Params: 3098 * etag = an optional [entity tag][gfile-etag] 3099 * for the current #GFile, or #NULL to ignore 3100 * makeBackup = %TRUE if a backup should be created 3101 * flags = a set of #GFileCreateFlags 3102 * cancellable = optional #GCancellable object, 3103 * %NULL to ignore 3104 * 3105 * Return: a #GFileIOStream or %NULL on error. 3106 * Free the returned object with g_object_unref(). 3107 * 3108 * Since: 2.22 3109 * 3110 * Throws: GException on failure. 3111 */ 3112 public FileIOStream replaceReadwrite(string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable) 3113 { 3114 GError* err = null; 3115 3116 auto p = g_file_replace_readwrite(getFileStruct(), Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 3117 3118 if (err !is null) 3119 { 3120 throw new GException( new ErrorG(err) ); 3121 } 3122 3123 if(p is null) 3124 { 3125 return null; 3126 } 3127 3128 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 3129 } 3130 3131 /** 3132 * Asynchronously overwrites the file in read-write mode, 3133 * replacing the contents, possibly creating a backup copy 3134 * of the file first. 3135 * 3136 * For more details, see g_file_replace_readwrite() which is 3137 * the synchronous version of this call. 3138 * 3139 * When the operation is finished, @callback will be called. 3140 * You can then call g_file_replace_readwrite_finish() to get 3141 * the result of the operation. 3142 * 3143 * Params: 3144 * etag = an [entity tag][gfile-etag] for the current #GFile, 3145 * or %NULL to ignore 3146 * makeBackup = %TRUE if a backup should be created 3147 * flags = a set of #GFileCreateFlags 3148 * ioPriority = the [I/O priority][io-priority] of the request 3149 * cancellable = optional #GCancellable object, 3150 * %NULL to ignore 3151 * callback = a #GAsyncReadyCallback to call 3152 * when the request is satisfied 3153 * userData = the data to pass to callback function 3154 * 3155 * Since: 2.22 3156 */ 3157 public void replaceReadwriteAsync(string etag, bool makeBackup, GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3158 { 3159 g_file_replace_readwrite_async(getFileStruct(), Str.toStringz(etag), makeBackup, flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3160 } 3161 3162 /** 3163 * Finishes an asynchronous file replace operation started with 3164 * g_file_replace_readwrite_async(). 3165 * 3166 * Params: 3167 * res = a #GAsyncResult 3168 * 3169 * Return: a #GFileIOStream, or %NULL on error. 3170 * Free the returned object with g_object_unref(). 3171 * 3172 * Since: 2.22 3173 * 3174 * Throws: GException on failure. 3175 */ 3176 public FileIOStream replaceReadwriteFinish(AsyncResultIF res) 3177 { 3178 GError* err = null; 3179 3180 auto p = g_file_replace_readwrite_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3181 3182 if (err !is null) 3183 { 3184 throw new GException( new ErrorG(err) ); 3185 } 3186 3187 if(p is null) 3188 { 3189 return null; 3190 } 3191 3192 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) p, true); 3193 } 3194 3195 /** 3196 * Resolves a relative path for @file to an absolute path. 3197 * 3198 * This call does no blocking I/O. 3199 * 3200 * Params: 3201 * relativePath = a given relative path string 3202 * 3203 * Return: #GFile to the resolved path. 3204 * %NULL if @relative_path is %NULL or if @file is invalid. 3205 * Free the returned object with g_object_unref(). 3206 */ 3207 public FileIF resolveRelativePath(string relativePath) 3208 { 3209 auto p = g_file_resolve_relative_path(getFileStruct(), Str.toStringz(relativePath)); 3210 3211 if(p is null) 3212 { 3213 return null; 3214 } 3215 3216 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 3217 } 3218 3219 /** 3220 * Sets an attribute in the file with attribute name @attribute to @value. 3221 * 3222 * Some attributes can be unset by setting @attribute to 3223 * %G_FILE_ATTRIBUTE_TYPE_INVALID and @value_p to %NULL. 3224 * 3225 * If @cancellable is not %NULL, then the operation can be cancelled by 3226 * triggering the cancellable object from another thread. If the operation 3227 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3228 * 3229 * Params: 3230 * attribute = a string containing the attribute's name 3231 * type = The type of the attribute 3232 * valueP = a pointer to the value (or the pointer 3233 * itself if the type is a pointer type) 3234 * flags = a set of #GFileQueryInfoFlags 3235 * cancellable = optional #GCancellable object, 3236 * %NULL to ignore 3237 * 3238 * Return: %TRUE if the attribute was set, %FALSE otherwise. 3239 * 3240 * Throws: GException on failure. 3241 */ 3242 public bool setAttribute(string attribute, GFileAttributeType type, void* valueP, GFileQueryInfoFlags flags, Cancellable cancellable) 3243 { 3244 GError* err = null; 3245 3246 auto p = g_file_set_attribute(getFileStruct(), Str.toStringz(attribute), type, valueP, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3247 3248 if (err !is null) 3249 { 3250 throw new GException( new ErrorG(err) ); 3251 } 3252 3253 return p; 3254 } 3255 3256 /** 3257 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to @value. 3258 * If @attribute is of a different type, this operation will fail, 3259 * returning %FALSE. 3260 * 3261 * If @cancellable is not %NULL, then the operation can be cancelled by 3262 * triggering the cancellable object from another thread. If the operation 3263 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3264 * 3265 * Params: 3266 * attribute = a string containing the attribute's name 3267 * value = a string containing the attribute's new value 3268 * flags = a #GFileQueryInfoFlags 3269 * cancellable = optional #GCancellable object, 3270 * %NULL to ignore 3271 * 3272 * Return: %TRUE if the @attribute was successfully set to @value 3273 * in the @file, %FALSE otherwise. 3274 * 3275 * Throws: GException on failure. 3276 */ 3277 public bool setAttributeByteString(string attribute, string value, GFileQueryInfoFlags flags, Cancellable cancellable) 3278 { 3279 GError* err = null; 3280 3281 auto p = g_file_set_attribute_byte_string(getFileStruct(), Str.toStringz(attribute), Str.toStringz(value), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3282 3283 if (err !is null) 3284 { 3285 throw new GException( new ErrorG(err) ); 3286 } 3287 3288 return p; 3289 } 3290 3291 /** 3292 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT32 to @value. 3293 * If @attribute is of a different type, this operation will fail. 3294 * 3295 * If @cancellable is not %NULL, then the operation can be cancelled by 3296 * triggering the cancellable object from another thread. If the operation 3297 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3298 * 3299 * Params: 3300 * attribute = a string containing the attribute's name 3301 * value = a #gint32 containing the attribute's new value 3302 * flags = a #GFileQueryInfoFlags 3303 * cancellable = optional #GCancellable object, 3304 * %NULL to ignore 3305 * 3306 * Return: %TRUE if the @attribute was successfully set to @value 3307 * in the @file, %FALSE otherwise. 3308 * 3309 * Throws: GException on failure. 3310 */ 3311 public bool setAttributeInt32(string attribute, int value, GFileQueryInfoFlags flags, Cancellable cancellable) 3312 { 3313 GError* err = null; 3314 3315 auto p = g_file_set_attribute_int32(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3316 3317 if (err !is null) 3318 { 3319 throw new GException( new ErrorG(err) ); 3320 } 3321 3322 return p; 3323 } 3324 3325 /** 3326 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT64 to @value. 3327 * If @attribute is of a different type, this operation will fail. 3328 * 3329 * If @cancellable is not %NULL, then the operation can be cancelled by 3330 * triggering the cancellable object from another thread. If the operation 3331 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3332 * 3333 * Params: 3334 * attribute = a string containing the attribute's name 3335 * value = a #guint64 containing the attribute's new value 3336 * flags = a #GFileQueryInfoFlags 3337 * cancellable = optional #GCancellable object, 3338 * %NULL to ignore 3339 * 3340 * Return: %TRUE if the @attribute was successfully set, %FALSE otherwise. 3341 * 3342 * Throws: GException on failure. 3343 */ 3344 public bool setAttributeInt64(string attribute, long value, GFileQueryInfoFlags flags, Cancellable cancellable) 3345 { 3346 GError* err = null; 3347 3348 auto p = g_file_set_attribute_int64(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3349 3350 if (err !is null) 3351 { 3352 throw new GException( new ErrorG(err) ); 3353 } 3354 3355 return p; 3356 } 3357 3358 /** 3359 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_STRING to @value. 3360 * If @attribute is of a different type, this operation will fail. 3361 * 3362 * If @cancellable is not %NULL, then the operation can be cancelled by 3363 * triggering the cancellable object from another thread. If the operation 3364 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3365 * 3366 * Params: 3367 * attribute = a string containing the attribute's name 3368 * value = a string containing the attribute's value 3369 * flags = #GFileQueryInfoFlags 3370 * cancellable = optional #GCancellable object, 3371 * %NULL to ignore 3372 * 3373 * Return: %TRUE if the @attribute was successfully set, %FALSE otherwise. 3374 * 3375 * Throws: GException on failure. 3376 */ 3377 public bool setAttributeString(string attribute, string value, GFileQueryInfoFlags flags, Cancellable cancellable) 3378 { 3379 GError* err = null; 3380 3381 auto p = g_file_set_attribute_string(getFileStruct(), Str.toStringz(attribute), Str.toStringz(value), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3382 3383 if (err !is null) 3384 { 3385 throw new GException( new ErrorG(err) ); 3386 } 3387 3388 return p; 3389 } 3390 3391 /** 3392 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT32 to @value. 3393 * If @attribute is of a different type, this operation will fail. 3394 * 3395 * If @cancellable is not %NULL, then the operation can be cancelled by 3396 * triggering the cancellable object from another thread. If the operation 3397 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3398 * 3399 * Params: 3400 * attribute = a string containing the attribute's name 3401 * value = a #guint32 containing the attribute's new value 3402 * flags = a #GFileQueryInfoFlags 3403 * cancellable = optional #GCancellable object, 3404 * %NULL to ignore 3405 * 3406 * Return: %TRUE if the @attribute was successfully set to @value 3407 * in the @file, %FALSE otherwise. 3408 * 3409 * Throws: GException on failure. 3410 */ 3411 public bool setAttributeUint32(string attribute, uint value, GFileQueryInfoFlags flags, Cancellable cancellable) 3412 { 3413 GError* err = null; 3414 3415 auto p = g_file_set_attribute_uint32(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3416 3417 if (err !is null) 3418 { 3419 throw new GException( new ErrorG(err) ); 3420 } 3421 3422 return p; 3423 } 3424 3425 /** 3426 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT64 to @value. 3427 * If @attribute is of a different type, this operation will fail. 3428 * 3429 * If @cancellable is not %NULL, then the operation can be cancelled by 3430 * triggering the cancellable object from another thread. If the operation 3431 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3432 * 3433 * Params: 3434 * attribute = a string containing the attribute's name 3435 * value = a #guint64 containing the attribute's new value 3436 * flags = a #GFileQueryInfoFlags 3437 * cancellable = optional #GCancellable object, 3438 * %NULL to ignore 3439 * 3440 * Return: %TRUE if the @attribute was successfully set to @value 3441 * in the @file, %FALSE otherwise. 3442 * 3443 * Throws: GException on failure. 3444 */ 3445 public bool setAttributeUint64(string attribute, ulong value, GFileQueryInfoFlags flags, Cancellable cancellable) 3446 { 3447 GError* err = null; 3448 3449 auto p = g_file_set_attribute_uint64(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3450 3451 if (err !is null) 3452 { 3453 throw new GException( new ErrorG(err) ); 3454 } 3455 3456 return p; 3457 } 3458 3459 /** 3460 * Asynchronously sets the attributes of @file with @info. 3461 * 3462 * For more details, see g_file_set_attributes_from_info(), 3463 * which is the synchronous version of this call. 3464 * 3465 * When the operation is finished, @callback will be called. 3466 * You can then call g_file_set_attributes_finish() to get 3467 * the result of the operation. 3468 * 3469 * Params: 3470 * info = a #GFileInfo 3471 * flags = a #GFileQueryInfoFlags 3472 * ioPriority = the [I/O priority][io-priority] of the request 3473 * cancellable = optional #GCancellable object, 3474 * %NULL to ignore 3475 * callback = a #GAsyncReadyCallback 3476 * userData = a #gpointer 3477 */ 3478 public void setAttributesAsync(FileInfo info, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3479 { 3480 g_file_set_attributes_async(getFileStruct(), (info is null) ? null : info.getFileInfoStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3481 } 3482 3483 /** 3484 * Finishes setting an attribute started in g_file_set_attributes_async(). 3485 * 3486 * Params: 3487 * result = a #GAsyncResult 3488 * info = a #GFileInfo 3489 * 3490 * Return: %TRUE if the attributes were set correctly, %FALSE otherwise. 3491 * 3492 * Throws: GException on failure. 3493 */ 3494 public bool setAttributesFinish(AsyncResultIF result, out FileInfo info) 3495 { 3496 GFileInfo* outinfo = null; 3497 GError* err = null; 3498 3499 auto p = g_file_set_attributes_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &outinfo, &err) != 0; 3500 3501 if (err !is null) 3502 { 3503 throw new GException( new ErrorG(err) ); 3504 } 3505 3506 info = ObjectG.getDObject!(FileInfo)(outinfo); 3507 3508 return p; 3509 } 3510 3511 /** 3512 * Tries to set all attributes in the #GFileInfo on the target 3513 * values, not stopping on the first error. 3514 * 3515 * If there is any error during this operation then @error will 3516 * be set to the first error. Error on particular fields are flagged 3517 * by setting the "status" field in the attribute value to 3518 * %G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING, which means you can 3519 * also detect further errors. 3520 * 3521 * If @cancellable is not %NULL, then the operation can be cancelled by 3522 * triggering the cancellable object from another thread. If the operation 3523 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3524 * 3525 * Params: 3526 * info = a #GFileInfo 3527 * flags = #GFileQueryInfoFlags 3528 * cancellable = optional #GCancellable object, 3529 * %NULL to ignore 3530 * 3531 * Return: %FALSE if there was any error, %TRUE otherwise. 3532 * 3533 * Throws: GException on failure. 3534 */ 3535 public bool setAttributesFromInfo(FileInfo info, GFileQueryInfoFlags flags, Cancellable cancellable) 3536 { 3537 GError* err = null; 3538 3539 auto p = g_file_set_attributes_from_info(getFileStruct(), (info is null) ? null : info.getFileInfoStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3540 3541 if (err !is null) 3542 { 3543 throw new GException( new ErrorG(err) ); 3544 } 3545 3546 return p; 3547 } 3548 3549 /** 3550 * Renames @file to the specified display name. 3551 * 3552 * The display name is converted from UTF-8 to the correct encoding 3553 * for the target filesystem if possible and the @file is renamed to this. 3554 * 3555 * If you want to implement a rename operation in the user interface the 3556 * edit name (#G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) should be used as the 3557 * initial value in the rename widget, and then the result after editing 3558 * should be passed to g_file_set_display_name(). 3559 * 3560 * On success the resulting converted filename is returned. 3561 * 3562 * If @cancellable is not %NULL, then the operation can be cancelled by 3563 * triggering the cancellable object from another thread. If the operation 3564 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3565 * 3566 * Params: 3567 * displayName = a string 3568 * cancellable = optional #GCancellable object, 3569 * %NULL to ignore 3570 * 3571 * Return: a #GFile specifying what @file was renamed to, 3572 * or %NULL if there was an error. 3573 * Free the returned object with g_object_unref(). 3574 * 3575 * Throws: GException on failure. 3576 */ 3577 public FileIF setDisplayName(string displayName, Cancellable cancellable) 3578 { 3579 GError* err = null; 3580 3581 auto p = g_file_set_display_name(getFileStruct(), Str.toStringz(displayName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 3582 3583 if (err !is null) 3584 { 3585 throw new GException( new ErrorG(err) ); 3586 } 3587 3588 if(p is null) 3589 { 3590 return null; 3591 } 3592 3593 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 3594 } 3595 3596 /** 3597 * Asynchronously sets the display name for a given #GFile. 3598 * 3599 * For more details, see g_file_set_display_name() which is 3600 * the synchronous version of this call. 3601 * 3602 * When the operation is finished, @callback will be called. 3603 * You can then call g_file_set_display_name_finish() to get 3604 * the result of the operation. 3605 * 3606 * Params: 3607 * displayName = a string 3608 * ioPriority = the [I/O priority][io-priority] of the request 3609 * cancellable = optional #GCancellable object, 3610 * %NULL to ignore 3611 * callback = a #GAsyncReadyCallback to call 3612 * when the request is satisfied 3613 * userData = the data to pass to callback function 3614 */ 3615 public void setDisplayNameAsync(string displayName, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3616 { 3617 g_file_set_display_name_async(getFileStruct(), Str.toStringz(displayName), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3618 } 3619 3620 /** 3621 * Finishes setting a display name started with 3622 * g_file_set_display_name_async(). 3623 * 3624 * Params: 3625 * res = a #GAsyncResult 3626 * 3627 * Return: a #GFile or %NULL on error. 3628 * Free the returned object with g_object_unref(). 3629 * 3630 * Throws: GException on failure. 3631 */ 3632 public FileIF setDisplayNameFinish(AsyncResultIF res) 3633 { 3634 GError* err = null; 3635 3636 auto p = g_file_set_display_name_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3637 3638 if (err !is null) 3639 { 3640 throw new GException( new ErrorG(err) ); 3641 } 3642 3643 if(p is null) 3644 { 3645 return null; 3646 } 3647 3648 return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true); 3649 } 3650 3651 /** 3652 * Starts a file of type #G_FILE_TYPE_MOUNTABLE. 3653 * Using @start_operation, you can request callbacks when, for instance, 3654 * passwords are needed during authentication. 3655 * 3656 * If @cancellable is not %NULL, then the operation can be cancelled by 3657 * triggering the cancellable object from another thread. If the operation 3658 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3659 * 3660 * When the operation is finished, @callback will be called. 3661 * You can then call g_file_mount_mountable_finish() to get 3662 * the result of the operation. 3663 * 3664 * Params: 3665 * flags = flags affecting the operation 3666 * startOperation = a #GMountOperation, or %NULL to avoid user interaction 3667 * cancellable = optional #GCancellable object, %NULL to ignore 3668 * callback = a #GAsyncReadyCallback to call when the request is satisfied, or %NULL 3669 * userData = the data to pass to callback function 3670 * 3671 * Since: 2.22 3672 */ 3673 public void startMountable(GDriveStartFlags flags, MountOperation startOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3674 { 3675 g_file_start_mountable(getFileStruct(), flags, (startOperation is null) ? null : startOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3676 } 3677 3678 /** 3679 * Finishes a start operation. See g_file_start_mountable() for details. 3680 * 3681 * Finish an asynchronous start operation that was started 3682 * with g_file_start_mountable(). 3683 * 3684 * Params: 3685 * result = a #GAsyncResult 3686 * 3687 * Return: %TRUE if the operation finished successfully. %FALSE 3688 * otherwise. 3689 * 3690 * Since: 2.22 3691 * 3692 * Throws: GException on failure. 3693 */ 3694 public bool startMountableFinish(AsyncResultIF result) 3695 { 3696 GError* err = null; 3697 3698 auto p = g_file_start_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3699 3700 if (err !is null) 3701 { 3702 throw new GException( new ErrorG(err) ); 3703 } 3704 3705 return p; 3706 } 3707 3708 /** 3709 * Stops a file of type #G_FILE_TYPE_MOUNTABLE. 3710 * 3711 * If @cancellable is not %NULL, then the operation can be cancelled by 3712 * triggering the cancellable object from another thread. If the operation 3713 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3714 * 3715 * When the operation is finished, @callback will be called. 3716 * You can then call g_file_stop_mountable_finish() to get 3717 * the result of the operation. 3718 * 3719 * Params: 3720 * flags = flags affecting the operation 3721 * mountOperation = a #GMountOperation, 3722 * or %NULL to avoid user interaction. 3723 * cancellable = optional #GCancellable object, 3724 * %NULL to ignore 3725 * callback = a #GAsyncReadyCallback to call 3726 * when the request is satisfied, or %NULL 3727 * userData = the data to pass to callback function 3728 * 3729 * Since: 2.22 3730 */ 3731 public void stopMountable(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3732 { 3733 g_file_stop_mountable(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3734 } 3735 3736 /** 3737 * Finishes an stop operation, see g_file_stop_mountable() for details. 3738 * 3739 * Finish an asynchronous stop operation that was started 3740 * with g_file_stop_mountable(). 3741 * 3742 * Params: 3743 * result = a #GAsyncResult 3744 * 3745 * Return: %TRUE if the operation finished successfully. 3746 * %FALSE otherwise. 3747 * 3748 * Since: 2.22 3749 * 3750 * Throws: GException on failure. 3751 */ 3752 public bool stopMountableFinish(AsyncResultIF result) 3753 { 3754 GError* err = null; 3755 3756 auto p = g_file_stop_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3757 3758 if (err !is null) 3759 { 3760 throw new GException( new ErrorG(err) ); 3761 } 3762 3763 return p; 3764 } 3765 3766 /** 3767 * Checks if @file supports 3768 * [thread-default contexts][g-main-context-push-thread-default-context]. 3769 * If this returns %FALSE, you cannot perform asynchronous operations on 3770 * @file in a thread that has a thread-default context. 3771 * 3772 * Return: Whether or not @file supports thread-default contexts. 3773 * 3774 * Since: 2.22 3775 */ 3776 public bool supportsThreadContexts() 3777 { 3778 return g_file_supports_thread_contexts(getFileStruct()) != 0; 3779 } 3780 3781 /** 3782 * Sends @file to the "Trashcan", if possible. This is similar to 3783 * deleting it, but the user can recover it before emptying the trashcan. 3784 * Not all file systems support trashing, so this call can return the 3785 * %G_IO_ERROR_NOT_SUPPORTED error. 3786 * 3787 * If @cancellable is not %NULL, then the operation can be cancelled by 3788 * triggering the cancellable object from another thread. If the operation 3789 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3790 * 3791 * Params: 3792 * cancellable = optional #GCancellable object, 3793 * %NULL to ignore 3794 * 3795 * Return: %TRUE on successful trash, %FALSE otherwise. 3796 * 3797 * Throws: GException on failure. 3798 */ 3799 public bool trash(Cancellable cancellable) 3800 { 3801 GError* err = null; 3802 3803 auto p = g_file_trash(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3804 3805 if (err !is null) 3806 { 3807 throw new GException( new ErrorG(err) ); 3808 } 3809 3810 return p; 3811 } 3812 3813 /** 3814 * Asynchronously sends @file to the Trash location, if possible. 3815 * 3816 * Params: 3817 * ioPriority = the [I/O priority][io-priority] of the request 3818 * cancellable = optional #GCancellable object, 3819 * %NULL to ignore 3820 * callback = a #GAsyncReadyCallback to call 3821 * when the request is satisfied 3822 * userData = the data to pass to callback function 3823 * 3824 * Since: 2.38 3825 */ 3826 public void trashAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3827 { 3828 g_file_trash_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3829 } 3830 3831 /** 3832 * Finishes an asynchronous file trashing operation, started with 3833 * g_file_trash_async(). 3834 * 3835 * Params: 3836 * result = a #GAsyncResult 3837 * 3838 * Return: %TRUE on successful trash, %FALSE otherwise. 3839 * 3840 * Since: 2.38 3841 * 3842 * Throws: GException on failure. 3843 */ 3844 public bool trashFinish(AsyncResultIF result) 3845 { 3846 GError* err = null; 3847 3848 auto p = g_file_trash_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3849 3850 if (err !is null) 3851 { 3852 throw new GException( new ErrorG(err) ); 3853 } 3854 3855 return p; 3856 } 3857 3858 /** 3859 * Unmounts a file of type G_FILE_TYPE_MOUNTABLE. 3860 * 3861 * If @cancellable is not %NULL, then the operation can be cancelled by 3862 * triggering the cancellable object from another thread. If the operation 3863 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3864 * 3865 * When the operation is finished, @callback will be called. 3866 * You can then call g_file_unmount_mountable_finish() to get 3867 * the result of the operation. 3868 * 3869 * Deprecated: Use g_file_unmount_mountable_with_operation() instead. 3870 * 3871 * Params: 3872 * flags = flags affecting the operation 3873 * cancellable = optional #GCancellable object, 3874 * %NULL to ignore 3875 * callback = a #GAsyncReadyCallback to call 3876 * when the request is satisfied, or %NULL 3877 * userData = the data to pass to callback function 3878 */ 3879 public void unmountMountable(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3880 { 3881 g_file_unmount_mountable(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3882 } 3883 3884 /** 3885 * Finishes an unmount operation, see g_file_unmount_mountable() for details. 3886 * 3887 * Finish an asynchronous unmount operation that was started 3888 * with g_file_unmount_mountable(). 3889 * 3890 * Deprecated: Use g_file_unmount_mountable_with_operation_finish() 3891 * instead. 3892 * 3893 * Params: 3894 * result = a #GAsyncResult 3895 * 3896 * Return: %TRUE if the operation finished successfully. 3897 * %FALSE otherwise. 3898 * 3899 * Throws: GException on failure. 3900 */ 3901 public bool unmountMountableFinish(AsyncResultIF result) 3902 { 3903 GError* err = null; 3904 3905 auto p = g_file_unmount_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3906 3907 if (err !is null) 3908 { 3909 throw new GException( new ErrorG(err) ); 3910 } 3911 3912 return p; 3913 } 3914 3915 /** 3916 * Unmounts a file of type #G_FILE_TYPE_MOUNTABLE. 3917 * 3918 * If @cancellable is not %NULL, then the operation can be cancelled by 3919 * triggering the cancellable object from another thread. If the operation 3920 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3921 * 3922 * When the operation is finished, @callback will be called. 3923 * You can then call g_file_unmount_mountable_finish() to get 3924 * the result of the operation. 3925 * 3926 * Params: 3927 * flags = flags affecting the operation 3928 * mountOperation = a #GMountOperation, 3929 * or %NULL to avoid user interaction 3930 * cancellable = optional #GCancellable object, 3931 * %NULL to ignore 3932 * callback = a #GAsyncReadyCallback to call 3933 * when the request is satisfied, or %NULL 3934 * userData = the data to pass to callback function 3935 * 3936 * Since: 2.22 3937 */ 3938 public void unmountMountableWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3939 { 3940 g_file_unmount_mountable_with_operation(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3941 } 3942 3943 /** 3944 * Finishes an unmount operation, 3945 * see g_file_unmount_mountable_with_operation() for details. 3946 * 3947 * Finish an asynchronous unmount operation that was started 3948 * with g_file_unmount_mountable_with_operation(). 3949 * 3950 * Params: 3951 * result = a #GAsyncResult 3952 * 3953 * Return: %TRUE if the operation finished successfully. 3954 * %FALSE otherwise. 3955 * 3956 * Since: 2.22 3957 * 3958 * Throws: GException on failure. 3959 */ 3960 public bool unmountMountableWithOperationFinish(AsyncResultIF result) 3961 { 3962 GError* err = null; 3963 3964 auto p = g_file_unmount_mountable_with_operation_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3965 3966 if (err !is null) 3967 { 3968 throw new GException( new ErrorG(err) ); 3969 } 3970 3971 return p; 3972 } 3973 }