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