Bug 536252 – GFileEnumerator should allow access to the containing GFile
[platform/upstream/glib.git] / gio / gfile.h
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
25 #endif
26
27 #ifndef __G_FILE_H__
28 #define __G_FILE_H__
29
30 #include <glib-object.h>
31 #include <gio/gfileinfo.h>
32 #include <gio/gfileenumerator.h>
33 #include <gio/gfileinputstream.h>
34 #include <gio/gfileoutputstream.h>
35 #include <gio/gmountoperation.h>
36 #include <gio/gappinfo.h>
37
38 G_BEGIN_DECLS
39
40 #define G_TYPE_FILE            (g_file_get_type ())
41 #define G_FILE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_FILE, GFile))
42 #define G_IS_FILE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_FILE))
43 #define G_FILE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_FILE, GFileIface))
44
45 /**
46  * GFileQueryInfoFlags:
47  * @G_FILE_QUERY_INFO_NONE: No flags set.
48  * @G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS: Don't follow symlinks.
49  * 
50  * Flags used when querying a #GFileInfo.
51  */
52 typedef enum {
53   G_FILE_QUERY_INFO_NONE = 0,
54   G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS = (1<<0)   /*< nick=nofollow-symlinks >*/
55 } GFileQueryInfoFlags;
56
57 /**
58  * GFileCreateFlags:
59  * @G_FILE_CREATE_NONE: No flags set.
60  * @G_FILE_CREATE_PRIVATE: Create a file that can only be 
61  *    accessed by the current user.
62  * 
63  * Flags used when an operation may create a file.
64  */
65 typedef enum  {
66   G_FILE_CREATE_NONE = 0,
67   G_FILE_CREATE_PRIVATE = (1<<0)
68 } GFileCreateFlags;
69
70
71 /**
72  * GMountMountFlags:
73  * @G_MOUNT_MOUNT_NONE: No flags set.
74  * 
75  * Flags used when mounting a mount.
76  */
77 typedef enum  {
78   G_MOUNT_MOUNT_NONE = 0
79 } GMountMountFlags;
80
81
82 /**
83  * GMountUnmountFlags:
84  * @G_MOUNT_UNMOUNT_NONE: No flags set.
85  * @G_MOUNT_UNMOUNT_FORCE: Unmount even if there are outstanding
86  *  file operations on the mount.
87  * 
88  * Flags used when an unmounting a mount.
89  */
90 typedef enum  {
91   G_MOUNT_UNMOUNT_NONE = 0,
92   G_MOUNT_UNMOUNT_FORCE = (1<<0)
93 } GMountUnmountFlags;
94
95 /**
96  * GFileCopyFlags:
97  * @G_FILE_COPY_NONE: No flags set.
98  * @G_FILE_COPY_OVERWRITE: Overwrite any existing files
99  * @G_FILE_COPY_BACKUP: Make a backup of any existing files.
100  * @G_FILE_COPY_NOFOLLOW_SYMLINKS: Don't follow symlinks.
101  * @G_FILE_COPY_ALL_METADATA: Copy all file metadata instead of just default set used for copy (see #GFileInfo).
102  * @G_FILE_COPY_NO_FALLBACK_FOR_MOVE: Don't use copy and delete fallback if native move not supported.
103  *
104  * Flags used when copying or moving files. 
105  */
106 typedef enum {
107   G_FILE_COPY_NONE = 0,          /*< nick=none >*/
108   G_FILE_COPY_OVERWRITE = (1<<0),
109   G_FILE_COPY_BACKUP = (1<<1),
110   G_FILE_COPY_NOFOLLOW_SYMLINKS = (1<<2),
111   G_FILE_COPY_ALL_METADATA = (1<<3),
112   G_FILE_COPY_NO_FALLBACK_FOR_MOVE = (1<<4)
113 } GFileCopyFlags;
114
115 /**
116  * GFileMonitorFlags:
117  * @G_FILE_MONITOR_NONE: No flags set.
118  * @G_FILE_MONITOR_WATCH_MOUNTS: Watch for mount events. 
119  *
120  * Flags used to set what a #GFileMonitor will watch for. 
121  */
122 typedef enum  {
123   G_FILE_MONITOR_NONE = 0,
124   G_FILE_MONITOR_WATCH_MOUNTS = (1<<0)
125 } GFileMonitorFlags;
126
127 #if 0
128 /**
129  * GFile:
130  * 
131  * A handle to an object implementing the #GFileIface interface. 
132  * Generally stores a location within the file system. Handles do not 
133  * necessarily represent files or directories that currently exist.
134  **/
135 typedef struct _GFile                   GFile; /* Dummy typedef */
136 #endif
137 typedef struct _GFileIface              GFileIface;
138 typedef struct _GFileMonitor            GFileMonitor;
139
140 /**
141  * GMount:
142  * 
143  * A handle to an object implementing the #GMountIface interface.
144  **/
145 typedef struct _GMount         GMount; /* Dummy typedef */
146
147 /**
148  * GFileProgressCallback:
149  * @current_num_bytes: the current number of bytes in the operation.
150  * @total_num_bytes: the total number of bytes in the operation.
151  * @user_data: user data passed to the callback.
152  *
153  * When doing file operations that may take a while, such as moving 
154  * a file or copying a file, a progress callback is used to pass how 
155  * far along that operation is to the application. 
156  **/
157 typedef void (*GFileProgressCallback) (goffset current_num_bytes,
158                                        goffset total_num_bytes,
159                                        gpointer user_data);
160
161 /**
162  * GFileReadMoreCallback:
163  * @file_contents: the data as currently read.
164  * @file_size: the size of the data currently read.
165  * @callback_data: data passed to the callback.
166  *
167  * When loading the partial contents of a file with g_file_read_partial_contents(), 
168  * it may become necessary to determine if any more data from the file should be loaded. 
169  * A #GFileReadMoreCallback function facilitates this by returning %TRUE if more data 
170  * should be read, or %FALSE otherwise.
171  *
172  * Returns: %TRUE if more data should be read back. %FALSE otherwise.
173  **/
174 typedef gboolean (* GFileReadMoreCallback) (const char *file_contents,
175                                             goffset file_size,
176                                             gpointer callback_data);
177
178 /**
179  * GFileIface:
180  * @g_iface: The parent interface.
181  * @dup: Duplicates a #GFile.
182  * @hash: Creates a hash of a #GFile.
183  * @equal: Checks equality of two given #GFile<!-- -->s.
184  * @is_native: Checks to see if a file is native to the system.
185  * @has_uri_scheme: Checks to see if a #GFile has a given URI scheme.
186  * @get_uri_scheme: Gets the URI scheme for a #GFile.
187  * @get_basename: Gets the basename for a given #GFile.
188  * @get_path: Gets the current path within a #GFile. 
189  * @get_uri: Gets a URI for the path within a #GFile.
190  * @get_parse_name: Gets the parsed name for the #GFile.
191  * @get_parent: Gets the parent directory for the #GFile.
192  * @prefix_matches: Checks whether a #GFile contains a specified file.
193  * @get_relative_path: Gets the path for a #GFile relative to a given path.
194  * @resolve_relative_path: Resolves a relative path for a #GFile to an absolute path.
195  * @get_child_for_display_name: Gets the child #GFile for a given display name.
196  * @enumerate_children: Gets a #GFileEnumerator with the children of a #GFile.
197  * @enumerate_children_async: Asynchronously gets a #GFileEnumerator with the children of a #GFile.
198  * @enumerate_children_finish: Finishes asynchronously enumerating the children.
199  * @query_info: Gets the #GFileInfo for a #GFile.
200  * @query_info_async: Asynchronously gets the #GFileInfo for a #GFile.
201  * @query_info_finish: Finishes an asynchronous query info operation.
202  * @query_filesystem_info: Gets a #GFileInfo for the file system #GFile is on.
203  * @query_filesystem_info_async: Asynchronously gets a #GFileInfo for the file system #GFile is on.
204  * @query_filesystem_info_finish: Finishes asynchronously getting the file system info.
205  * @find_enclosing_mount: Gets a #GMount for the #GFile.
206  * @find_enclosing_mount_async: Asynchronously gets the #GMount for a #GFile.
207  * @find_enclosing_mount_finish: Finishes asynchronously getting the volume.
208  * @set_display_name: Sets the display name for a #GFile.
209  * @set_display_name_async: Asynchronously sets a #GFile's display name.
210  * @set_display_name_finish: Finishes asynchronously setting a #GFile's display name.
211  * @query_settable_attributes: Returns a list of #GFileAttribute<!-- -->s that can be set.
212  * @_query_settable_attributes_async: Asynchronously gets a list of #GFileAttribute<!-- -->s that can be set.
213  * @_query_settable_attributes_finish: Finishes asynchronously querying settable attributes.
214  * @query_writable_namespaces: Returns a list of #GFileAttribute namespaces that are writable.
215  * @_query_writable_namespaces_async: Asynchronously gets a list of #GFileAttribute namespaces that are writable.
216  * @_query_writable_namespaces_finish: Finishes asynchronously querying the writable namespaces.
217  * @set_attribute: Sets a #GFileAttribute.
218  * @set_attributes_from_info: Sets a #GFileAttribute with information from a #GFileInfo.
219  * @set_attributes_async: Asynchronously sets a file's attributes.
220  * @set_attributes_finish: Finishes setting a file's attributes asynchronously.
221  * @read_fn: Reads a file asynchronously.
222  * @read_async: Asynchronously reads a file.
223  * @read_finish: Finishes asynchronously reading a file.
224  * @append_to: Writes to the end of a file.
225  * @append_to_async: Asynchronously writes to the end of a file.
226  * @append_to_finish: Finishes an asynchronous file append operation.
227  * @create: Creates a new file.
228  * @create_async: Asynchronously creates a file.
229  * @create_finish: Finishes asynchronously creating a file.
230  * @replace: Replaces the contents of a file.
231  * @replace_async: Asynchronously replaces the contents of a file.
232  * @replace_finish: Finishes asynchronously replacing a file.
233  * @delete_file: Deletes a file.
234  * @_delete_file_async: Asynchronously deletes a file.
235  * @_delete_file_finish: Finishes an asynchronous delete.
236  * @trash: Sends a #GFile to the Trash location.
237  * @_trash_async: Asynchronously sends a #GFile to the Trash location.
238  * @_trash_finish: Finishes an asynchronous file trashing operation.
239  * @make_directory: Makes a directory.
240  * @_make_directory_async: Asynchronously makes a directory.
241  * @_make_directory_finish: Finishes making a directory asynchronously.
242  * @make_symbolic_link: Makes a symbolic link.
243  * @_make_symbolic_link_async: Asynchronously makes a symbolic link
244  * @_make_symbolic_link_finish: Finishes making a symbolic link asynchronously.
245  * @copy: Copies a file.
246  * @copy_async: Asynchronously copies a file.
247  * @copy_finish: Finishes an asynchronous copy operation.
248  * @move: Moves a file.
249  * @_move_async: Asynchronously moves a file. 
250  * @_move_finish: Finishes an asynchronous move operation.
251  * @mount_mountable: Mounts a mountable object.
252  * @mount_mountable_finish: Finishes a mounting operation.
253  * @unmount_mountable: Unmounts a mountable object.
254  * @unmount_mountable_finish: Finishes an unmount operation.
255  * @eject_mountable: Ejects a mountable.
256  * @eject_mountable_finish: Finishes an eject operation.
257  * @mount_enclosing_volume: Mounts a specified location. 
258  * @mount_enclosing_volume_finish: Finishes mounting a specified location.
259  * @monitor_dir: Creates a #GFileMonitor for the location.
260  * @monitor_file: Creates a #GFileMonitor for the location.
261  * 
262  * An interface for writing VFS file handles.  
263  **/ 
264 struct _GFileIface
265 {
266   GTypeInterface g_iface;
267
268   /* Virtual Table */
269
270   GFile *             (*dup)                        (GFile         *file);
271   guint               (*hash)                       (GFile         *file);
272   gboolean            (*equal)                      (GFile         *file1,
273                                                      GFile         *file2);
274   gboolean            (*is_native)                  (GFile         *file);
275   gboolean            (*has_uri_scheme)             (GFile         *file,
276                                                      const char    *uri_scheme);
277   char *              (*get_uri_scheme)             (GFile         *file);
278   char *              (*get_basename)               (GFile         *file);
279   char *              (*get_path)                   (GFile         *file);
280   char *              (*get_uri)                    (GFile         *file);
281   char *              (*get_parse_name)             (GFile         *file);
282   GFile *             (*get_parent)                 (GFile         *file);
283   gboolean            (*prefix_matches)             (GFile         *prefix,
284                                                      GFile         *file);
285   char *              (*get_relative_path)          (GFile         *parent,
286                                                      GFile         *descendant);
287   GFile *             (*resolve_relative_path)      (GFile        *file,
288                                                      const char   *relative_path);
289   GFile *             (*get_child_for_display_name) (GFile        *file,
290                                                      const char   *display_name,
291                                                      GError      **error);
292   
293   GFileEnumerator *   (*enumerate_children)        (GFile                *file,
294                                                     const char           *attributes,
295                                                     GFileQueryInfoFlags   flags,
296                                                     GCancellable         *cancellable,
297                                                     GError              **error);
298   void                (*enumerate_children_async)  (GFile                      *file,
299                                                     const char                 *attributes,
300                                                     GFileQueryInfoFlags         flags,
301                                                     int                         io_priority,
302                                                     GCancellable               *cancellable,
303                                                     GAsyncReadyCallback         callback,
304                                                     gpointer                    user_data);
305   GFileEnumerator *   (*enumerate_children_finish) (GFile                      *file,
306                                                     GAsyncResult               *res,
307                                                     GError                    **error);
308   
309   GFileInfo *         (*query_info)         (GFile                *file,
310                                              const char           *attributes,
311                                              GFileQueryInfoFlags   flags,
312                                              GCancellable         *cancellable,
313                                              GError              **error);
314   void                (*query_info_async)   (GFile                *file,
315                                              const char           *attributes,
316                                              GFileQueryInfoFlags   flags,
317                                              int                   io_priority,
318                                              GCancellable         *cancellable,
319                                              GAsyncReadyCallback   callback,
320                                              gpointer              user_data);
321   GFileInfo *         (*query_info_finish)  (GFile                *file,
322                                              GAsyncResult         *res,
323                                              GError              **error);
324   
325   GFileInfo *         (*query_filesystem_info)(GFile                *file,
326                                              const char           *attributes,
327                                              GCancellable         *cancellable,
328                                              GError              **error);
329   void                (*query_filesystem_info_async) (GFile                *file,
330                                                       const char           *attributes,
331                                                       int                   io_priority,
332                                                       GCancellable         *cancellable,
333                                                       GAsyncReadyCallback   callback,
334                                                       gpointer              user_data);
335   GFileInfo *         (*query_filesystem_info_finish) (GFile                *file,
336                                                        GAsyncResult         *res,
337                                                        GError              **error);
338   
339   GMount *            (*find_enclosing_mount)(GFile              *file,
340                                                GCancellable       *cancellable,
341                                                GError            **error);
342   void                (*find_enclosing_mount_async)(GFile              *file,
343                                                     int                   io_priority,
344                                                     GCancellable         *cancellable,
345                                                     GAsyncReadyCallback   callback,
346                                                     gpointer              user_data);
347   GMount *            (*find_enclosing_mount_finish)(GFile              *file,
348                                                      GAsyncResult         *res,
349                                                      GError            **error);
350   
351   GFile *             (*set_display_name)         (GFile                *file,
352                                                    const char           *display_name,
353                                                    GCancellable         *cancellable,
354                                                    GError              **error);
355   void                (*set_display_name_async)   (GFile                      *file,
356                                                    const char                 *display_name,
357                                                    int                         io_priority,
358                                                    GCancellable               *cancellable,
359                                                    GAsyncReadyCallback         callback,
360                                                    gpointer                    user_data);
361   GFile *              (*set_display_name_finish) (GFile                      *file,
362                                                    GAsyncResult               *res,
363                                                    GError                    **error);
364   
365   GFileAttributeInfoList * (*query_settable_attributes) (GFile        *file,
366                                                          GCancellable *cancellable,
367                                                          GError      **error);
368   void                (*_query_settable_attributes_async) (void);
369   void                (*_query_settable_attributes_finish) (void);
370   
371   GFileAttributeInfoList * (*query_writable_namespaces) (GFile        *file,
372                                                          GCancellable *cancellable,
373                                                          GError      **error);
374   void                (*_query_writable_namespaces_async) (void);
375   void                (*_query_writable_namespaces_finish) (void);
376   
377   gboolean            (*set_attribute)            (GFile                *file,
378                                                    const char           *attribute,
379                                                    GFileAttributeType    type,
380                                                    gpointer              value_p,
381                                                    GFileQueryInfoFlags   flags,
382                                                    GCancellable         *cancellable,
383                                                    GError              **error);
384   gboolean            (*set_attributes_from_info) (GFile          *file,
385                                                    GFileInfo            *info,
386                                                    GFileQueryInfoFlags   flags,
387                                                    GCancellable         *cancellable,
388                                                    GError              **error);
389   void                (*set_attributes_async)     (GFile                      *file,
390                                                    GFileInfo                  *info,
391                                                    GFileQueryInfoFlags        flags,
392                                                    int                         io_priority,
393                                                    GCancellable               *cancellable,
394                                                    GAsyncReadyCallback         callback,
395                                                    gpointer                    user_data);
396   gboolean            (*set_attributes_finish)    (GFile                      *file,
397                                                    GAsyncResult               *result,
398                                                    GFileInfo                 **info,
399                                                    GError                    **error);
400   
401   GFileInputStream *  (*read_fn)            (GFile                *file,
402                                              GCancellable         *cancellable,
403                                              GError              **error);
404   void                (*read_async)         (GFile                *file,
405                                              int                   io_priority,
406                                              GCancellable         *cancellable,
407                                              GAsyncReadyCallback   callback,
408                                              gpointer              user_data);
409   GFileInputStream *  (*read_finish)        (GFile                *file,
410                                              GAsyncResult         *res,
411                                              GError              **error);
412   
413   GFileOutputStream * (*append_to)          (GFile                *file,
414                                              GFileCreateFlags      flags,
415                                              GCancellable         *cancellable,
416                                              GError               **error);
417   void                 (*append_to_async)   (GFile                      *file,
418                                              GFileCreateFlags            flags,
419                                              int                         io_priority,
420                                              GCancellable               *cancellable,
421                                              GAsyncReadyCallback         callback,
422                                              gpointer                    user_data);
423   GFileOutputStream *  (*append_to_finish)  (GFile                      *file,
424                                              GAsyncResult               *res,
425                                              GError                    **error);
426   
427   GFileOutputStream *  (*create)            (GFile                *file,
428                                              GFileCreateFlags      flags,
429                                              GCancellable         *cancellable,
430                                              GError               **error);
431   void                 (*create_async)      (GFile                      *file,
432                                              GFileCreateFlags            flags,
433                                              int                         io_priority,
434                                              GCancellable               *cancellable,
435                                              GAsyncReadyCallback         callback,
436                                              gpointer                    user_data);
437   GFileOutputStream *  (*create_finish)     (GFile                      *file,
438                                              GAsyncResult               *res,
439                                              GError                    **error);
440   
441   GFileOutputStream *  (*replace)           (GFile                *file,
442                                              const char           *etag,
443                                              gboolean              make_backup,
444                                              GFileCreateFlags      flags,
445                                              GCancellable         *cancellable,
446                                              GError              **error);
447   void                 (*replace_async)     (GFile                      *file,
448                                              const char                 *etag,
449                                              gboolean                    make_backup,
450                                              GFileCreateFlags            flags,
451                                              int                         io_priority,
452                                              GCancellable               *cancellable,
453                                              GAsyncReadyCallback         callback,
454                                              gpointer                    user_data);
455   GFileOutputStream *  (*replace_finish)    (GFile                      *file,
456                                              GAsyncResult               *res,
457                                              GError                    **error);
458   
459   gboolean            (*delete_file)        (GFile                *file,
460                                              GCancellable         *cancellable,
461                                              GError              **error);
462   void                (*_delete_file_async) (void);
463   void                (*_delete_file_finish) (void);
464   
465   gboolean            (*trash)              (GFile                *file,
466                                              GCancellable         *cancellable,
467                                              GError              **error);
468   void                (*_trash_async) (void);
469   void                (*_trash_finish) (void);
470   
471   gboolean            (*make_directory)     (GFile                *file,
472                                              GCancellable         *cancellable,
473                                              GError              **error);
474   void                (*_make_directory_async) (void);
475   void                (*_make_directory_finish) (void);
476   
477   gboolean            (*make_symbolic_link) (GFile                *file,
478                                              const char           *symlink_value,
479                                              GCancellable         *cancellable,
480                                              GError              **error);
481   void                (*_make_symbolic_link_async) (void);
482   void                (*_make_symbolic_link_finish) (void);
483   
484   gboolean            (*copy)               (GFile                *source,
485                                              GFile                *destination,
486                                              GFileCopyFlags        flags,
487                                              GCancellable         *cancellable,
488                                              GFileProgressCallback progress_callback,
489                                              gpointer              progress_callback_data,
490                                              GError              **error);
491   void                (*copy_async)         (GFile                  *source,
492                                              GFile                  *destination,
493                                              GFileCopyFlags          flags,
494                                              int                     io_priority,
495                                              GCancellable           *cancellable,
496                                              GFileProgressCallback   progress_callback,
497                                              gpointer                progress_callback_data,
498                                              GAsyncReadyCallback     callback,
499                                              gpointer                user_data);
500   gboolean            (*copy_finish)        (GFile                  *file,
501                                              GAsyncResult           *res,
502                                              GError                **error);
503   
504   gboolean            (*move)               (GFile                *source,
505                                              GFile                *destination,
506                                              GFileCopyFlags        flags,
507                                              GCancellable         *cancellable,
508                                              GFileProgressCallback progress_callback,
509                                              gpointer              progress_callback_data,
510                                              GError              **error);
511
512   void                (*_move_async) (void);
513   void                (*_move_finish) (void);
514
515
516   void                (*mount_mountable)           (GFile               *file,
517                                                     GMountMountFlags     flags,
518                                                     GMountOperation     *mount_operation,
519                                                     GCancellable         *cancellable,
520                                                     GAsyncReadyCallback  callback,
521                                                     gpointer             user_data);
522   GFile *             (*mount_mountable_finish)    (GFile               *file,
523                                                     GAsyncResult        *result,
524                                                     GError             **error);
525   void                (*unmount_mountable)         (GFile               *file,
526                                                     GMountUnmountFlags   flags,
527                                                     GCancellable         *cancellable,
528                                                     GAsyncReadyCallback  callback,
529                                                     gpointer             user_data);
530   gboolean            (*unmount_mountable_finish)  (GFile               *file,
531                                                     GAsyncResult        *result,
532                                                     GError             **error);
533   void                (*eject_mountable)           (GFile               *file,
534                                                     GMountUnmountFlags   flags,
535                                                     GCancellable        *cancellable,
536                                                     GAsyncReadyCallback  callback,
537                                                     gpointer             user_data);
538   gboolean            (*eject_mountable_finish)    (GFile               *file,
539                                                     GAsyncResult        *result,
540                                                     GError             **error);
541
542
543   void     (*mount_enclosing_volume)        (GFile *location,
544                                              GMountMountFlags flags,
545                                              GMountOperation *mount_operation,
546                                              GCancellable *cancellable,
547                                              GAsyncReadyCallback callback,
548                                              gpointer user_data);
549   gboolean (*mount_enclosing_volume_finish) (GFile *location,
550                                              GAsyncResult *result,
551                                              GError **error);
552   
553   GFileMonitor*      (*monitor_dir)         (GFile                  *file,
554                                              GFileMonitorFlags       flags,
555                                              GCancellable           *cancellable,
556                                              GError                **error);
557
558   GFileMonitor*      (*monitor_file)        (GFile                  *file,
559                                              GFileMonitorFlags       flags,
560                                              GCancellable           *cancellable,
561                                              GError                **error);
562
563 };
564
565 GType g_file_get_type (void) G_GNUC_CONST;
566
567 GFile *                 g_file_new_for_path               (const char                 *path);
568 GFile *                 g_file_new_for_uri                (const char                 *uri);
569 GFile *                 g_file_new_for_commandline_arg    (const char                 *arg);
570 GFile *                 g_file_parse_name                 (const char                 *parse_name);
571 GFile *                 g_file_dup                        (GFile                      *file);
572 guint                   g_file_hash                       (gconstpointer               file);
573 gboolean                g_file_equal                      (GFile                      *file1,
574                                                            GFile                      *file2);
575 char *                  g_file_get_basename               (GFile                      *file);
576 char *                  g_file_get_path                   (GFile                      *file);
577 char *                  g_file_get_uri                    (GFile                      *file);
578 char *                  g_file_get_parse_name             (GFile                      *file);
579 GFile *                 g_file_get_parent                 (GFile                      *file);
580 GFile *                 g_file_get_child                  (GFile                      *file,
581                                                            const char                 *name);
582 GFile *                 g_file_get_child_for_display_name (GFile                      *file,
583                                                            const char                 *display_name,
584                                                            GError                    **error);
585 gboolean                g_file_has_prefix                 (GFile                      *file,
586                                                            GFile                      *prefix);
587 char *                  g_file_get_relative_path          (GFile                      *parent,
588                                                            GFile                      *descendant);
589 GFile *                 g_file_resolve_relative_path      (GFile                      *file,
590                                                            const char                 *relative_path);
591 gboolean                g_file_is_native                  (GFile                      *file);
592 gboolean                g_file_has_uri_scheme             (GFile                      *file,
593                                                            const char                 *uri_scheme);
594 char *                  g_file_get_uri_scheme             (GFile                      *file);
595 GFileInputStream *      g_file_read                       (GFile                      *file,
596                                                            GCancellable               *cancellable,
597                                                            GError                    **error);
598 void                    g_file_read_async                 (GFile                      *file,
599                                                            int                         io_priority,
600                                                            GCancellable               *cancellable,
601                                                            GAsyncReadyCallback         callback,
602                                                            gpointer                    user_data);
603 GFileInputStream *      g_file_read_finish                (GFile                      *file,
604                                                            GAsyncResult               *res,
605                                                            GError                    **error);
606 GFileOutputStream *     g_file_append_to                  (GFile                      *file,
607                                                            GFileCreateFlags             flags,
608                                                            GCancellable               *cancellable,
609                                                            GError                    **error);
610 GFileOutputStream *     g_file_create                     (GFile                      *file,
611                                                            GFileCreateFlags             flags,
612                                                            GCancellable               *cancellable,
613                                                            GError                    **error);
614 GFileOutputStream *     g_file_replace                    (GFile                      *file,
615                                                            const char                 *etag,
616                                                            gboolean                    make_backup,
617                                                            GFileCreateFlags            flags,
618                                                            GCancellable               *cancellable,
619                                                            GError                    **error);
620 void                    g_file_append_to_async            (GFile                      *file,
621                                                            GFileCreateFlags            flags,
622                                                            int                         io_priority,
623                                                            GCancellable               *cancellable,
624                                                            GAsyncReadyCallback         callback,
625                                                            gpointer                    user_data);
626 GFileOutputStream *     g_file_append_to_finish           (GFile                      *file,
627                                                            GAsyncResult               *res,
628                                                            GError                    **error);
629 void                    g_file_create_async               (GFile                      *file,
630                                                            GFileCreateFlags            flags,
631                                                            int                         io_priority,
632                                                            GCancellable               *cancellable,
633                                                            GAsyncReadyCallback         callback,
634                                                            gpointer                    user_data);
635 GFileOutputStream *     g_file_create_finish              (GFile                      *file,
636                                                            GAsyncResult               *res,
637                                                            GError                    **error);
638 void                    g_file_replace_async              (GFile                      *file,
639                                                            const char                 *etag,
640                                                            gboolean                    make_backup,
641                                                            GFileCreateFlags            flags,
642                                                            int                         io_priority,
643                                                            GCancellable               *cancellable,
644                                                            GAsyncReadyCallback         callback,
645                                                            gpointer                    user_data);
646 GFileOutputStream *     g_file_replace_finish             (GFile                      *file,
647                                                            GAsyncResult               *res,
648                                                            GError                    **error);
649 gboolean                g_file_query_exists               (GFile                      *file,
650                                                            GCancellable               *cancellable);
651 GFileType               g_file_query_file_type            (GFile                      *file,
652                                                            GFileQueryInfoFlags         flags,
653                                                            GCancellable               *cancellable);
654 GFileInfo *             g_file_query_info                 (GFile                      *file,
655                                                            const char                 *attributes,
656                                                            GFileQueryInfoFlags         flags,
657                                                            GCancellable               *cancellable,
658                                                            GError                    **error);
659 void                    g_file_query_info_async           (GFile                      *file,
660                                                            const char                 *attributes,
661                                                            GFileQueryInfoFlags         flags,
662                                                            int                         io_priority,
663                                                            GCancellable               *cancellable,
664                                                            GAsyncReadyCallback         callback,
665                                                            gpointer                    user_data);
666 GFileInfo *             g_file_query_info_finish          (GFile                      *file,
667                                                            GAsyncResult               *res,
668                                                            GError                    **error);
669 GFileInfo *             g_file_query_filesystem_info      (GFile                      *file,
670                                                            const char                 *attributes,
671                                                            GCancellable               *cancellable,
672                                                            GError                    **error);
673 void                    g_file_query_filesystem_info_async (GFile                      *file,
674                                                            const char                 *attributes,
675                                                            int                         io_priority,
676                                                            GCancellable               *cancellable,
677                                                            GAsyncReadyCallback         callback,
678                                                            gpointer                    user_data);
679 GFileInfo *             g_file_query_filesystem_info_finish (GFile                      *file,
680                                                            GAsyncResult               *res,
681                                                            GError                    **error);
682 GMount *                g_file_find_enclosing_mount       (GFile                      *file,
683                                                            GCancellable               *cancellable,
684                                                            GError                    **error);
685 void                    g_file_find_enclosing_mount_async (GFile                      *file,
686                                                            int                         io_priority,
687                                                            GCancellable               *cancellable,
688                                                            GAsyncReadyCallback         callback,
689                                                            gpointer                    user_data);
690 GMount *                g_file_find_enclosing_mount_finish (GFile                     *file,
691                                                             GAsyncResult              *res,
692                                                             GError                   **error);
693 GFileEnumerator *       g_file_enumerate_children         (GFile                      *file,
694                                                            const char                 *attributes,
695                                                            GFileQueryInfoFlags         flags,
696                                                            GCancellable               *cancellable,
697                                                            GError                    **error);
698 void                    g_file_enumerate_children_async   (GFile                      *file,
699                                                            const char                 *attributes,
700                                                            GFileQueryInfoFlags         flags,
701                                                            int                         io_priority,
702                                                            GCancellable               *cancellable,
703                                                            GAsyncReadyCallback         callback,
704                                                            gpointer                    user_data);
705 GFileEnumerator *       g_file_enumerate_children_finish  (GFile                      *file,
706                                                            GAsyncResult               *res,
707                                                            GError                    **error);
708 GFile *                 g_file_set_display_name           (GFile                      *file,
709                                                            const char                 *display_name,
710                                                            GCancellable               *cancellable,
711                                                            GError                    **error);
712 void                    g_file_set_display_name_async     (GFile                      *file,
713                                                            const char                 *display_name,
714                                                            int                         io_priority,
715                                                            GCancellable               *cancellable,
716                                                            GAsyncReadyCallback         callback,
717                                                            gpointer                    user_data);
718 GFile *                 g_file_set_display_name_finish    (GFile                      *file,
719                                                            GAsyncResult               *res,
720                                                            GError                    **error);
721 gboolean                g_file_delete                     (GFile                      *file,
722                                                            GCancellable               *cancellable,
723                                                            GError                    **error);
724 gboolean                g_file_trash                      (GFile                      *file,
725                                                            GCancellable               *cancellable,
726                                                            GError                    **error);
727 gboolean                g_file_copy                       (GFile                      *source,
728                                                            GFile                      *destination,
729                                                            GFileCopyFlags              flags,
730                                                            GCancellable               *cancellable,
731                                                            GFileProgressCallback       progress_callback,
732                                                            gpointer                    progress_callback_data,
733                                                            GError                    **error);
734 void                    g_file_copy_async                 (GFile                      *source,
735                                                            GFile                      *destination,
736                                                            GFileCopyFlags              flags,
737                                                            int                         io_priority,
738                                                            GCancellable               *cancellable,
739                                                            GFileProgressCallback       progress_callback,
740                                                            gpointer                    progress_callback_data,
741                                                            GAsyncReadyCallback         callback,
742                                                            gpointer                    user_data);
743 gboolean                g_file_copy_finish                (GFile                      *file,
744                                                            GAsyncResult               *res,
745                                                            GError                    **error);
746 gboolean                g_file_move                       (GFile                      *source,
747                                                            GFile                      *destination,
748                                                            GFileCopyFlags              flags,
749                                                            GCancellable               *cancellable,
750                                                            GFileProgressCallback       progress_callback,
751                                                            gpointer                    progress_callback_data,
752                                                            GError                    **error);
753 gboolean                g_file_make_directory             (GFile                      *file,
754                                                            GCancellable               *cancellable,
755                                                            GError                    **error);
756 gboolean                g_file_make_directory_with_parents (GFile                     *file,
757                                                            GCancellable               *cancellable,
758                                                            GError                    **error);
759 gboolean                g_file_make_symbolic_link         (GFile                      *file,
760                                                            const char                 *symlink_value,
761                                                            GCancellable               *cancellable,
762                                                            GError                    **error);
763 GFileAttributeInfoList *g_file_query_settable_attributes  (GFile                      *file,
764                                                            GCancellable               *cancellable,
765                                                            GError                    **error);
766 GFileAttributeInfoList *g_file_query_writable_namespaces  (GFile                      *file,
767                                                            GCancellable               *cancellable,
768                                                            GError                    **error);
769 gboolean                g_file_set_attribute              (GFile                      *file,
770                                                            const char                 *attribute,
771                                                            GFileAttributeType          type,
772                                                            gpointer                    value_p,
773                                                            GFileQueryInfoFlags         flags,
774                                                            GCancellable               *cancellable,
775                                                            GError                    **error);
776 gboolean                g_file_set_attributes_from_info   (GFile                      *file,
777                                                            GFileInfo                  *info,
778                                                            GFileQueryInfoFlags         flags,
779                                                            GCancellable               *cancellable,
780                                                            GError                    **error);
781 void                    g_file_set_attributes_async       (GFile                      *file,
782                                                            GFileInfo                  *info,
783                                                            GFileQueryInfoFlags         flags,
784                                                            int                         io_priority,
785                                                            GCancellable               *cancellable,
786                                                            GAsyncReadyCallback         callback,
787                                                            gpointer                    user_data);
788 gboolean                g_file_set_attributes_finish      (GFile                      *file,
789                                                            GAsyncResult               *result,
790                                                            GFileInfo                 **info,
791                                                            GError                    **error);
792 gboolean                g_file_set_attribute_string       (GFile                      *file,
793                                                            const char                 *attribute,
794                                                            const char                 *value,
795                                                            GFileQueryInfoFlags         flags,
796                                                            GCancellable               *cancellable,
797                                                            GError                    **error);
798 gboolean                g_file_set_attribute_byte_string  (GFile                      *file,
799                                                            const char                 *attribute,
800                                                            const char                 *value,
801                                                            GFileQueryInfoFlags         flags,
802                                                            GCancellable               *cancellable,
803                                                            GError                    **error);
804 gboolean                g_file_set_attribute_uint32       (GFile                      *file,
805                                                            const char                 *attribute,
806                                                            guint32                     value,
807                                                            GFileQueryInfoFlags         flags,
808                                                            GCancellable               *cancellable,
809                                                            GError                    **error);
810 gboolean                g_file_set_attribute_int32        (GFile                      *file,
811                                                            const char                 *attribute,
812                                                            gint32                      value,
813                                                            GFileQueryInfoFlags         flags,
814                                                            GCancellable               *cancellable,
815                                                            GError                    **error);
816 gboolean                g_file_set_attribute_uint64       (GFile                      *file,
817                                                            const char                 *attribute,
818                                                            guint64                     value,
819                                                            GFileQueryInfoFlags         flags,
820                                                            GCancellable               *cancellable,
821                                                            GError                    **error);
822 gboolean                g_file_set_attribute_int64        (GFile                      *file,
823                                                            const char                 *attribute,
824                                                            gint64                      value,
825                                                            GFileQueryInfoFlags         flags,
826                                                            GCancellable               *cancellable,
827                                                            GError                    **error);
828 void                    g_file_mount_enclosing_volume     (GFile                      *location,
829                                                            GMountMountFlags            flags,
830                                                            GMountOperation            *mount_operation,
831                                                            GCancellable               *cancellable,
832                                                            GAsyncReadyCallback         callback,
833                                                            gpointer                    user_data);
834 gboolean                g_file_mount_enclosing_volume_finish (GFile                      *location,
835                                                            GAsyncResult               *result,
836                                                            GError                    **error);
837 void                    g_file_mount_mountable            (GFile                      *file,
838                                                            GMountMountFlags            flags,
839                                                            GMountOperation            *mount_operation,
840                                                            GCancellable               *cancellable,
841                                                            GAsyncReadyCallback         callback,
842                                                            gpointer                    user_data);
843 GFile *                 g_file_mount_mountable_finish     (GFile                      *file,
844                                                            GAsyncResult               *result,
845                                                            GError                    **error);
846 void                    g_file_unmount_mountable          (GFile                      *file,
847                                                            GMountUnmountFlags          flags,
848                                                            GCancellable               *cancellable,
849                                                            GAsyncReadyCallback         callback,
850                                                            gpointer                    user_data);
851 gboolean                g_file_unmount_mountable_finish   (GFile                      *file,
852                                                            GAsyncResult               *result,
853                                                            GError                    **error);
854 void                    g_file_eject_mountable            (GFile                      *file,
855                                                            GMountUnmountFlags          flags,
856                                                            GCancellable               *cancellable,
857                                                            GAsyncReadyCallback         callback,
858                                                            gpointer                    user_data);
859 gboolean                g_file_eject_mountable_finish     (GFile                      *file,
860                                                            GAsyncResult               *result,
861                                                            GError                    **error);
862
863 gboolean                g_file_copy_attributes            (GFile                      *source,
864                                                            GFile                      *destination,
865                                                            GFileCopyFlags              flags,
866                                                            GCancellable               *cancellable,
867                                                            GError                    **error);
868
869
870 GFileMonitor*           g_file_monitor_directory          (GFile                  *file,
871                                                            GFileMonitorFlags       flags,
872                                                            GCancellable           *cancellable,
873                                                            GError                **error);
874 GFileMonitor*           g_file_monitor_file               (GFile                  *file,
875                                                            GFileMonitorFlags       flags,
876                                                            GCancellable           *cancellable,
877                                                            GError                **error);
878
879
880 /* Utilities */
881
882 GAppInfo *g_file_query_default_handler       (GFile                  *file,
883                                               GCancellable           *cancellable,
884                                               GError                **error);
885 gboolean g_file_load_contents                (GFile                  *file,
886                                               GCancellable           *cancellable,
887                                               char                  **contents,
888                                               gsize                  *length,
889                                               char                  **etag_out,
890                                               GError                **error);
891 void     g_file_load_contents_async          (GFile                  *file,
892                                               GCancellable           *cancellable,
893                                               GAsyncReadyCallback     callback,
894                                               gpointer                user_data);
895 gboolean g_file_load_contents_finish         (GFile                  *file,
896                                               GAsyncResult           *res,
897                                               char                  **contents,
898                                               gsize                  *length,
899                                               char                  **etag_out,
900                                               GError                **error);
901 void     g_file_load_partial_contents_async  (GFile                  *file,
902                                               GCancellable           *cancellable,
903                                               GFileReadMoreCallback   read_more_callback,
904                                               GAsyncReadyCallback     callback,
905                                               gpointer                user_data);
906 gboolean g_file_load_partial_contents_finish (GFile                  *file,
907                                               GAsyncResult           *res,
908                                               char                  **contents,
909                                               gsize                  *length,
910                                               char                  **etag_out,
911                                               GError                **error);
912 gboolean g_file_replace_contents             (GFile                  *file,
913                                               const char             *contents,
914                                               gsize                   length,
915                                               const char             *etag,
916                                               gboolean                make_backup,
917                                               GFileCreateFlags        flags,
918                                               char                  **new_etag,
919                                               GCancellable           *cancellable,
920                                               GError                **error);
921 void     g_file_replace_contents_async       (GFile                  *file,
922                                               const char             *contents,
923                                               gsize                   length,
924                                               const char             *etag,
925                                               gboolean                make_backup,
926                                               GFileCreateFlags        flags,
927                                               GCancellable           *cancellable,
928                                               GAsyncReadyCallback     callback,
929                                               gpointer                user_data);
930 gboolean g_file_replace_contents_finish      (GFile                  *file,
931                                               GAsyncResult           *res,
932                                               char                  **new_etag,
933                                               GError                **error);
934
935 G_END_DECLS
936
937 #endif /* __G_FILE_H__ */