register_uri_scheme


Description:

[ Version ( since = "2.50" ) ]
public bool register_uri_scheme (string scheme, owned VfsFileLookupFunc? uri_func, owned VfsFileLookupFunc? parse_name_func)

Registers uri_func and parse_name_func as the File 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 File is requested with an URI containing scheme (e.g. through 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 register_uri_scheme or unregister_uri_scheme.

When parse_name is called with a parse name obtained from such file, parse_name_func will be called to allow the File to be created again. In that case, it's responsibility of parse_name_func to make sure the parse name matches what the custom File implementation returned when get_parse_name was previously called. The implementation of parse_name_func should not be blocking, and must not call register_uri_scheme or unregister_uri_scheme.

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

Parameters:

this

a Vfs

scheme

an URI scheme, e.g. "http"

uri_func

a VfsFileLookupFunc

parse_name_func

a VfsFileLookupFunc

parse_name_data

custom data passed to be passed to parse_name_func, or null

parse_name_destroy

function to be called when unregistering the URI scheme, or when this is disposed, to free the resources used by the parse name lookup function

uri_data

custom data passed to be passed to uri_func, or null

uri_destroy

function to be called when unregistering the URI scheme, or when this is disposed, to free the resources used by the URI lookup function

Returns:

true if scheme was successfully registered, or false if a handler for scheme already exists.