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