Skip to content

Gio.Vfs

class — extends GObject.Object

Entry point for using GIO functionality.

Methods

get_file_for_path

def get_file_for_path(self, path: str | bytes | os.PathLike[str] | os.PathLike[bytes]) -> File

Gets a File for path.

Parameters:

  • path — a string containing a VFS path.

get_file_for_uri

def get_file_for_uri(self, uri: str) -> File

Gets a File 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:

  • uri — a string containing a URI

get_supported_uri_schemes

def get_supported_uri_schemes(self) -> list[str]

Gets a list of URI schemes supported by vfs.

is_active

def is_active(self) -> bool

Checks if the VFS is active.

parse_name

def parse_name(self, parse_name: str) -> File

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

Parameters:

  • parse_name — a string to be parsed by the VFS module.

register_uri_scheme

def register_uri_scheme(self, scheme: str, uri_func: VfsFileLookupFunc | None = ..., parse_name_func: VfsFileLookupFunc | None = ...) -> bool

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 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 Vfs.register_uri_scheme or Vfs.unregister_uri_scheme.

When File.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 File.get_parse_name was previously called. The implementation of parse_name_func should not be blocking, and must not call Vfs.register_uri_scheme or Vfs.unregister_uri_scheme.

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

Parameters:

  • scheme — an URI scheme, e.g. "http"
  • uri_func — a GVfsFileLookupFunc
  • parse_name_func — a GVfsFileLookupFunc

unregister_uri_scheme

def unregister_uri_scheme(self, scheme: str) -> bool

Unregisters the URI handler for scheme previously registered with Vfs.register_uri_scheme.

Parameters:

  • scheme — an URI scheme, e.g. "http"

Static functions

get_default

@staticmethod
def get_default() -> Vfs

Gets the default Vfs for the system.

get_local

@staticmethod
def get_local() -> Vfs

Gets the local Vfs for the system.

Virtual methods

do_add_writable_namespaces

def do_add_writable_namespaces(self, list: FileAttributeInfoList) -> None

do_get_file_for_path

def do_get_file_for_path(self, path: str | bytes | os.PathLike[str] | os.PathLike[bytes]) -> File

Gets a File for path.

Parameters:

  • path — a string containing a VFS path.

do_get_file_for_uri

def do_get_file_for_uri(self, uri: str) -> File

Gets a File 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:

  • uri — a string containing a URI

do_get_supported_uri_schemes

def do_get_supported_uri_schemes(self) -> list[str]

Gets a list of URI schemes supported by vfs.

do_is_active

def do_is_active(self) -> bool

Checks if the VFS is active.

do_local_file_add_info

def do_local_file_add_info(self, filename: str, device: int, attribute_matcher: FileAttributeMatcher, info: FileInfo, cancellable: Cancellable | None, extra_data: int | None, free_extra_data: GLib.DestroyNotify) -> None

do_local_file_moved

def do_local_file_moved(self, source: str, dest: str) -> None

do_local_file_removed

def do_local_file_removed(self, filename: str) -> None

do_local_file_set_attributes

def do_local_file_set_attributes(self, filename: str, info: FileInfo, flags: FileQueryInfoFlags | int, cancellable: Cancellable | None = ...) -> bool

do_parse_name

def do_parse_name(self, parse_name: str) -> File

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

Parameters:

  • parse_name — a string to be parsed by the VFS module.