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