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