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