## GVfs GVfs — Virtual File System |

## Functions

GFile * | (*GVfsFileLookupFunc) ()
GFile * | g_vfs_get_file_for_path ()
GFile * | g_vfs_get_file_for_uri ()
GFile * | g_vfs_parse_name ()
GVfs * | g_vfs_get_default ()
GVfs * | g_vfs_get_local ()
gboolean | g_vfs_is_active ()
const gchar * const * | g_vfs_get_supported_uri_schemes ()
gboolean | g_vfs_register_uri_scheme ()
gboolean | g_vfs_unregister_uri_scheme ()

## Types and Values

| GVfs
#define | G_VFS_EXTENSION_POINT_NAME

## Object Hierarchy

        GObject
        ╰── GVfs

## Includes

    #include <gio/gio.h>

## Description

Entry point for using GIO functionality.

## Functions

### GVfsFileLookupFunc ()

    GFile *
    (*GVfsFileLookupFunc) (GVfs *vfs,
                           const char *identifier,
                           gpointer user_data);

This function type is used by `g_vfs_register_uri_scheme()` to make it possible for a client to associate an URI scheme to a different GFile implementation.

The client should return a reference to the new file that has been created for `uri` , or `NULL` to continue with the default implementation.

#### Parameters

vfs | a GVfs |
identifier | the identifier to look up a GFile for. This can either be an URI or a parse name as returned by `g_file_get_parse_name()` |
user_data | user data passed to the function |

#### Returns

a GFile for `identifier` .

[transfer full]

Since: 2.50

### g_vfs_get_file_for_path ()

    GFile *
    g_vfs_get_file_for_path (GVfs *vfs,
                             const char *path);

Gets a GFile for `path` .

#### Parameters

vfs | a GVfs. |
path | a string containing a VFS path. |

#### Returns

a GFile. Free the returned object with `g_object_unref()`.

[transfer full]

### g_vfs_get_file_for_uri ()

    GFile *
    g_vfs_get_file_for_uri (GVfs *vfs,
                            const char *uri);

Gets a GFile for `uri` .

This operation never fails, but the returned object might not support any I/O operation if the URI is malformed or if the URI scheme is not supported.

#### Parameters

vfs | aGVfs. |
uri | a string containing a URI |

#### Returns

a GFile. Free the returned object with `g_object_unref()`.

[transfer full]

### g_vfs_parse_name ()

    GFile *
    g_vfs_parse_name (GVfs *vfs,
                      const char *parse_name);

This operation never fails, but the returned object might not support any I/O operations if the `parse_name` cannot be parsed by the GVfs module.

#### Parameters

vfs | a GVfs. |
parse_name | a string to be parsed by the VFS module. |

#### Returns

a GFile for the given `parse_name` . Free the returned object with `g_object_unref()`.

[transfer full]

### g_vfs_get_default ()

    GVfs *
    g_vfs_get_default (void);

Gets the default GVfs for the system.

#### Returns

a GVfs, which will be the local file system GVfs if no other implementation is available.

[not nullable][transfer none]

### g_vfs_get_local ()

    GVfs *
    g_vfs_get_local (void);

Gets the local GVfs for the system.

#### Returns

a GVfs.

[transfer none]

### g_vfs_is_active ()

    gboolean
    g_vfs_is_active (GVfs *vfs);

Checks if the VFS is active.

#### Parameters

vfs | a GVfs. |

#### Returns

`TRUE` if construction of the `vfs` was successful and it is now active.

### g_vfs_get_supported_uri_schemes ()

    const gchar * const *
    g_vfs_get_supported_uri_schemes (GVfs *vfs);

Gets a list of URI schemes supported by `vfs` .

#### Parameters

vfs | a GVfs. |

#### Returns

a `NULL`-terminated array of strings. The returned array belongs to GIO and must not be freed or modified.

[transfer none]

### g_vfs_register_uri_scheme ()

    gboolean
    g_vfs_register_uri_scheme (GVfs *vfs,
                               const char *scheme,
                               GVfsFileLookupFunc uri_func,
                               gpointer uri_data,
                               GDestroyNotify uri_destroy,
                               GVfsFileLookupFunc parse_name_func,
                               gpointer parse_name_data,
                               GDestroyNotify parse_name_destroy);

Registers `uri_func` and `parse_name_func` as the GFile URI and parse name lookup functions for URIs with a scheme matching `scheme` . Note that `scheme` is registered only within the running application, as opposed to desktop-wide as it happens with GVfs backends.

When a GFile is requested with an URI containing `scheme` (e.g. through `g_file_new_for_uri()`), `uri_func` will be called to allow a custom constructor. The implementation of `uri_func` should not be blocking, and must not call `g_vfs_register_uri_scheme()` or `g_vfs_unregister_uri_scheme()`.

When `g_file_parse_name()` is called with a parse name obtained from such file, `parse_name_func` will be called to allow the GFile to be created again. In that case, it's responsibility of `parse_name_func` to make sure the parse name matches what the custom GFile implementation returned when `g_file_get_parse_name()` was previously called. The implementation of `parse_name_func` should not be blocking, and must not call `g_vfs_register_uri_scheme()` or `g_vfs_unregister_uri_scheme()`.

It's an error to call this function twice with the same scheme. To unregister a custom URI scheme, use `g_vfs_unregister_uri_scheme()`.

#### Parameters

vfs | a GVfs |
scheme | an URI scheme, e.g. "http" |
uri_func | a GVfsFileLookupFunc. | [scope notified][nullable]
uri_data | custom data passed to be passed to `uri_func` , or `NULL`. | [nullable]
uri_destroy | function to be called when unregistering the URI scheme, or when `vfs` is disposed, to free the resources used by the URI lookup function. | [nullable]
parse_name_func | a GVfsFileLookupFunc. | [scope notified][nullable]
parse_name_data | custom data passed to be passed to `parse_name_func` , or `NULL`. | [nullable]
parse_name_destroy | function to be called when unregistering the URI scheme, or when `vfs` is disposed, to free the resources used by the parse name lookup function. | [nullable]

#### Returns

`TRUE` if `scheme` was successfully registered, or `FALSE` if a handler for `scheme` already exists.

Since: 2.50

### g_vfs_unregister_uri_scheme ()

    gboolean
    g_vfs_unregister_uri_scheme (GVfs *vfs,
                                 const char *scheme);

Unregisters the URI handler for `scheme` previously registered with `g_vfs_register_uri_scheme()`.

#### Parameters

vfs | a GVfs |
scheme | an URI scheme, e.g. "http" |

#### Returns

`TRUE` if `scheme` was successfully unregistered, or `FALSE` if a handler for `scheme` does not exist.

Since: 2.50

## Types and Values

### GVfs

    typedef struct _GVfs GVfs;

Virtual File System object.

### G_VFS_EXTENSION_POINT_NAME

    #define G_VFS_EXTENSION_POINT_NAME "gio-vfs"

Extension point for GVfs functionality. See Extending GIO.