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