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