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