GFile

GFile — File and Directory Handling

Synopsis


#include <gio/gio.h>

                    GFile;
                    GFileIface;
enum                GFileQueryInfoFlags;
enum                GFileCreateFlags;
enum                GFileCopyFlags;
enum                GFileMonitorFlags;
enum                GFilesystemPreviewType;
void                (*GFileProgressCallback)            (goffset current_num_bytes,
                                                         goffset total_num_bytes,
                                                         gpointer user_data);
gboolean            (*GFileReadMoreCallback)            (const char *file_contents,
                                                         goffset file_size,
                                                         gpointer callback_data);
GFile*              g_file_new_for_path                 (const char *path);
GFile*              g_file_new_for_uri                  (const char *uri);
GFile*              g_file_new_for_commandline_arg      (const char *arg);
GFile*              g_file_parse_name                   (const char *parse_name);
GFile*              g_file_dup                          (GFile *file);
guint               g_file_hash                         (gconstpointer file);
gboolean            g_file_equal                        (GFile *file1,
                                                         GFile *file2);
char*               g_file_get_basename                 (GFile *file);
char*               g_file_get_path                     (GFile *file);
char*               g_file_get_uri                      (GFile *file);
char*               g_file_get_parse_name               (GFile *file);
GFile*              g_file_get_parent                   (GFile *file);
GFile*              g_file_get_child                    (GFile *file,
                                                         const char *name);
GFile*              g_file_get_child_for_display_name   (GFile *file,
                                                         const char *display_name,
                                                         GError **error);
gboolean            g_file_has_prefix                   (GFile *file,
                                                         GFile *prefix);
char*               g_file_get_relative_path            (GFile *parent,
                                                         GFile *descendant);
GFile*              g_file_resolve_relative_path        (GFile *file,
                                                         const char *relative_path);
gboolean            g_file_is_native                    (GFile *file);
gboolean            g_file_has_uri_scheme               (GFile *file,
                                                         const char *uri_scheme);
char*               g_file_get_uri_scheme               (GFile *file);
GFileInputStream*   g_file_read                         (GFile *file,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_read_async                   (GFile *file,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFileInputStream*   g_file_read_finish                  (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
GFileOutputStream*  g_file_append_to                    (GFile *file,
                                                         GFileCreateFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
GFileOutputStream*  g_file_create                       (GFile *file,
                                                         GFileCreateFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
GFileOutputStream*  g_file_replace                      (GFile *file,
                                                         const char *etag,
                                                         gboolean make_backup,
                                                         GFileCreateFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_append_to_async              (GFile *file,
                                                         GFileCreateFlags flags,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFileOutputStream*  g_file_append_to_finish             (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
void                g_file_create_async                 (GFile *file,
                                                         GFileCreateFlags flags,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFileOutputStream*  g_file_create_finish                (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
void                g_file_replace_async                (GFile *file,
                                                         const char *etag,
                                                         gboolean make_backup,
                                                         GFileCreateFlags flags,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFileOutputStream*  g_file_replace_finish               (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
GFileInfo*          g_file_query_info                   (GFile *file,
                                                         const char *attributes,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_query_info_async             (GFile *file,
                                                         const char *attributes,
                                                         GFileQueryInfoFlags flags,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFileInfo*          g_file_query_info_finish            (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
gboolean            g_file_query_exists                 (GFile *file,
                                                         GCancellable *cancellable);
GFileInfo*          g_file_query_filesystem_info        (GFile *file,
                                                         const char *attributes,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_query_filesystem_info_async  (GFile *file,
                                                         const char *attributes,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFileInfo*          g_file_query_filesystem_info_finish (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
GAppInfo*           g_file_query_default_handler        (GFile *file,
                                                         GCancellable *cancellable,
                                                         GError **error);
GMount*             g_file_find_enclosing_mount         (GFile *file,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_find_enclosing_mount_async   (GFile *file,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GMount*             g_file_find_enclosing_mount_finish  (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
GFileEnumerator*    g_file_enumerate_children           (GFile *file,
                                                         const char *attributes,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_enumerate_children_async     (GFile *file,
                                                         const char *attributes,
                                                         GFileQueryInfoFlags flags,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFileEnumerator*    g_file_enumerate_children_finish    (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
GFile*              g_file_set_display_name             (GFile *file,
                                                         const char *display_name,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_set_display_name_async       (GFile *file,
                                                         const char *display_name,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFile*              g_file_set_display_name_finish      (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
gboolean            g_file_delete                       (GFile *file,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_trash                        (GFile *file,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_copy                         (GFile *source,
                                                         GFile *destination,
                                                         GFileCopyFlags flags,
                                                         GCancellable *cancellable,
                                                         GFileProgressCallback progress_callback,
                                                         gpointer progress_callback_data,
                                                         GError **error);
void                g_file_copy_async                   (GFile *source,
                                                         GFile *destination,
                                                         GFileCopyFlags flags,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GFileProgressCallback progress_callback,
                                                         gpointer progress_callback_data,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            g_file_copy_finish                  (GFile *file,
                                                         GAsyncResult *res,
                                                         GError **error);
gboolean            g_file_move                         (GFile *source,
                                                         GFile *destination,
                                                         GFileCopyFlags flags,
                                                         GCancellable *cancellable,
                                                         GFileProgressCallback progress_callback,
                                                         gpointer progress_callback_data,
                                                         GError **error);
gboolean            g_file_make_directory               (GFile *file,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_make_symbolic_link           (GFile *file,
                                                         const char *symlink_value,
                                                         GCancellable *cancellable,
                                                         GError **error);
GFileAttributeInfoList* g_file_query_settable_attributes
                                                        (GFile *file,
                                                         GCancellable *cancellable,
                                                         GError **error);
GFileAttributeInfoList* g_file_query_writable_namespaces
                                                        (GFile *file,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_set_attribute                (GFile *file,
                                                         const char *attribute,
                                                         GFileAttributeType type,
                                                         gpointer value_p,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_set_attributes_from_info     (GFile *file,
                                                         GFileInfo *info,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_set_attributes_async         (GFile *file,
                                                         GFileInfo *info,
                                                         GFileQueryInfoFlags flags,
                                                         int io_priority,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            g_file_set_attributes_finish        (GFile *file,
                                                         GAsyncResult *result,
                                                         GFileInfo **info,
                                                         GError **error);
gboolean            g_file_set_attribute_string         (GFile *file,
                                                         const char *attribute,
                                                         const char *value,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_set_attribute_byte_string    (GFile *file,
                                                         const char *attribute,
                                                         const char *value,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_set_attribute_uint32         (GFile *file,
                                                         const char *attribute,
                                                         guint32 value,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_set_attribute_int32          (GFile *file,
                                                         const char *attribute,
                                                         gint32 value,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_set_attribute_uint64         (GFile *file,
                                                         const char *attribute,
                                                         guint64 value,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_set_attribute_int64          (GFile *file,
                                                         const char *attribute,
                                                         gint64 value,
                                                         GFileQueryInfoFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_mount_mountable              (GFile *file,
                                                         GMountMountFlags flags,
                                                         GMountOperation *mount_operation,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFile*              g_file_mount_mountable_finish       (GFile *file,
                                                         GAsyncResult *result,
                                                         GError **error);
void                g_file_unmount_mountable            (GFile *file,
                                                         GMountUnmountFlags flags,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            g_file_unmount_mountable_finish     (GFile *file,
                                                         GAsyncResult *result,
                                                         GError **error);
void                g_file_eject_mountable              (GFile *file,
                                                         GMountUnmountFlags flags,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            g_file_eject_mountable_finish       (GFile *file,
                                                         GAsyncResult *result,
                                                         GError **error);
void                g_file_mount_enclosing_volume       (GFile *location,
                                                         GMountMountFlags flags,
                                                         GMountOperation *mount_operation,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            g_file_mount_enclosing_volume_finish
                                                        (GFile *location,
                                                         GAsyncResult *result,
                                                         GError **error);
GFileMonitor*       g_file_monitor_directory            (GFile *file,
                                                         GFileMonitorFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
GFileMonitor*       g_file_monitor_file                 (GFile *file,
                                                         GFileMonitorFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_file_load_contents                (GFile *file,
                                                         GCancellable *cancellable,
                                                         char **contents,
                                                         gsize *length,
                                                         char **etag_out,
                                                         GError **error);
void                g_file_load_contents_async          (GFile *file,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            g_file_load_contents_finish         (GFile *file,
                                                         GAsyncResult *res,
                                                         char **contents,
                                                         gsize *length,
                                                         char **etag_out,
                                                         GError **error);
void                g_file_load_partial_contents_async  (GFile *file,
                                                         GCancellable *cancellable,
                                                         GFileReadMoreCallback read_more_callback,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            g_file_load_partial_contents_finish (GFile *file,
                                                         GAsyncResult *res,
                                                         char **contents,
                                                         gsize *length,
                                                         char **etag_out,
                                                         GError **error);
gboolean            g_file_replace_contents             (GFile *file,
                                                         const char *contents,
                                                         gsize length,
                                                         const char *etag,
                                                         gboolean make_backup,
                                                         GFileCreateFlags flags,
                                                         char **new_etag,
                                                         GCancellable *cancellable,
                                                         GError **error);
void                g_file_replace_contents_async       (GFile *file,
                                                         const char *contents,
                                                         gsize length,
                                                         const char *etag,
                                                         gboolean make_backup,
                                                         GFileCreateFlags flags,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            g_file_replace_contents_finish      (GFile *file,
                                                         GAsyncResult *res,
                                                         char **new_etag,
                                                         GError **error);
gboolean            g_file_copy_attributes              (GFile *source,
                                                         GFile *destination,
                                                         GFileCopyFlags flags,
                                                         GCancellable *cancellable,
                                                         GError **error);

Object Hierarchy

  GInterface
   +----GFile

Prerequisites

GFile requires GObject.

Description

GFile is a high level abstraction for manipulating files on a virtual file system. GFiles are lightweight, immutable objects that do no I/O upon creation. It is necessary to understand that GFile objects do not represent files, merely an identifier for a file. All file content I/O is implemented as streaming operations (see GInputStream and GOutputStream).

To construct a GFile, you can use: g_file_new_for_path() if you have a path. g_file_new_for_uri() if you have a URI. g_file_new_for_commandline_arg() for a command line argument. g_file_parse_name() from a utf8 string gotten from g_file_get_parse_name().

One way to think of a GFile is as an abstraction of a pathname. For normal files the system pathname is what is stored internally, but as GFiles are extensible it could also be something else that corresponds to a pathname in a userspace implementation of a filesystem.

GFiles make up hierarchies of directories and files that correspond to the files on a filesystem. You can move through the file system with GFile using g_file_get_parent() to get an identifier for the parent directory, g_file_get_child() to get a child within a directory, g_file_resolve_relative_path() to resolve a relative path between two GFiles. There can be multiple hierarchies, so you may not end up at the same root if you repeatedly call g_file_get_parent() on two different files.

All GFiles have a basename (get with g_file_get_basename()). These names are byte strings that are used to identify the file on the filesystem (relative to its parent directory) and there is no guarantees that they have any particular charset encoding or even make any sense at all. If you want to use filenames in a user interface you should use the display name that you can get by requesting the G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info(). This is guaranteed to be in utf8 and can be used in a user interface. But always store the real basename or the GFile to use to actually access the file, because there is no way to go from a display name to the actual name.

Using GFile as an identifier has the same weaknesses as using a path in that there may be multiple aliases for the same file. For instance, hard or soft links may cause two different GFiles to refer to the same file. Other possible causes for aliases are: case insensitive filesystems, short and long names on Fat/NTFS, or bind mounts in Linux. If you want to check if two GFiles point to the same file you can query for the G_FILE_ATTRIBUTE_ID_FILE attribute. Note that GFile does some trivial canonicalization of pathnames passed in, so that trivial differences in the path string used at creation (duplicated slashes, slash at end of path, "." or ".." path segments, etc) does not create different GFiles.

Many GFile operations have both synchronous and asynchronous versions to suit your application. Asynchronous versions of synchronous functions simply have _async() appended to their function names. The asynchronous I/O functions call a GAsyncReadyCallback which is then used to finalize the operation, producing a GAsyncResult which is then passed to the function's matching _finish() operation.

Some GFile operations do not have synchronous analogs, as they may take a very long time to finish, and blocking may leave an application unusable. Notable cases include: g_file_mount_mountable() to mount a mountable file. g_file_unmount_mountable() to unmount a mountable file. g_file_eject_mountable() to eject a mountable file.

One notable feature of GFiles are entity tags, or "etags" for short. Entity tags are somewhat like a more abstract version of the traditional mtime, and can be used to quickly determine if the file has been modified from the version on the file system. See the HTTP 1.1 specification for HTTP Etag headers, which are a very similar concept.

Details

GFile

typedef struct _GFile GFile;

A handle to an object implementing the GFileIface interface. Generally stores a location within the file system. Handles do not necessarily represent files or directories that currently exist.


GFileIface

typedef struct {
  GTypeInterface g_iface;

  /* Virtual Table */

  GFile *             (*dup)                        (GFile         *file);
  guint               (*hash)                       (GFile         *file);
  gboolean            (*equal)                      (GFile         *file1,
						     GFile         *file2);
  gboolean            (*is_native)                  (GFile         *file);
  gboolean            (*has_uri_scheme)             (GFile         *file,
						     const char    *uri_scheme);
  char *              (*get_uri_scheme)             (GFile         *file);
  char *              (*get_basename)               (GFile         *file);
  char *              (*get_path)                   (GFile         *file);
  char *              (*get_uri)                    (GFile         *file);
  char *              (*get_parse_name)             (GFile         *file);
  GFile *             (*get_parent)                 (GFile         *file);
  gboolean            (*prefix_matches)             (GFile         *prefix,
						     GFile         *file);
  char *              (*get_relative_path)          (GFile         *parent,
						     GFile         *descendant);
  GFile *             (*resolve_relative_path)      (GFile        *file,
						     const char   *relative_path);
  GFile *             (*get_child_for_display_name) (GFile        *file,
						     const char   *display_name,
						     GError      **error);
  
  GFileEnumerator *   (*enumerate_children)        (GFile                *file,
						    const char           *attributes,
						    GFileQueryInfoFlags   flags,
						    GCancellable         *cancellable,
						    GError              **error);
  void                (*enumerate_children_async)  (GFile                      *file,
						    const char                 *attributes,
						    GFileQueryInfoFlags         flags,
						    int                         io_priority,
						    GCancellable               *cancellable,
						    GAsyncReadyCallback         callback,
						    gpointer                    user_data);
  GFileEnumerator *   (*enumerate_children_finish) (GFile                      *file,
						    GAsyncResult               *res,
						    GError                    **error);
  
  GFileInfo *         (*query_info)         (GFile                *file,
					     const char           *attributes,
					     GFileQueryInfoFlags   flags,
					     GCancellable         *cancellable,
					     GError              **error);
  void                (*query_info_async)   (GFile                *file,
					     const char           *attributes,
					     GFileQueryInfoFlags   flags,
					     int                   io_priority,
					     GCancellable         *cancellable,
					     GAsyncReadyCallback   callback,
					     gpointer              user_data);
  GFileInfo *         (*query_info_finish)  (GFile                *file,
					     GAsyncResult         *res,
					     GError              **error);
  
  GFileInfo *         (*query_filesystem_info)(GFile                *file,
					     const char           *attributes,
					     GCancellable         *cancellable,
					     GError              **error);
  void                (*query_filesystem_info_async) (GFile                *file,
                                                      const char           *attributes,
                                                      int                   io_priority,
                                                      GCancellable         *cancellable,
                                                      GAsyncReadyCallback   callback,
                                                      gpointer              user_data);
  GFileInfo *         (*query_filesystem_info_finish) (GFile                *file,
                                                       GAsyncResult         *res,
                                                       GError              **error);
  
  GMount *            (*find_enclosing_mount)(GFile              *file,
					       GCancellable       *cancellable,
					       GError            **error);
  void                (*find_enclosing_mount_async)(GFile              *file,
                                                    int                   io_priority,
                                                    GCancellable         *cancellable,
                                                    GAsyncReadyCallback   callback,
                                                    gpointer              user_data);
  GMount *            (*find_enclosing_mount_finish)(GFile              *file,
                                                     GAsyncResult         *res,
                                                     GError            **error);
  
  GFile *             (*set_display_name)         (GFile                *file,
						   const char           *display_name,
						   GCancellable         *cancellable,
						   GError              **error);
  void                (*set_display_name_async)   (GFile                      *file,
						   const char                 *display_name,
						   int                         io_priority,
						   GCancellable               *cancellable,
						   GAsyncReadyCallback         callback,
						   gpointer                    user_data);
  GFile *              (*set_display_name_finish) (GFile                      *file,
						   GAsyncResult               *res,
						   GError                    **error);
  
  GFileAttributeInfoList * (*query_settable_attributes) (GFile        *file,
							 GCancellable *cancellable,
							 GError      **error);
  void                (*_query_settable_attributes_async) (void);
  void                (*_query_settable_attributes_finish) (void);
  
  GFileAttributeInfoList * (*query_writable_namespaces) (GFile        *file,
							 GCancellable *cancellable,
							 GError      **error);
  void                (*_query_writable_namespaces_async) (void);
  void                (*_query_writable_namespaces_finish) (void);
  
  gboolean            (*set_attribute)            (GFile                *file,
						   const char           *attribute,
						   GFileAttributeType    type,
						   gpointer              value_p,
						   GFileQueryInfoFlags   flags,
						   GCancellable         *cancellable,
						   GError              **error);
  gboolean            (*set_attributes_from_info) (GFile          *file,
						   GFileInfo            *info,
						   GFileQueryInfoFlags   flags,
						   GCancellable         *cancellable,
						   GError              **error);
  void                (*set_attributes_async)     (GFile                      *file,
						   GFileInfo                  *info,
						   GFileQueryInfoFlags        flags,
						   int                         io_priority,
						   GCancellable               *cancellable,
						   GAsyncReadyCallback         callback,
						   gpointer                    user_data);
  gboolean            (*set_attributes_finish)    (GFile                      *file,
						   GAsyncResult               *result,
						   GFileInfo                 **info,
						   GError                    **error);
  
  GFileInputStream *  (*read_fn)            (GFile                *file,
					     GCancellable         *cancellable,
					     GError              **error);
  void                (*read_async)         (GFile                *file,
					     int                   io_priority,
					     GCancellable         *cancellable,
					     GAsyncReadyCallback   callback,
					     gpointer              user_data);
  GFileInputStream *  (*read_finish)        (GFile                *file,
					     GAsyncResult         *res,
					     GError              **error);
  
  GFileOutputStream * (*append_to)          (GFile                *file,
					     GFileCreateFlags      flags,
					     GCancellable         *cancellable,
					     GError               **error);
  void                 (*append_to_async)   (GFile                      *file,
					     GFileCreateFlags            flags,
					     int                         io_priority,
					     GCancellable               *cancellable,
					     GAsyncReadyCallback         callback,
					     gpointer                    user_data);
  GFileOutputStream *  (*append_to_finish)  (GFile                      *file,
					     GAsyncResult               *res,
					     GError                    **error);
  
  GFileOutputStream *  (*create)            (GFile                *file,
					     GFileCreateFlags      flags,
					     GCancellable         *cancellable,
					     GError               **error);
  void                 (*create_async)      (GFile                      *file,
					     GFileCreateFlags            flags,
					     int                         io_priority,
					     GCancellable               *cancellable,
					     GAsyncReadyCallback         callback,
					     gpointer                    user_data);
  GFileOutputStream *  (*create_finish)     (GFile                      *file,
					     GAsyncResult               *res,
					     GError                    **error);
  
  GFileOutputStream *  (*replace)           (GFile                *file,
					     const char           *etag,
					     gboolean              make_backup,
					     GFileCreateFlags      flags,
					     GCancellable         *cancellable,
					     GError              **error);
  void                 (*replace_async)     (GFile                      *file,
					     const char                 *etag,
					     gboolean                    make_backup,
					     GFileCreateFlags            flags,
					     int                         io_priority,
					     GCancellable               *cancellable,
					     GAsyncReadyCallback         callback,
					     gpointer                    user_data);
  GFileOutputStream *  (*replace_finish)    (GFile                      *file,
					     GAsyncResult               *res,
					     GError                    **error);
  
  gboolean            (*delete_file)        (GFile                *file,
					     GCancellable         *cancellable,
					     GError              **error);
  void                (*_delete_file_async) (void);
  void                (*_delete_file_finish) (void);
  
  gboolean            (*trash)              (GFile                *file,
					     GCancellable         *cancellable,
					     GError              **error);
  void                (*_trash_async) (void);
  void                (*_trash_finish) (void);
  
  gboolean            (*make_directory)     (GFile                *file,
					     GCancellable         *cancellable,
					     GError              **error);
  void                (*_make_directory_async) (void);
  void                (*_make_directory_finish) (void);
  
  gboolean            (*make_symbolic_link) (GFile                *file,
					     const char           *symlink_value,
					     GCancellable         *cancellable,
					     GError              **error);
  void                (*_make_symbolic_link_async) (void);
  void                (*_make_symbolic_link_finish) (void);
  
  gboolean            (*copy)               (GFile                *source,
					     GFile                *destination,
					     GFileCopyFlags        flags,
					     GCancellable         *cancellable,
					     GFileProgressCallback progress_callback,
					     gpointer              progress_callback_data,
					     GError              **error);
  void                (*copy_async)         (GFile                  *source,
					     GFile                  *destination,
					     GFileCopyFlags          flags,
					     int                     io_priority,
					     GCancellable           *cancellable,
					     GFileProgressCallback   progress_callback,
					     gpointer                progress_callback_data,
					     GAsyncReadyCallback     callback,
					     gpointer                user_data);
  gboolean            (*copy_finish)        (GFile                  *file,
					     GAsyncResult           *res,
					     GError                **error);
  
  gboolean            (*move)               (GFile                *source,
					     GFile                *destination,
					     GFileCopyFlags        flags,
					     GCancellable         *cancellable,
					     GFileProgressCallback progress_callback,
					     gpointer              progress_callback_data,
					     GError              **error);

  void                (*_move_async) (void);
  void                (*_move_finish) (void);


  void                (*mount_mountable)           (GFile               *file,
						    GMountMountFlags     flags,
						    GMountOperation     *mount_operation,
						    GCancellable         *cancellable,
						    GAsyncReadyCallback  callback,
						    gpointer             user_data);
  GFile *             (*mount_mountable_finish)    (GFile               *file,
						    GAsyncResult        *result,
						    GError             **error);
  void                (*unmount_mountable)         (GFile               *file,
						    GMountUnmountFlags   flags,
						    GCancellable         *cancellable,
						    GAsyncReadyCallback  callback,
						    gpointer             user_data);
  gboolean            (*unmount_mountable_finish)  (GFile               *file,
						    GAsyncResult        *result,
						    GError             **error);
  void                (*eject_mountable)           (GFile               *file,
						    GMountUnmountFlags   flags,
						    GCancellable        *cancellable,
						    GAsyncReadyCallback  callback,
						    gpointer             user_data);
  gboolean            (*eject_mountable_finish)    (GFile               *file,
						    GAsyncResult        *result,
						    GError             **error);


  void     (*mount_enclosing_volume)        (GFile *location,
					     GMountMountFlags flags,
					     GMountOperation *mount_operation,
					     GCancellable *cancellable,
					     GAsyncReadyCallback callback,
					     gpointer user_data);
  gboolean (*mount_enclosing_volume_finish) (GFile *location,
					     GAsyncResult *result,
					     GError **error);
  
  GFileMonitor*      (*monitor_dir)         (GFile                  *file,
					     GFileMonitorFlags       flags,
					     GCancellable           *cancellable,
					     GError                **error);

  GFileMonitor*      (*monitor_file)        (GFile                  *file,
					     GFileMonitorFlags       flags,
					     GCancellable           *cancellable,
					     GError                **error);
} GFileIface;

An interface for writing VFS file handles.

GTypeInterface g_iface; The parent interface.
dup () Duplicates a GFile.
hash () Creates a hash of a GFile.
equal () Checks equality of two given GFiles.
is_native () Checks to see if a file is native to the system.
has_uri_scheme () Checks to see if a GFile has a given URI scheme.
get_uri_scheme () Gets the URI scheme for a GFile.
get_basename () Gets the basename for a given GFile.
get_path () Gets the current path within a GFile.
get_uri () Gets a URI for the path within a GFile.
get_parse_name () Gets the parsed name for the GFile.
get_parent () Gets the parent directory for the GFile.
prefix_matches () Checks whether a GFile contains a specified file.
get_relative_path () Gets the path for a GFile relative to a given path.
resolve_relative_path () Resolves a relative path for a GFile to an absolute path.
get_child_for_display_name () Gets the child GFile for a given display name.
enumerate_children () Gets a GFileEnumerator with the children of a GFile.
enumerate_children_async () Asynchronously gets a GFileEnumerator with the children of a GFile.
enumerate_children_finish () Finishes asynchronously enumerating the children.
query_info () Gets the GFileInfo for a GFile.
query_info_async () Asynchronously gets the GFileInfo for a GFile.
query_info_finish () Finishes an asynchronous query info operation.
query_filesystem_info () Gets a GFileInfo for the file system GFile is on.
query_filesystem_info_async () Asynchronously gets a GFileInfo for the file system GFile is on.
query_filesystem_info_finish () Finishes asynchronously getting the file system info.
find_enclosing_mount () Gets a GMount for the GFile.
find_enclosing_mount_async () Asynchronously gets the GMount for a GFile.
find_enclosing_mount_finish () Finishes asynchronously getting the volume.
set_display_name () Sets the display name for a GFile.
set_display_name_async () Asynchronously sets a GFile's display name.
set_display_name_finish () Finishes asynchronously setting a GFile's display name.
query_settable_attributes () Returns a list of GFileAttributes that can be set.
_query_settable_attributes_async () Asynchronously gets a list of GFileAttributes that can be set.
_query_settable_attributes_finish () Finishes asynchronously querying settable attributes.
query_writable_namespaces () Returns a list of GFileAttribute namespaces that are writable.
_query_writable_namespaces_async () Asynchronously gets a list of GFileAttribute namespaces that are writable.
_query_writable_namespaces_finish () Finishes asynchronously querying the writable namespaces.
set_attribute () Sets a GFileAttribute.
set_attributes_from_info () Sets a GFileAttribute with information from a GFileInfo.
set_attributes_async () Asynchronously sets a file's attributes.
set_attributes_finish () Finishes setting a file's attributes asynchronously.
read_fn () Reads a file asynchronously.
read_async () Asynchronously reads a file.
read_finish () Finishes asynchronously reading a file.
append_to () Writes to the end of a file.
append_to_async () Asynchronously writes to the end of a file.
append_to_finish () Finishes an asynchronous file append operation.
create () Creates a new file.
create_async () Asynchronously creates a file.
create_finish () Finishes asynchronously creating a file.
replace () Replaces the contents of a file.
replace_async () Asynchronously replaces the contents of a file.
replace_finish () Finishes asynchronously replacing a file.
delete_file () Deletes a file.
_delete_file_async () Asynchronously deletes a file.
_delete_file_finish () Finishes an asynchronous delete.
trash () Sends a GFile to the Trash location.
_trash_async () Asynchronously sends a GFile to the Trash location.
_trash_finish () Finishes an asynchronous file trashing operation.
make_directory () Makes a directory.
_make_directory_async () Asynchronously makes a directory.
_make_directory_finish () Finishes making a directory asynchronously.
make_symbolic_link () Makes a symbolic link.
_make_symbolic_link_async () Asynchronously makes a symbolic link
_make_symbolic_link_finish () Finishes making a symbolic link asynchronously.
copy () Copies a file.
copy_async () Asynchronously copies a file.
copy_finish () Finishes an asynchronous copy operation.
move () Moves a file.
_move_async () Asynchronously moves a file.
_move_finish () Finishes an asynchronous move operation.
mount_mountable () Mounts a mountable object.
mount_mountable_finish () Finishes a mounting operation.
unmount_mountable () Unmounts a mountable object.
unmount_mountable_finish () Finishes an unmount operation.
eject_mountable () Ejects a mountable.
eject_mountable_finish () Finishes an eject operation.
mount_enclosing_volume () Mounts a specified location.
mount_enclosing_volume_finish () Finishes mounting a specified location.
monitor_dir () Creates a GFileMonitor for the location.
monitor_file () Creates a GFileMonitor for the location.

enum GFileQueryInfoFlags

typedef enum {
  G_FILE_QUERY_INFO_NONE = 0,
  G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS = (1<<0)   /*< nick=nofollow-symlinks >*/
} GFileQueryInfoFlags;

Flags used when querying a GFileInfo.

G_FILE_QUERY_INFO_NONE No flags set.
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS Don't follow symlinks.

enum GFileCreateFlags

typedef enum  {
  G_FILE_CREATE_NONE = 0,
  G_FILE_CREATE_PRIVATE = (1<<0)
} GFileCreateFlags;

Flags used when an operation may create a file.

G_FILE_CREATE_NONE No flags set.
G_FILE_CREATE_PRIVATE Create a file that can only be accessed by the current user.

enum GFileCopyFlags

typedef enum {
  G_FILE_COPY_NONE = 0,          /*< nick=none >*/
  G_FILE_COPY_OVERWRITE = (1<<0),
  G_FILE_COPY_BACKUP = (1<<1),
  G_FILE_COPY_NOFOLLOW_SYMLINKS = (1<<2),
  G_FILE_COPY_ALL_METADATA = (1<<3),
  G_FILE_COPY_NO_FALLBACK_FOR_MOVE = (1<<4)
} GFileCopyFlags;

Flags used when copying or moving files.

G_FILE_COPY_NONE No flags set.
G_FILE_COPY_OVERWRITE Overwrite any existing files
G_FILE_COPY_BACKUP Make a backup of any existing files.
G_FILE_COPY_NOFOLLOW_SYMLINKS Don't follow symlinks.
G_FILE_COPY_ALL_METADATA Copy all file metadata instead of just default set used for copy (see GFileInfo).
G_FILE_COPY_NO_FALLBACK_FOR_MOVE Don't use copy and delete fallback if native move not supported.

enum GFileMonitorFlags

typedef enum  {
  G_FILE_MONITOR_NONE = 0,
  G_FILE_MONITOR_WATCH_MOUNTS = (1<<0)
} GFileMonitorFlags;

Flags used to set what a GFileMonitor will watch for.

G_FILE_MONITOR_NONE No flags set.
G_FILE_MONITOR_WATCH_MOUNTS Watch for mount events.

enum GFilesystemPreviewType

typedef enum {
  G_FILESYSTEM_PREVIEW_TYPE_IF_ALWAYS = 0,
  G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL,
  G_FILESYSTEM_PREVIEW_TYPE_NEVER
} GFilesystemPreviewType;

Indicates a hint from the file system whether files should be previewed in a file manager. Returned as the value of the key G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW.

G_FILESYSTEM_PREVIEW_TYPE_IF_ALWAYS Only preview files if user has explicitly requested it.
G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL Preview files if user has requested preview of "local" files.
G_FILESYSTEM_PREVIEW_TYPE_NEVER Never preview files.

GFileProgressCallback ()

void                (*GFileProgressCallback)            (goffset current_num_bytes,
                                                         goffset total_num_bytes,
                                                         gpointer user_data);

When doing file operations that may take a while, such as moving a file or copying a file, a progress callback is used to pass how far along that operation is to the application.

current_num_bytes : the current number of bytes in the operation.
total_num_bytes : the total number of bytes in the operation.
user_data : user data passed to the callback.

GFileReadMoreCallback ()

gboolean            (*GFileReadMoreCallback)            (const char *file_contents,
                                                         goffset file_size,
                                                         gpointer callback_data);

When loading the partial contents of a file with g_file_read_partial_contents(), it may become necessary to determine if any more data from the file should be loaded. A GFileReadMoreCallback function facilitates this by returning TRUE if more data should be read, or FALSE otherwise.

file_contents : the data as currently read.
file_size : the size of the data currently read.
callback_data : data passed to the callback.
Returns : TRUE if more data should be read back. FALSE otherwise.

g_file_new_for_path ()

GFile*              g_file_new_for_path                 (const char *path);

Constructs a GFile for a given path. This operation never fails, but the returned object might not support any I/O operation if path is malformed.

path : a string containing a relative or absolute path.
Returns : a new GFile for the given path.

g_file_new_for_uri ()

GFile*              g_file_new_for_uri                  (const char *uri);

Constructs a GFile for a given URI. This operation never fails, but the returned object might not support any I/O operation if uri is malformed or if the uri type is not supported.

uri : a string containing a URI.
Returns : a GFile for the given uri.

g_file_new_for_commandline_arg ()

GFile*              g_file_new_for_commandline_arg      (const char *arg);

Creates a GFile with the given argument from the command line. The value of arg can be either a URI, an absolute path or a relative path resolved relative to the current working directory. This operation never fails, but the returned object might not support any I/O operation if arg points to a malformed path.

arg : a command line string.
Returns : a new GFile.

g_file_parse_name ()

GFile*              g_file_parse_name                   (const char *parse_name);

Constructs a GFile with the given parse_name (i.e. something given by g_file_get_parse_name()). This operation never fails, but the returned object might not support any I/O operation if the parse_name cannot be parsed.

parse_name : a file name or path to be parsed.
Returns : a new GFile.

g_file_dup ()

GFile*              g_file_dup                          (GFile *file);

Duplicates a GFile handle. This operation does not duplicate the actual file or directory represented by the GFile; see g_file_copy() if attempting to copy a file.

This call does no blocking i/o.

file : input GFile.
Returns : GFile that is a duplicate of the given GFile.

g_file_hash ()

guint               g_file_hash                         (gconstpointer file);

Creates a hash value for a GFile.

This call does no blocking i/o.

file : gconstpointer to a GFile.
Returns : 0 if file is not a valid GFile, otherwise an integer that can be used as hash value for the GFile. This function is intended for easily hashing a GFile to add to a GHashTable or similar data structure.

g_file_equal ()

gboolean            g_file_equal                        (GFile *file1,
                                                         GFile *file2);

Checks equality of two given GFiles. Note that two GFiles that differ can still refer to the same file on the filesystem due to various forms of filename aliasing.

This call does no blocking i/o.

file1 : the first GFile.
file2 : the second GFile.
Returns : TRUE if file1 and file2 are equal. FALSE if either is not a GFile.

g_file_get_basename ()

char*               g_file_get_basename                 (GFile *file);

Gets the base name (the last component of the path) for a given GFile.

If called for the top level of a system (such as the filesystem root or a uri like sftp://host/) it will return a single directory separator (and on Windows, possibly a drive letter).

The base name is a byte string (*not* UTF-8). It has no defined encoding or rules other than it may not contain zero bytes. If you want to use filenames in a user interface you should use the display name that you can get by requesting the G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().

This call does no blocking i/o.

file : input GFile.
Returns : string containing the GFile's base name, or NULL if given GFile is invalid. The returned string should be freed with g_free() when no longer needed.

g_file_get_path ()

char*               g_file_get_path                     (GFile *file);

Gets the local pathname for GFile, if one exists.

This call does no blocking i/o.

file : input GFile.
Returns : string containing the GFile's path, or NULL if no such path exists. The returned string should be freed with g_free() when no longer needed.

g_file_get_uri ()

char*               g_file_get_uri                      (GFile *file);

Gets the URI for the file.

This call does no blocking i/o.

file : input GFile.
Returns : a string containing the GFile's URI. The returned string should be freed with g_free() when no longer needed.

g_file_get_parse_name ()

char*               g_file_get_parse_name               (GFile *file);

Gets the parse name of the file. A parse name is a UTF-8 string that describes the file such that one can get the GFile back using g_file_parse_name().

This is generally used to show the GFile as a nice full-pathname kind of string in a user interface, like in a location entry.

For local files with names that can safely be converted to UTF8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF8 characters unescaped).

This call does no blocking i/o.

file : input GFile.
Returns : a string containing the GFile's parse name. The returned string should be freed with g_free() when no longer needed.

g_file_get_parent ()

GFile*              g_file_get_parent                   (GFile *file);

Gets the parent directory for the file. If the file represents the root directory of the file system, then NULL will be returned.

This call does no blocking i/o.

file : input GFile.
Returns : a GFile structure to the parent of the given GFile or NULL if there is no parent.

g_file_get_child ()

GFile*              g_file_get_child                    (GFile *file,
                                                         const char *name);

Gets a child of file with basename equal to