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