:right-sidebar: True File =================================================================== .. currentmodule:: gi.repository.Gio .. class:: File(*args, **kwargs) :no-contents-entry: ``GFile`` is a high level abstraction for manipulating files on a virtual file system. ``GFile``\s 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 :obj:`~gi.repository.Gio.InputStream` and :obj:`~gi.repository.Gio.OutputStream`\). To construct a ``GFile``\, you can use: - :obj:`~gi.repository.Gio.File.new_for_path` if you have a path. - :obj:`~gi.repository.Gio.File.new_for_uri` if you have a URI. - :obj:`~gi.repository.Gio.File.new_for_commandline_arg` or :obj:`~gi.repository.Gio.File.new_for_commandline_arg_and_cwd` for a command line argument. - :obj:`~gi.repository.Gio.File.new_tmp` to create a temporary file from a template. - :obj:`~gi.repository.Gio.File.new_tmp_async` to asynchronously create a temporary file. - :obj:`~gi.repository.Gio.File.new_tmp_dir_async` to asynchronously create a temporary directory. - :obj:`~gi.repository.Gio.File.parse_name` from a UTF-8 string gotten from :obj:`~gi.repository.Gio.File.get_parse_name`\. - :obj:`~gi.repository.Gio.File.new_build_filename` or :obj:`~gi.repository.Gio.File.new_build_filenamev` to create a file from path elements. 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 ``GFile``\s are extensible it could also be something else that corresponds to a pathname in a userspace implementation of a filesystem. ``GFile``\s 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 :obj:`~gi.repository.Gio.File.get_parent` to get an identifier for the parent directory, :obj:`~gi.repository.Gio.File.get_child` to get a child within a directory, and :obj:`~gi.repository.Gio.File.resolve_relative_path` to resolve a relative path between two ``GFile``\s. There can be multiple hierarchies, so you may not end up at the same root if you repeatedly call :obj:`~gi.repository.Gio.File.get_parent` on two different files. All ``GFile``\s have a basename (get with :obj:`~gi.repository.Gio.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 :obj:`~gi.repository.Gio.File.query_info`\. This is guaranteed to be in UTF-8 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 ``GFile``\s 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 ``GFile``\s 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 ``GFile``\s. 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 [callback``Gio``\.AsyncReadyCallback] which is then used to finalize the operation, producing a :obj:`~gi.repository.Gio.AsyncResult` which is then passed to the function’s matching ``_finish()`` operation. It is highly recommended to use asynchronous calls when running within a shared main loop, such as in the main thread of an application. This avoids I/O operations blocking other sources on the main loop from being dispatched. Synchronous I/O operations should be performed from worker threads. See the `introduction to asynchronous programming section `__ for more. Some ``GFile`` operations almost always take a noticeable amount of time, and so do not have synchronous analogs. Notable cases include: - :obj:`~gi.repository.Gio.File.mount_mountable` to mount a mountable file. - :obj:`~gi.repository.Gio.File.unmount_mountable_with_operation` to unmount a mountable file. - :obj:`~gi.repository.Gio.File.eject_mountable_with_operation` to eject a mountable file. Entity Tags -------------------------------------------------------------------------------- One notable feature of ``GFile``\s 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. Methods ------- .. rst-class:: interim-class .. class:: File :no-index: .. method:: append_to(flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileOutputStream Gets an output stream for appending data to the file. If the file doesn't already exist it is created. By default files created are generally readable by everyone, but if you pass :const:`~gi.repository.Gio.FileCreateFlags.PRIVATE` in ``flags`` the file will be made readable only to the current user, to the level that is supported on the target filesystem. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. Some file systems don't allow all file names, and may return an :const:`~gi.repository.Gio.IOErrorEnum.INVALID_FILENAME` error. If the file is a directory the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: append_to_async(flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously opens ``file`` for appending. For more details, see :func:`~gi.repository.Gio.File.append_to` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.append_to_finish` to get the result of the operation. :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: append_to_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileOutputStream Finishes an asynchronous file append operation started with :func:`~gi.repository.Gio.File.append_to_async`. :param res: :obj:`~gi.repository.Gio.AsyncResult` .. method:: create(flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileOutputStream Creates a new file and returns an output stream for writing to it. The file must not already exist. By default files created are generally readable by everyone, but if you pass :const:`~gi.repository.Gio.FileCreateFlags.PRIVATE` in ``flags`` the file will be made readable only to the current user, to the level that is supported on the target filesystem. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If a file or directory with this name already exists the :const:`~gi.repository.Gio.IOErrorEnum.EXISTS` error will be returned. Some file systems don't allow all file names, and may return an :const:`~gi.repository.Gio.IOErrorEnum.INVALID_FILENAME` error, and if the name is to long :const:`~gi.repository.Gio.IOErrorEnum.FILENAME_TOO_LONG` will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: create_async(flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a new file and returns an output stream for writing to it. The file must not already exist. For more details, see :func:`~gi.repository.Gio.File.create` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.create_finish` to get the result of the operation. :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: create_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileOutputStream Finishes an asynchronous file create operation started with :func:`~gi.repository.Gio.File.create_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: create_readwrite(flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileIOStream Creates a new file and returns a stream for reading and writing to it. The file must not already exist. By default files created are generally readable by everyone, but if you pass :const:`~gi.repository.Gio.FileCreateFlags.PRIVATE` in ``flags`` the file will be made readable only to the current user, to the level that is supported on the target filesystem. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If a file or directory with this name already exists, the :const:`~gi.repository.Gio.IOErrorEnum.EXISTS` error will be returned. Some file systems don't allow all file names, and may return an :const:`~gi.repository.Gio.IOErrorEnum.INVALID_FILENAME` error, and if the name is too long, :const:`~gi.repository.Gio.IOErrorEnum.FILENAME_TOO_LONG` will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing. .. versionadded:: 2.22 :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: create_readwrite_async(flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a new file and returns a stream for reading and writing to it. The file must not already exist. For more details, see :func:`~gi.repository.Gio.File.create_readwrite` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.create_readwrite_finish` to get the result of the operation. .. versionadded:: 2.22 :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: create_readwrite_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileIOStream Finishes an asynchronous file create operation started with :func:`~gi.repository.Gio.File.create_readwrite_async`. .. versionadded:: 2.22 :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: delete(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Deletes a file. If the ``file`` is a directory, it will only be deleted if it is empty. This has the same semantics as :func:`~gi.repository.GLib.unlink`. If ``file`` doesn’t exist, :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` will be returned. This allows for deletion to be implemented avoiding `time-of-check to time-of-use races `__\: .. code-block:: :dedent: g_autoptr(GError) local_error = NULL; if (!g_file_delete (my_file, my_cancellable, &local_error) && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) { // deletion failed for some reason other than the file not existing: // so report the error g_warning ("Failed to delete %s: %s", g_file_peek_path (my_file), local_error->message); } If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: delete_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously delete a file. If the ``file`` is a directory, it will only be deleted if it is empty. This has the same semantics as :func:`~gi.repository.GLib.unlink`. .. versionadded:: 2.34 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: delete_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes deleting a file started with :func:`~gi.repository.Gio.File.delete_async`. .. versionadded:: 2.34 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: dup() -> ~gi.repository.Gio.File Duplicates a :obj:`~gi.repository.Gio.File` handle. This operation does not duplicate the actual file or directory represented by the :obj:`~gi.repository.Gio.File`\; see :func:`~gi.repository.Gio.File.copy` if attempting to copy a file. :func:`~gi.repository.Gio.File.dup` is useful when a second handle is needed to the same underlying file, for use in a separate thread (:obj:`~gi.repository.Gio.File` is not thread-safe). For use within the same thread, use :func:`~gi.repository.GObject.GObject.Object.ref` to increment the existing object’s reference count. This call does no blocking I/O. .. method:: eject_mountable(flags: ~gi.repository.Gio.MountUnmountFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts an asynchronous eject on a mountable. When this operation has completed, ``callback`` will be called with ``user_user`` data, and the operation can be finalized with :func:`~gi.repository.Gio.File.eject_mountable_finish`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. .. deprecated:: 2.22 Use :func:`~gi.repository.Gio.File.eject_mountable_with_operation` instead. :param flags: flags affecting the operation :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: eject_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous eject operation started by :func:`~gi.repository.Gio.File.eject_mountable`. .. deprecated:: 2.22 Use :func:`~gi.repository.Gio.File.eject_mountable_with_operation_finish` instead. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: eject_mountable_with_operation(flags: ~gi.repository.Gio.MountUnmountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts an asynchronous eject on a mountable. When this operation has completed, ``callback`` will be called with ``user_user`` data, and the operation can be finalized with :func:`~gi.repository.Gio.File.eject_mountable_with_operation_finish`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. .. versionadded:: 2.22 :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: eject_mountable_with_operation_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous eject operation started by :func:`~gi.repository.Gio.File.eject_mountable_with_operation`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: enumerate_children(attributes: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileEnumerator Gets the requested information about the files in a directory. The result is a :obj:`~gi.repository.Gio.FileEnumerator` object that will give out :obj:`~gi.repository.Gio.FileInfo` objects for all the files in the directory. The ``attributes`` value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. ``attributes`` should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*\" means all attributes in the standard namespace. An example attribute query be "standard::\*,owner::user". The standard attributes are available as defines, like :const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_NAME`. :const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_NAME` should always be specified if you plan to call :func:`~gi.repository.Gio.FileEnumerator.get_child` or :func:`~gi.repository.Gio.FileEnumerator.iterate` on the returned enumerator. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. If the file is not a directory, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_DIRECTORY` error will be returned. Other errors are possible too. :param attributes: an attribute query string :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: enumerate_children_async(attributes: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously gets the requested information about the files in a directory. The result is a :obj:`~gi.repository.Gio.FileEnumerator` object that will give out :obj:`~gi.repository.Gio.FileInfo` objects for all the files in the directory. For more details, see :func:`~gi.repository.Gio.File.enumerate_children` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.enumerate_children_finish` to get the result of the operation. :param attributes: an attribute query string :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: enumerate_children_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileEnumerator Finishes an async enumerate children operation. See :func:`~gi.repository.Gio.File.enumerate_children_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: equal(file2: ~gi.repository.Gio.File) -> bool Checks if the two given :obj:`~gi.repository.Gio.File` refer to the same file. Note that two :obj:`~gi.repository.Gio.File` 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. :param file2: the second :obj:`~gi.repository.Gio.File` .. method:: find_enclosing_mount(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.Mount Gets a :obj:`~gi.repository.Gio.Mount` for the :obj:`~gi.repository.Gio.File`\. :obj:`~gi.repository.Gio.Mount` is returned only for user interesting locations, see :obj:`~gi.repository.Gio.VolumeMonitor`\. If the ``GFileIface`` for ``file`` does not have a ``mount``, ``error`` will be set to :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` and :const:`None` ``will`` be returned. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: find_enclosing_mount_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously gets the mount for the file. For more details, see :func:`~gi.repository.Gio.File.find_enclosing_mount` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.find_enclosing_mount_finish` to get the result of the operation. :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: find_enclosing_mount_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.Mount Finishes an asynchronous find mount request. See :func:`~gi.repository.Gio.File.find_enclosing_mount_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: get_basename() -> str | None Gets the base name (the last component of the path) for a given :obj:`~gi.repository.Gio.File`\. 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 :const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME` attribute with :func:`~gi.repository.Gio.File.query_info`. This call does no blocking I/O. .. method:: get_child(name: str) -> ~gi.repository.Gio.File Gets a child of ``file`` with basename equal to ``name``\. Note that the file with that specific name might not exist, but you can still have a :obj:`~gi.repository.Gio.File` that points to it. You can use this for instance to create that file. This call does no blocking I/O. :param name: string containing the child's basename .. method:: get_child_for_display_name(display_name: str) -> ~gi.repository.Gio.File Gets the child of ``file`` for a given ``display_name`` (i.e. a UTF-8 version of the name). If this function fails, it returns :const:`None` and ``error`` will be set. This is very useful when constructing a :obj:`~gi.repository.Gio.File` for a new file and the user entered the filename in the user interface, for instance when you select a directory and type a filename in the file selector. This call does no blocking I/O. :param display_name: string to a possible child .. method:: get_parent() -> ~gi.repository.Gio.File | None Gets the parent directory for the ``file``\. If the ``file`` represents the root directory of the file system, then :const:`None` will be returned. This call does no blocking I/O. .. method:: get_parse_name() -> str 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 :obj:`~gi.repository.Gio.File` back using :func:`~gi.repository.Gio.File.parse_name`. This is generally used to show the :obj:`~gi.repository.Gio.File` 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 UTF-8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF-8 characters unescaped). This call does no blocking I/O. .. method:: get_path() -> str | None Gets the local pathname for :obj:`~gi.repository.Gio.File`\, if one exists. If non-:const:`None`, this is guaranteed to be an absolute, canonical path. It might contain symlinks. This call does no blocking I/O. .. method:: get_relative_path(descendant: ~gi.repository.Gio.File) -> str | None Gets the path for ``descendant`` relative to ``parent``\. This call does no blocking I/O. :param descendant: input :obj:`~gi.repository.Gio.File` .. method:: get_uri() -> str Gets the URI for the ``file``\. This call does no blocking I/O. .. method:: get_uri_scheme() -> str | None Gets the URI scheme for a :obj:`~gi.repository.Gio.File`\. RFC 3986 decodes the scheme as: .. code-block:: :dedent: URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] Common schemes include "file", "http", "ftp", etc. The scheme can be different from the one used to construct the :obj:`~gi.repository.Gio.File`\, in that it might be replaced with one that is logically equivalent to the :obj:`~gi.repository.Gio.File`\. This call does no blocking I/O. .. method:: has_parent(parent: ~gi.repository.Gio.File | None = None) -> bool Checks if ``file`` has a parent, and optionally, if it is ``parent``\. If ``parent`` is :const:`None` then this function returns :const:`True` if ``file`` has any parent at all. If ``parent`` is non-:const:`None` then :const:`True` is only returned if ``file`` is an immediate child of ``parent``\. .. versionadded:: 2.24 :param parent: the parent to check for, or :const:`None` .. method:: has_prefix(prefix: ~gi.repository.Gio.File) -> bool Checks whether ``file`` has the prefix specified by ``prefix``\. In other words, if the names of initial elements of ``file``\'s pathname match ``prefix``\. Only full pathname elements are matched, so a path like /foo is not considered a prefix of /foobar, only of /foo/bar. A :obj:`~gi.repository.Gio.File` is not a prefix of itself. If you want to check for equality, use :func:`~gi.repository.Gio.File.equal`. This call does no I/O, as it works purely on names. As such it can sometimes return :const:`False` even if ``file`` is inside a ``prefix`` (from a filesystem point of view), because the prefix of ``file`` is an alias of ``prefix``\. :param prefix: input :obj:`~gi.repository.Gio.File` .. method:: has_uri_scheme(uri_scheme: str) -> bool Checks to see if a :obj:`~gi.repository.Gio.File` has a given URI scheme. This call does no blocking I/O. :param uri_scheme: a string containing a URI scheme .. method:: hash() -> int Creates a hash value for a :obj:`~gi.repository.Gio.File`\. This call does no blocking I/O. .. method:: is_native() -> bool Checks to see if a file is native to the platform. A native file is one expressed in the platform-native filename format, e.g. "C:\Windows" or "/usr/bin/". This does not mean the file is local, as it might be on a locally mounted remote filesystem. On some systems non-native files may be available using the native filesystem via a userspace filesystem (FUSE), in these cases this call will return :const:`False`, but :func:`~gi.repository.Gio.File.get_path` will still return a native path. This call does no blocking I/O. .. method:: load_bytes(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~typing.Tuple[~gi.repository.GLib.Bytes, str | None] Loads the contents of ``file`` and returns it as :obj:`~gi.repository.GLib.Bytes`\. If ``file`` is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling :func:`~gi.repository.Gio.File.load_contents` and :func:`~gi.repository.GLib.Bytes.new_take`. For resources, ``etag_out`` will be set to :const:`None`. The data contained in the resulting :obj:`~gi.repository.GLib.Bytes` is always zero-terminated, but this is not included in the :obj:`~gi.repository.GLib.Bytes` length. The resulting :obj:`~gi.repository.GLib.Bytes` should be freed with :func:`~gi.repository.GLib.Bytes.unref` when no longer in use. .. versionadded:: 2.56 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` .. method:: load_bytes_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously loads the contents of ``file`` as :obj:`~gi.repository.GLib.Bytes`\. If ``file`` is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling :func:`~gi.repository.Gio.File.load_contents_async` and :func:`~gi.repository.GLib.Bytes.new_take`. ``callback`` should call :func:`~gi.repository.Gio.File.load_bytes_finish` to get the result of this asynchronous operation. See :func:`~gi.repository.Gio.File.load_bytes` for more information. .. versionadded:: 2.56 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: load_bytes_finish(result: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[~gi.repository.GLib.Bytes, str | None] Completes an asynchronous request to :func:`~gi.repository.Gio.File.load_bytes_async`. For resources, ``etag_out`` will be set to :const:`None`. The data contained in the resulting :obj:`~gi.repository.GLib.Bytes` is always zero-terminated, but this is not included in the :obj:`~gi.repository.GLib.Bytes` length. The resulting :obj:`~gi.repository.GLib.Bytes` should be freed with :func:`~gi.repository.GLib.Bytes.unref` when no longer in use. See :func:`~gi.repository.Gio.File.load_bytes` for more information. .. versionadded:: 2.56 :param result: a :obj:`~gi.repository.Gio.AsyncResult` provided to the callback .. method:: load_contents(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~typing.Tuple[bool, list[int], str | None] Loads the content of the file into memory. The data is always zero-terminated, but this is not included in the resultant ``length``\. The returned ``contents`` should be freed with :func:`~gi.repository.GLib.free` when no longer needed. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: load_contents_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts an asynchronous load of the ``file``\'s contents. For more details, see :func:`~gi.repository.Gio.File.load_contents` which is the synchronous version of this call. When the load operation has completed, ``callback`` will be called with ``user`` data. To finish the operation, call :func:`~gi.repository.Gio.File.load_contents_finish` with the :obj:`~gi.repository.Gio.AsyncResult` returned by the ``callback``\. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: load_contents_finish(res: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[bool, list[int], str | None] Finishes an asynchronous load of the ``file``\'s contents. The contents are placed in ``contents``\, and ``length`` is set to the size of the ``contents`` string. The ``contents`` should be freed with :func:`~gi.repository.GLib.free` when no longer needed. If ``etag_out`` is present, it will be set to the new entity tag for the ``file``\. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: load_partial_contents_finish(res: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[bool, list[int], str | None] Finishes an asynchronous partial load operation that was started with :func:`~gi.repository.Gio.File.load_partial_contents_async`. The data is always zero-terminated, but this is not included in the resultant ``length``\. The returned ``contents`` should be freed with :func:`~gi.repository.GLib.free` when no longer needed. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: make_directory(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Creates a directory. Note that this will only create a child directory of the immediate parent directory of the path or URI given by the :obj:`~gi.repository.Gio.File`\. To recursively create directories, see :func:`~gi.repository.Gio.File.make_directory_with_parents`. This function will fail if the parent directory does not exist, setting ``error`` to :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND`. If the file system doesn't support creating directories, this function will fail, setting ``error`` to :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED`. For a local :obj:`~gi.repository.Gio.File` the newly created directory will have the default (current) ownership and permissions of the current process. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: make_directory_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a directory. .. versionadded:: 2.38 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: make_directory_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous directory creation, started with :func:`~gi.repository.Gio.File.make_directory_async`. .. versionadded:: 2.38 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: make_directory_with_parents(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Creates a directory and any parent directories that may not exist similar to 'mkdir -p'. If the file system does not support creating directories, this function will fail, setting ``error`` to :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED`. If the directory itself already exists, this function will fail setting ``error`` to :const:`~gi.repository.Gio.IOErrorEnum.EXISTS`, unlike the similar :func:`~gi.repository.GLib.mkdir_with_parents`. For a local :obj:`~gi.repository.Gio.File` the newly created directories will have the default (current) ownership and permissions of the current process. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. .. versionadded:: 2.18 :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: make_symbolic_link(symlink_value: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Creates a symbolic link named ``file`` which contains the string ``symlink_value``\. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param symlink_value: a string with the path for the target of the new symlink :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: make_symbolic_link_async(symlink_value: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a symbolic link named ``file`` which contains the string ``symlink_value``\. .. versionadded:: 2.74 :param symlink_value: a string with the path for the target of the new symlink :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: make_symbolic_link_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous symbolic link creation, started with :func:`~gi.repository.Gio.File.make_symbolic_link_async`. .. versionadded:: 2.74 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: measure_disk_usage(flags: ~gi.repository.Gio.FileMeasureFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, progress_callback: ~typing.Callable[[bool, int, int, int, ~typing.Any], None] | None = None, progress_data: ~typing.Any = None) -> ~typing.Tuple[bool, int, int, int] Recursively measures the disk usage of ``file``\. This is essentially an analog of the 'du' command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links). By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless :const:`~gi.repository.Gio.FileMeasureFlags.REPORT_ANY_ERROR` is given in ``flags``\. The returned size, ``disk_usage``\, is in bytes and should be formatted with :func:`~gi.repository.GLib.format_size` in order to get something reasonable for showing in a user interface. ``progress_callback`` and ``progress_data`` can be given to request periodic progress updates while scanning. See the documentation for :obj:`~gi.repository.Gio.FileMeasureProgressCallback` for information about when and how the callback will be invoked. .. versionadded:: 2.38 :param flags: :obj:`~gi.repository.Gio.FileMeasureFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` :param progress_callback: a :obj:`~gi.repository.Gio.FileMeasureProgressCallback` :param progress_data: user_data for ``progress_callback`` .. method:: measure_disk_usage_finish(result: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[bool, int, int, int] Collects the results from an earlier call to :func:`~gi.repository.Gio.File.measure_disk_usage_async`. See :func:`~gi.repository.Gio.File.measure_disk_usage` for more information. .. versionadded:: 2.38 :param result: the :obj:`~gi.repository.Gio.AsyncResult` passed to your :obj:`~gi.repository.Gio.AsyncReadyCallback` .. method:: monitor(flags: ~gi.repository.Gio.FileMonitorFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileMonitor Obtains a file or directory monitor for the given file, depending on the type of the file. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. .. versionadded:: 2.18 :param flags: a set of :obj:`~gi.repository.Gio.FileMonitorFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: monitor_directory(flags: ~gi.repository.Gio.FileMonitorFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileMonitor Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. It does not make sense for ``flags`` to contain :const:`~gi.repository.Gio.FileMonitorFlags.WATCH_HARD_LINKS`, since hard links can not be made to directories. It is not possible to monitor all the files in a directory for changes made via hard links; if you want to do this then you must register individual watches with :func:`~gi.repository.Gio.File.monitor`. :param flags: a set of :obj:`~gi.repository.Gio.FileMonitorFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: monitor_file(flags: ~gi.repository.Gio.FileMonitorFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileMonitor Obtains a file monitor for the given file. If no file notification mechanism exists, then regular polling of the file is used. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If ``flags`` contains :const:`~gi.repository.Gio.FileMonitorFlags.WATCH_HARD_LINKS` then the monitor will also attempt to report changes made to the file via another filename (ie, a hard link). Without this flag, you can only rely on changes made through the filename contained in ``file`` to be reported. Using this flag may result in an increase in resource usage, and may not have any effect depending on the :obj:`~gi.repository.Gio.FileMonitor` backend and/or filesystem type. :param flags: a set of :obj:`~gi.repository.Gio.FileMonitorFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: mount_enclosing_volume(flags: ~gi.repository.Gio.MountMountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts a ``mount_operation``\, mounting the volume that contains the file ``location``\. When this operation has completed, ``callback`` will be called with ``user_user`` data, and the operation can be finalized with :func:`~gi.repository.Gio.File.mount_enclosing_volume_finish`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation` or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied, or :const:`None` :param user_data: the data to pass to callback function .. method:: mount_enclosing_volume_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a mount operation started by :func:`~gi.repository.Gio.File.mount_enclosing_volume`. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: mount_mountable(flags: ~gi.repository.Gio.MountMountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Mounts a file of type G_FILE_TYPE_MOUNTABLE. Using ``mount_operation``\, you can request callbacks when, for instance, passwords are needed during authentication. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.mount_mountable_finish` to get the result of the operation. :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: mount_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.File Finishes a mount operation. See :func:`~gi.repository.Gio.File.mount_mountable` for details. Finish an asynchronous mount operation that was started with :func:`~gi.repository.Gio.File.mount_mountable`. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: move(destination: ~gi.repository.Gio.File, flags: ~gi.repository.Gio.FileCopyFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, progress_callback: ~typing.Callable[[int, int, ~typing.Any], None] | None = None, progress_callback_data: ~typing.Any = None) -> bool Tries to move the file or directory ``source`` to the location specified by ``destination``\. If native move operations are supported then this is used, otherwise a copy + delete fallback is used. The native implementation may support moving directories (for instance on moves inside the same filesystem), but the fallback code does not. If the flag :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is specified an already existing ``destination`` file is overwritten. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If ``progress_callback`` is not :const:`None`, then the operation can be monitored by setting this to a :obj:`~gi.repository.Gio.FileProgressCallback` function. ``progress_callback_data`` will be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation. If the ``source`` file does not exist, then the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error is returned, independent on the status of the ``destination``\. If :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is not specified and the target exists, then the error :const:`~gi.repository.Gio.IOErrorEnum.EXISTS` is returned. If trying to overwrite a file over a directory, the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error is returned. If trying to overwrite a directory with a directory the :const:`~gi.repository.Gio.IOErrorEnum.WOULD_MERGE` error is returned. If the source is a directory and the target does not exist, or :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is specified and the target is a file, then the :const:`~gi.repository.Gio.IOErrorEnum.WOULD_RECURSE` error may be returned (if the native move operation isn't available). :param destination: :obj:`~gi.repository.Gio.File` pointing to the destination location :param flags: set of :obj:`~gi.repository.Gio.FileCopyFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param progress_callback: :obj:`~gi.repository.Gio.FileProgressCallback` function for updates :param progress_callback_data: gpointer to user data for the callback function .. method:: move_async(destination: ~gi.repository.Gio.File, flags: ~gi.repository.Gio.FileCopyFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None, progress_callback_closure: ~gi.repository.GObject.Closure | None, ready_callback_closure: ~gi.repository.GObject.Closure) -> None Asynchronously moves a file ``source`` to the location of ``destination``\. For details of the behaviour, see :func:`~gi.repository.Gio.File.move`. If ``progress_callback`` is not :const:`None`, then that function that will be called just like in :func:`~gi.repository.Gio.File.move`. The callback will run in the default main context of the thread calling :func:`~gi.repository.Gio.File.move_async` — the same context as ``callback`` is run in. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.move_finish` to get the result of the operation. .. versionadded:: 2.72 :param destination: :obj:`~gi.repository.Gio.File` pointing to the destination location :param flags: set of :obj:`~gi.repository.Gio.FileCopyFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param progress_callback_closure: :param ready_callback_closure: .. method:: move_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous file movement, started with :func:`~gi.repository.Gio.File.move_async`. .. versionadded:: 2.72 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. classmethod:: new_build_filenamev() -> ~gi.repository.Gio.File Constructs a :obj:`~gi.repository.Gio.File` from a vector of elements using the correct separator for filenames. Using this function is equivalent to calling :func:`~gi.repository.GLib.build_filenamev`, followed by :func:`~gi.repository.Gio.File.new_for_path` on the result. .. versionadded:: 2.78 .. classmethod:: new_for_commandline_arg() -> ~gi.repository.Gio.File Creates a :obj:`~gi.repository.Gio.File` 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. Note that on Windows, this function expects its argument to be in UTF-8 -- not the system code page. This means that you should not use this function with string from argv as it is passed to main(). g_win32_get_command_line() will return a UTF-8 version of the commandline. :obj:`~gi.repository.Gio.Application` also uses UTF-8 but :func:`~gi.repository.Gio.ApplicationCommandLine.create_file_for_arg` may be more useful for you there. It is also always possible to use this function with :obj:`~gi.repository.GLib.OptionContext` arguments of type %G_OPTION_ARG_FILENAME. .. classmethod:: new_for_commandline_arg_and_cwd(cwd: str) -> ~gi.repository.Gio.File Creates a :obj:`~gi.repository.Gio.File` with the given argument from the command line. This function is similar to :func:`~gi.repository.Gio.File.new_for_commandline_arg` except that it allows for passing the current working directory as an argument instead of using the current working directory of the process. This is useful if the commandline argument was given in a context other than the invocation of the current process. See also :func:`~gi.repository.Gio.ApplicationCommandLine.create_file_for_arg`. .. versionadded:: 2.36 :param cwd: the current working directory of the commandline .. classmethod:: new_for_path() -> ~gi.repository.Gio.File Constructs a :obj:`~gi.repository.Gio.File` for a given path. This operation never fails, but the returned object might not support any I/O operation if ``path`` is malformed. .. classmethod:: new_for_uri() -> ~gi.repository.Gio.File Constructs a :obj:`~gi.repository.Gio.File` 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. .. classmethod:: new_tmp() -> ~typing.Tuple[~gi.repository.Gio.File, ~gi.repository.Gio.FileIOStream] Opens a file in the preferred directory for temporary files (as returned by :func:`~gi.repository.GLib.get_tmp_dir`) and returns a :obj:`~gi.repository.Gio.File` and :obj:`~gi.repository.Gio.FileIOStream` pointing to it. ``tmpl`` should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is :const:`None`, a default template is used. Unlike the other :obj:`~gi.repository.Gio.File` constructors, this will return :const:`None` if a temporary file could not be created. .. versionadded:: 2.32 .. classmethod:: new_tmp_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously opens a file in the preferred directory for temporary files (as returned by :func:`~gi.repository.GLib.get_tmp_dir`) as :func:`~gi.repository.Gio.File.new_tmp`. ``tmpl`` should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is :const:`None`, a default template is used. .. versionadded:: 2.74 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is done :param user_data: data to pass to ``callback`` .. classmethod:: new_tmp_dir_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a directory in the preferred directory for temporary files (as returned by :func:`~gi.repository.GLib.get_tmp_dir`) as :func:`~gi.repository.GLib.Dir.make_tmp`. ``tmpl`` should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is :const:`None`, a default template is used. .. versionadded:: 2.74 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is done :param user_data: data to pass to ``callback`` .. classmethod:: new_tmp_dir_finish() -> ~gi.repository.Gio.File Finishes a temporary directory creation started by :func:`~gi.repository.Gio.File.new_tmp_dir_async`. .. versionadded:: 2.74 .. classmethod:: new_tmp_finish() -> ~typing.Tuple[~gi.repository.Gio.File, ~gi.repository.Gio.FileIOStream] Finishes a temporary file creation started by :func:`~gi.repository.Gio.File.new_tmp_async`. .. versionadded:: 2.74 .. method:: open_readwrite(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileIOStream Opens an existing file for reading and writing. The result is a :obj:`~gi.repository.Gio.FileIOStream` that can be used to read and write the contents of the file. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. If the file is a directory, the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing. .. versionadded:: 2.22 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` .. method:: open_readwrite_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously opens ``file`` for reading and writing. For more details, see :func:`~gi.repository.Gio.File.open_readwrite` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.open_readwrite_finish` to get the result of the operation. .. versionadded:: 2.22 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: open_readwrite_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileIOStream Finishes an asynchronous file read operation started with :func:`~gi.repository.Gio.File.open_readwrite_async`. .. versionadded:: 2.22 :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. classmethod:: parse_name() -> ~gi.repository.Gio.File Constructs a :obj:`~gi.repository.Gio.File` with the given ``parse_name`` (i.e. something given by :func:`~gi.repository.Gio.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. .. method:: peek_path() -> str | None Exactly like :func:`~gi.repository.Gio.File.get_path`, but caches the result via :func:`~gi.repository.GObject.GObject.Object.set_qdata_full`. This is useful for example in C applications which mix ``g_file_*`` APIs with native ones. It also avoids an extra duplicated string when possible, so will be generally more efficient. This call does no blocking I/O. .. versionadded:: 2.56 .. method:: poll_mountable(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Polls a file of type :const:`~gi.repository.Gio.FileType.MOUNTABLE`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.mount_mountable_finish` to get the result of the operation. .. versionadded:: 2.22 :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied, or :const:`None` :param user_data: the data to pass to callback function .. method:: poll_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a poll operation. See :func:`~gi.repository.Gio.File.poll_mountable` for details. Finish an asynchronous poll operation that was polled with :func:`~gi.repository.Gio.File.poll_mountable`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: query_default_handler(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.AppInfo Returns the :obj:`~gi.repository.Gio.AppInfo` that is registered as the default application to handle the file specified by ``file``\. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: query_default_handler_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Async version of :func:`~gi.repository.Gio.File.query_default_handler`. .. versionadded:: 2.60 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is done :param user_data: data to pass to ``callback`` .. method:: query_default_handler_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.AppInfo Finishes a :func:`~gi.repository.Gio.File.query_default_handler_async` operation. .. versionadded:: 2.60 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: query_exists(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Utility function to check if a particular file exists. This is implemented using :func:`~gi.repository.Gio.File.query_info` and as such does blocking I/O. Note that in many cases it is `racy to first check for file existence `__ and then execute something based on the outcome of that, because the file might have been created or removed in between the operations. The general approach to handling that is to not check, but just do the operation and handle the errors as they come. As an example of race-free checking, take the case of reading a file, and if it doesn't exist, creating it. There are two racy versions: read it, and on error create it; and: check if it exists, if not create it. These can both result in two processes creating the file (with perhaps a partially written file as the result). The correct approach is to always try to create the file with :func:`~gi.repository.Gio.File.create` which will either atomically create the file or fail with a :const:`~gi.repository.Gio.IOErrorEnum.EXISTS` error. However, in many cases an existence check is useful in a user interface, for instance to make a menu item sensitive/insensitive, so that you don't have to fool users that something is possible and then just show an error dialog. If you do this, you should make sure to also handle the errors that can happen due to races when you execute the operation. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: query_file_type(flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileType Utility function to inspect the :obj:`~gi.repository.Gio.FileType` of a file. This is implemented using :func:`~gi.repository.Gio.File.query_info` and as such does blocking I/O. The primary use case of this method is to check if a file is a regular file, directory, or symlink. .. versionadded:: 2.18 :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` passed to :func:`~gi.repository.Gio.File.query_info` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: query_filesystem_info(attributes: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInfo Similar to :func:`~gi.repository.Gio.File.query_info`, but obtains information about the filesystem the ``file`` is on, rather than the file itself. For instance the amount of space available and the type of the filesystem. The ``attributes`` value is a string that specifies the attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. ``attributes`` should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "filesystem::*\" means all attributes in the filesystem namespace. The standard namespace for filesystem attributes is "filesystem". Common attributes of interest are :const:`~gi.repository.Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE` (the total size of the filesystem in bytes), :const:`~gi.repository.Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE` (number of bytes available), and :const:`~gi.repository.Gio.FILE_ATTRIBUTE_FILESYSTEM_TYPE` (type of the filesystem). If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param attributes: an attribute query string :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: query_filesystem_info_async(attributes: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously gets the requested information about the filesystem that the specified ``file`` is on. The result is a :obj:`~gi.repository.Gio.FileInfo` object that contains key-value attributes (such as type or size for the file). For more details, see :func:`~gi.repository.Gio.File.query_filesystem_info` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.query_info_finish` to get the result of the operation. :param attributes: an attribute query string :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: query_filesystem_info_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInfo Finishes an asynchronous filesystem info query. See :func:`~gi.repository.Gio.File.query_filesystem_info_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: query_info(attributes: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInfo Gets the requested information about specified ``file``\. The result is a :obj:`~gi.repository.Gio.FileInfo` object that contains key-value attributes (such as the type or size of the file). The ``attributes`` value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. ``attributes`` should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*\" means all attributes in the standard namespace. An example attribute query be "standard::\*,owner::user". The standard attributes are available as defines, like :const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_NAME`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass :const:`~gi.repository.Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS` in ``flags`` the information about the symlink itself will be returned. Also, for symlinks that point to non-existing files the information about the symlink itself will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param attributes: an attribute query string :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: query_info_async(attributes: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously gets the requested information about specified ``file``\. The result is a :obj:`~gi.repository.Gio.FileInfo` object that contains key-value attributes (such as type or size for the file). For more details, see :func:`~gi.repository.Gio.File.query_info` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.query_info_finish` to get the result of the operation. :param attributes: an attribute query string :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: query_info_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInfo Finishes an asynchronous file info query. See :func:`~gi.repository.Gio.File.query_info_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: query_settable_attributes(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileAttributeInfoList Obtain the list of settable attributes for the file. Returns the type and full attribute name of all the attributes that can be set on this file. This doesn't mean setting it will always succeed though, you might get an access failure, or some specific file may not support a specific attribute. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: query_writable_namespaces(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileAttributeInfoList Obtain the list of attribute namespaces where new attributes can be created by a user. An example of this is extended attributes (in the "xattr" namespace). If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: read(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInputStream Opens a file for reading. The result is a :obj:`~gi.repository.Gio.FileInputStream` that can be used to read the contents of the file. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. If the file is a directory, the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` .. method:: read_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously opens ``file`` for reading. For more details, see :func:`~gi.repository.Gio.File.read` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.read_finish` to get the result of the operation. :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: read_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInputStream Finishes an asynchronous file read operation started with :func:`~gi.repository.Gio.File.read_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: replace(etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileOutputStream Returns an output stream for overwriting the file, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created. This will try to replace the file in the safest way possible so that any errors during the writing will not affect an already existing copy of the file. For instance, for local files it may write to a temporary file and then atomically rename over the destination when the stream is closed. By default files created are generally readable by everyone, but if you pass :const:`~gi.repository.Gio.FileCreateFlags.PRIVATE` in ``flags`` the file will be made readable only to the current user, to the level that is supported on the target filesystem. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If you pass in a non-:const:`None` ``etag`` value and ``file`` already exists, then this value is compared to the current entity tag of the file, and if they differ an :const:`~gi.repository.Gio.IOErrorEnum.WRONG_ETAG` error is returned. This generally means that the file has been changed since you last read it. You can get the new etag from :func:`~gi.repository.Gio.FileOutputStream.get_etag` after you've finished writing and closed the :obj:`~gi.repository.Gio.FileOutputStream`\. When you load a new file you can use :func:`~gi.repository.Gio.FileInputStream.query_info` to get the etag of the file. If ``make_backup`` is :const:`True`, this function will attempt to make a backup of the current file before overwriting it. If this fails a :const:`~gi.repository.Gio.IOErrorEnum.CANT_CREATE_BACKUP` error will be returned. If you want to replace anyway, try again with ``make_backup`` set to :const:`False`. If the file is a directory the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error will be returned, and if the file is some other form of non-regular file then a :const:`~gi.repository.Gio.IOErrorEnum.NOT_REGULAR_FILE` error will be returned. Some file systems don't allow all file names, and may return an :const:`~gi.repository.Gio.IOErrorEnum.INVALID_FILENAME` error, and if the name is to long :const:`~gi.repository.Gio.IOErrorEnum.FILENAME_TOO_LONG` will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param etag: an optional `entity tag <#entity-tags>`__ for the current :obj:`~gi.repository.Gio.File`\, or :obj:`~gi.repository.None` to ignore :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: replace_async(etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first. For more details, see :func:`~gi.repository.Gio.File.replace` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.replace_finish` to get the result of the operation. :param etag: an `entity tag <#entity-tags>`__ for the current :obj:`~gi.repository.Gio.File`\, or :const:`None` to ignore :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: replace_contents(contents: list[int], etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~typing.Tuple[bool, str | None] Replaces the contents of ``file`` with ``contents`` of ``length`` bytes. If ``etag`` is specified (not :const:`None`), any existing file must have that etag, or the error :const:`~gi.repository.Gio.IOErrorEnum.WRONG_ETAG` will be returned. If ``make_backup`` is :const:`True`, this function will attempt to make a backup of ``file``\. Internally, it uses :func:`~gi.repository.Gio.File.replace`, so will try to replace the file contents in the safest way possible. For example, atomic renames are used when replacing local files’ contents. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. The returned ``new_etag`` can be used to verify that the file hasn't changed the next time it is saved over. :param contents: a string containing the new contents for ``file`` :param etag: the old `entity-tag <#entity-tags>`__ for the document, or :const:`None` :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: replace_contents_async(contents: list[int], etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts an asynchronous replacement of ``file`` with the given ``contents`` of ``length`` bytes. ``etag`` will replace the document's current entity tag. When this operation has completed, ``callback`` will be called with ``user_user`` data, and the operation can be finalized with :func:`~gi.repository.Gio.File.replace_contents_finish`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If ``make_backup`` is :const:`True`, this function will attempt to make a backup of ``file``\. Note that no copy of ``contents`` will be made, so it must stay valid until ``callback`` is called. See :func:`~gi.repository.Gio.File.replace_contents_bytes_async` for a :obj:`~gi.repository.GLib.Bytes` version that will automatically hold a reference to the contents (without copying) for the duration of the call. :param contents: string of contents to replace the file with :param etag: a new `entity tag <#entity-tags>`__ for the ``file``\, or :const:`None` :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: replace_contents_bytes_async(contents: ~gi.repository.GLib.Bytes, etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Same as :func:`~gi.repository.Gio.File.replace_contents_async` but takes a :obj:`~gi.repository.GLib.Bytes` input instead. This function will keep a ref on ``contents`` until the operation is done. Unlike :func:`~gi.repository.Gio.File.replace_contents_async` this allows forgetting about the content without waiting for the callback. When this operation has completed, ``callback`` will be called with ``user_user`` data, and the operation can be finalized with :func:`~gi.repository.Gio.File.replace_contents_finish`. .. versionadded:: 2.40 :param contents: a :obj:`~gi.repository.GLib.Bytes` :param etag: a new `entity tag <#entity-tags>`__ for the ``file``\, or :const:`None` :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: replace_contents_finish(res: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[bool, str | None] Finishes an asynchronous replace of the given ``file``\. See :func:`~gi.repository.Gio.File.replace_contents_async`. Sets ``new_etag`` to the new entity tag for the document, if present. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: replace_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileOutputStream Finishes an asynchronous file replace operation started with :func:`~gi.repository.Gio.File.replace_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: replace_readwrite(etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileIOStream Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created. For details about the behaviour, see :func:`~gi.repository.Gio.File.replace` which does the same thing but returns an output stream only. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing. .. versionadded:: 2.22 :param etag: an optional `entity tag <#entity-tags>`__ for the current :obj:`~gi.repository.Gio.File`\, or :obj:`~gi.repository.None` to ignore :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: replace_readwrite_async(etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first. For more details, see :func:`~gi.repository.Gio.File.replace_readwrite` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.replace_readwrite_finish` to get the result of the operation. .. versionadded:: 2.22 :param etag: an `entity tag <#entity-tags>`__ for the current :obj:`~gi.repository.Gio.File`\, or :const:`None` to ignore :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: replace_readwrite_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileIOStream Finishes an asynchronous file replace operation started with :func:`~gi.repository.Gio.File.replace_readwrite_async`. .. versionadded:: 2.22 :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: resolve_relative_path(relative_path: str) -> ~gi.repository.Gio.File Resolves a relative path for ``file`` to an absolute path. This call does no blocking I/O. If the ``relative_path`` is an absolute path name, the resolution is done absolutely (without taking ``file`` path as base). :param relative_path: a given relative path string .. method:: set_attribute(attribute: str, type: ~gi.repository.Gio.FileAttributeType, value_p: ~typing.Any, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sets an attribute in the file with attribute name ``attribute`` to ``value_p``\. Some attributes can be unset by setting ``type`` to :const:`~gi.repository.Gio.FileAttributeType.INVALID` and ``value_p`` to :const:`None`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param attribute: a string containing the attribute's name :param type: The type of the attribute :param value_p: a pointer to the value (or the pointer itself if the type is a pointer type) :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_attribute_byte_string(attribute: str, value: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sets ``attribute`` of type :const:`~gi.repository.Gio.FileAttributeType.BYTE_STRING` to ``value``\. If ``attribute`` is of a different type, this operation will fail, returning :const:`False`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param attribute: a string containing the attribute's name :param value: a string containing the attribute's new value :param flags: a :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_attribute_int32(attribute: str, value: int, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sets ``attribute`` of type :const:`~gi.repository.Gio.FileAttributeType.INT32` to ``value``\. If ``attribute`` is of a different type, this operation will fail. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param attribute: a string containing the attribute's name :param value: a :obj:`int` containing the attribute's new value :param flags: a :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_attribute_int64(attribute: str, value: int, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sets ``attribute`` of type :const:`~gi.repository.Gio.FileAttributeType.INT64` to ``value``\. If ``attribute`` is of a different type, this operation will fail. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param attribute: a string containing the attribute's name :param value: a :obj:`int` containing the attribute's new value :param flags: a :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_attribute_string(attribute: str, value: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sets ``attribute`` of type :const:`~gi.repository.Gio.FileAttributeType.STRING` to ``value``\. If ``attribute`` is of a different type, this operation will fail. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param attribute: a string containing the attribute's name :param value: a string containing the attribute's value :param flags: :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_attribute_uint32(attribute: str, value: int, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sets ``attribute`` of type :const:`~gi.repository.Gio.FileAttributeType.UINT32` to ``value``\. If ``attribute`` is of a different type, this operation will fail. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param attribute: a string containing the attribute's name :param value: a :obj:`int` containing the attribute's new value :param flags: a :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_attribute_uint64(attribute: str, value: int, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sets ``attribute`` of type :const:`~gi.repository.Gio.FileAttributeType.UINT64` to ``value``\. If ``attribute`` is of a different type, this operation will fail. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param attribute: a string containing the attribute's name :param value: a :obj:`int` containing the attribute's new value :param flags: a :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_attributes_async(info: ~gi.repository.Gio.FileInfo, flags: ~gi.repository.Gio.FileQueryInfoFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously sets the attributes of ``file`` with ``info``\. For more details, see :func:`~gi.repository.Gio.File.set_attributes_from_info`, which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.set_attributes_finish` to get the result of the operation. :param info: a :obj:`~gi.repository.Gio.FileInfo` :param flags: a :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: set_attributes_finish(result: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[bool, ~gi.repository.Gio.FileInfo] Finishes setting an attribute started in :func:`~gi.repository.Gio.File.set_attributes_async`. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: set_attributes_from_info(info: ~gi.repository.Gio.FileInfo, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Tries to set all attributes in the :obj:`~gi.repository.Gio.FileInfo` on the target values, not stopping on the first error. If there is any error during this operation then ``error`` will be set to the first error. Error on particular fields are flagged by setting the "status" field in the attribute value to :const:`~gi.repository.Gio.FileAttributeStatus.ERROR_SETTING`, which means you can also detect further errors. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param info: a :obj:`~gi.repository.Gio.FileInfo` :param flags: :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_display_name(display_name: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.File Renames ``file`` to the specified display name. The display name is converted from UTF-8 to the correct encoding for the target filesystem if possible and the ``file`` is renamed to this. If you want to implement a rename operation in the user interface the edit name (:const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_EDIT_NAME`) should be used as the initial value in the rename widget, and then the result after editing should be passed to :func:`~gi.repository.Gio.File.set_display_name`. On success the resulting converted filename is returned. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param display_name: a string :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: set_display_name_async(display_name: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously sets the display name for a given :obj:`~gi.repository.Gio.File`\. For more details, see :func:`~gi.repository.Gio.File.set_display_name` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.set_display_name_finish` to get the result of the operation. :param display_name: a string :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: set_display_name_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.File Finishes setting a display name started with :func:`~gi.repository.Gio.File.set_display_name_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: start_mountable(flags: ~gi.repository.Gio.DriveStartFlags, start_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts a file of type :const:`~gi.repository.Gio.FileType.MOUNTABLE`. Using ``start_operation``\, you can request callbacks when, for instance, passwords are needed during authentication. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.mount_mountable_finish` to get the result of the operation. .. versionadded:: 2.22 :param flags: flags affecting the operation :param start_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied, or :const:`None` :param user_data: the data to pass to callback function .. method:: start_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a start operation. See :func:`~gi.repository.Gio.File.start_mountable` for details. Finish an asynchronous start operation that was started with :func:`~gi.repository.Gio.File.start_mountable`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: stop_mountable(flags: ~gi.repository.Gio.MountUnmountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Stops a file of type :const:`~gi.repository.Gio.FileType.MOUNTABLE`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.stop_mountable_finish` to get the result of the operation. .. versionadded:: 2.22 :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied, or :const:`None` :param user_data: the data to pass to callback function .. method:: stop_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a stop operation, see :func:`~gi.repository.Gio.File.stop_mountable` for details. Finish an asynchronous stop operation that was started with :func:`~gi.repository.Gio.File.stop_mountable`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: supports_thread_contexts() -> bool Checks if ``file`` supports [thread-default contexts][g-main-context-push-thread-default-context]. If this returns :const:`False`, you cannot perform asynchronous operations on ``file`` in a thread that has a thread-default context. .. versionadded:: 2.22 .. method:: trash(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sends ``file`` to the "Trashcan", if possible. This is similar to deleting it, but the user can recover it before emptying the trashcan. Trashing is disabled for system mounts by default (see :func:`~gi.repository.Gio.unix_mount_is_system_internal`), so this call can return the :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED` error. Since GLib 2.66, the ``x-gvfs-notrash`` unix mount option can be used to disable :func:`~gi.repository.Gio.File.trash` support for particular mounts, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED` error will be returned in that case. Since 2.82, the ``x-gvfs-trash`` unix mount option can be used to enable :func:`~gi.repository.Gio.File.trash` support for particular system mounts. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: trash_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously sends ``file`` to the Trash location, if possible. .. versionadded:: 2.38 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: trash_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous file trashing operation, started with :func:`~gi.repository.Gio.File.trash_async`. .. versionadded:: 2.38 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: unmount_mountable(flags: ~gi.repository.Gio.MountUnmountFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Unmounts a file of type G_FILE_TYPE_MOUNTABLE. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.unmount_mountable_finish` to get the result of the operation. .. deprecated:: 2.22 Use :func:`~gi.repository.Gio.File.unmount_mountable_with_operation` instead. :param flags: flags affecting the operation :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: unmount_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an unmount operation, see :func:`~gi.repository.Gio.File.unmount_mountable` for details. Finish an asynchronous unmount operation that was started with :func:`~gi.repository.Gio.File.unmount_mountable`. .. deprecated:: 2.22 Use :func:`~gi.repository.Gio.File.unmount_mountable_with_operation_finish` instead. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: unmount_mountable_with_operation(flags: ~gi.repository.Gio.MountUnmountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Unmounts a file of type :const:`~gi.repository.Gio.FileType.MOUNTABLE`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.unmount_mountable_finish` to get the result of the operation. .. versionadded:: 2.22 :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: unmount_mountable_with_operation_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an unmount operation, see :func:`~gi.repository.Gio.File.unmount_mountable_with_operation` for details. Finish an asynchronous unmount operation that was started with :func:`~gi.repository.Gio.File.unmount_mountable_with_operation`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` Virtual Methods --------------- .. rst-class:: interim-class .. class:: File :no-index: .. method:: do_append_to(flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileOutputStream Gets an output stream for appending data to the file. If the file doesn't already exist it is created. By default files created are generally readable by everyone, but if you pass :const:`~gi.repository.Gio.FileCreateFlags.PRIVATE` in ``flags`` the file will be made readable only to the current user, to the level that is supported on the target filesystem. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. Some file systems don't allow all file names, and may return an :const:`~gi.repository.Gio.IOErrorEnum.INVALID_FILENAME` error. If the file is a directory the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_append_to_async(flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously opens ``file`` for appending. For more details, see :func:`~gi.repository.Gio.File.append_to` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.append_to_finish` to get the result of the operation. :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_append_to_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileOutputStream Finishes an asynchronous file append operation started with :func:`~gi.repository.Gio.File.append_to_async`. :param res: :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_copy(destination: ~gi.repository.Gio.File, flags: ~gi.repository.Gio.FileCopyFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, progress_callback: ~typing.Callable[[int, int, ~typing.Any], None] | None = None, progress_callback_data: ~typing.Any = None) -> bool Copies the file ``source`` to the location specified by ``destination``\. Can not handle recursive copies of directories. If the flag :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is specified an already existing ``destination`` file is overwritten. If the flag :const:`~gi.repository.Gio.FileCopyFlags.NOFOLLOW_SYMLINKS` is specified then symlinks will be copied as symlinks, otherwise the target of the ``source`` symlink will be copied. If the flag :const:`~gi.repository.Gio.FileCopyFlags.ALL_METADATA` is specified then all the metadata that is possible to copy is copied, not just the default subset (which, for instance, does not include the owner, see :obj:`~gi.repository.Gio.FileInfo`\). If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If ``progress_callback`` is not :const:`None`, then the operation can be monitored by setting this to a :obj:`~gi.repository.Gio.FileProgressCallback` function. ``progress_callback_data`` will be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation. If the ``source`` file does not exist, then the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error is returned, independent on the status of the ``destination``\. If :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is not specified and the target exists, then the error :const:`~gi.repository.Gio.IOErrorEnum.EXISTS` is returned. If trying to overwrite a file over a directory, the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error is returned. If trying to overwrite a directory with a directory the :const:`~gi.repository.Gio.IOErrorEnum.WOULD_MERGE` error is returned. If the source is a directory and the target does not exist, or :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is specified and the target is a file, then the :const:`~gi.repository.Gio.IOErrorEnum.WOULD_RECURSE` error is returned. If you are interested in copying the :obj:`~gi.repository.Gio.File` object itself (not the on-disk file), see :func:`~gi.repository.Gio.File.dup`. :param destination: destination :obj:`~gi.repository.Gio.File` :param flags: set of :obj:`~gi.repository.Gio.FileCopyFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param progress_callback: function to callback with progress information, or :const:`None` if progress information is not needed :param progress_callback_data: user data to pass to ``progress_callback`` .. method:: do_copy_async(destination: ~gi.repository.Gio.File, flags: ~gi.repository.Gio.FileCopyFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, progress_callback: ~typing.Callable[[int, int, ~typing.Any], None] | None = None, progress_callback_data: ~typing.Any = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Copies the file ``source`` to the location specified by ``destination`` asynchronously. For details of the behaviour, see :func:`~gi.repository.Gio.File.copy`. If ``progress_callback`` is not :const:`None`, then that function that will be called just like in :func:`~gi.repository.Gio.File.copy`. The callback will run in the default main context of the thread calling :func:`~gi.repository.Gio.File.copy_async` — the same context as ``callback`` is run in. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.copy_finish` to get the result of the operation. :param destination: destination :obj:`~gi.repository.Gio.File` :param flags: set of :obj:`~gi.repository.Gio.FileCopyFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param progress_callback: function to callback with progress information, or :const:`None` if progress information is not needed :param progress_callback_data: user data to pass to ``progress_callback`` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback .. method:: do_copy_finish(res: ~gi.repository.Gio.AsyncResult) -> bool Finishes copying the file started with :func:`~gi.repository.Gio.File.copy_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_create(flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileOutputStream Creates a new file and returns an output stream for writing to it. The file must not already exist. By default files created are generally readable by everyone, but if you pass :const:`~gi.repository.Gio.FileCreateFlags.PRIVATE` in ``flags`` the file will be made readable only to the current user, to the level that is supported on the target filesystem. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If a file or directory with this name already exists the :const:`~gi.repository.Gio.IOErrorEnum.EXISTS` error will be returned. Some file systems don't allow all file names, and may return an :const:`~gi.repository.Gio.IOErrorEnum.INVALID_FILENAME` error, and if the name is to long :const:`~gi.repository.Gio.IOErrorEnum.FILENAME_TOO_LONG` will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_create_async(flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a new file and returns an output stream for writing to it. The file must not already exist. For more details, see :func:`~gi.repository.Gio.File.create` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.create_finish` to get the result of the operation. :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_create_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileOutputStream Finishes an asynchronous file create operation started with :func:`~gi.repository.Gio.File.create_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_create_readwrite(flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileIOStream Creates a new file and returns a stream for reading and writing to it. The file must not already exist. By default files created are generally readable by everyone, but if you pass :const:`~gi.repository.Gio.FileCreateFlags.PRIVATE` in ``flags`` the file will be made readable only to the current user, to the level that is supported on the target filesystem. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If a file or directory with this name already exists, the :const:`~gi.repository.Gio.IOErrorEnum.EXISTS` error will be returned. Some file systems don't allow all file names, and may return an :const:`~gi.repository.Gio.IOErrorEnum.INVALID_FILENAME` error, and if the name is too long, :const:`~gi.repository.Gio.IOErrorEnum.FILENAME_TOO_LONG` will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing. .. versionadded:: 2.22 :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_create_readwrite_async(flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a new file and returns a stream for reading and writing to it. The file must not already exist. For more details, see :func:`~gi.repository.Gio.File.create_readwrite` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.create_readwrite_finish` to get the result of the operation. .. versionadded:: 2.22 :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_create_readwrite_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileIOStream Finishes an asynchronous file create operation started with :func:`~gi.repository.Gio.File.create_readwrite_async`. .. versionadded:: 2.22 :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_delete_file(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool The type of the None singleton. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_delete_file_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None The type of the None singleton. .. versionadded:: 2.34 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_delete_file_finish(result: ~gi.repository.Gio.AsyncResult) -> bool The type of the None singleton. .. versionadded:: 2.34 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_dup() -> ~gi.repository.Gio.File Duplicates a :obj:`~gi.repository.Gio.File` handle. This operation does not duplicate the actual file or directory represented by the :obj:`~gi.repository.Gio.File`\; see :func:`~gi.repository.Gio.File.copy` if attempting to copy a file. :func:`~gi.repository.Gio.File.dup` is useful when a second handle is needed to the same underlying file, for use in a separate thread (:obj:`~gi.repository.Gio.File` is not thread-safe). For use within the same thread, use :func:`~gi.repository.GObject.GObject.Object.ref` to increment the existing object’s reference count. This call does no blocking I/O. .. method:: do_eject_mountable(flags: ~gi.repository.Gio.MountUnmountFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts an asynchronous eject on a mountable. When this operation has completed, ``callback`` will be called with ``user_user`` data, and the operation can be finalized with :func:`~gi.repository.Gio.File.eject_mountable_finish`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. .. deprecated:: 2.22 Use :func:`~gi.repository.Gio.File.eject_mountable_with_operation` instead. :param flags: flags affecting the operation :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_eject_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous eject operation started by :func:`~gi.repository.Gio.File.eject_mountable`. .. deprecated:: 2.22 Use :func:`~gi.repository.Gio.File.eject_mountable_with_operation_finish` instead. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_eject_mountable_with_operation(flags: ~gi.repository.Gio.MountUnmountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts an asynchronous eject on a mountable. When this operation has completed, ``callback`` will be called with ``user_user`` data, and the operation can be finalized with :func:`~gi.repository.Gio.File.eject_mountable_with_operation_finish`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. .. versionadded:: 2.22 :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_eject_mountable_with_operation_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous eject operation started by :func:`~gi.repository.Gio.File.eject_mountable_with_operation`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_enumerate_children(attributes: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileEnumerator Gets the requested information about the files in a directory. The result is a :obj:`~gi.repository.Gio.FileEnumerator` object that will give out :obj:`~gi.repository.Gio.FileInfo` objects for all the files in the directory. The ``attributes`` value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. ``attributes`` should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*\" means all attributes in the standard namespace. An example attribute query be "standard::\*,owner::user". The standard attributes are available as defines, like :const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_NAME`. :const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_NAME` should always be specified if you plan to call :func:`~gi.repository.Gio.FileEnumerator.get_child` or :func:`~gi.repository.Gio.FileEnumerator.iterate` on the returned enumerator. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. If the file is not a directory, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_DIRECTORY` error will be returned. Other errors are possible too. :param attributes: an attribute query string :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_enumerate_children_async(attributes: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously gets the requested information about the files in a directory. The result is a :obj:`~gi.repository.Gio.FileEnumerator` object that will give out :obj:`~gi.repository.Gio.FileInfo` objects for all the files in the directory. For more details, see :func:`~gi.repository.Gio.File.enumerate_children` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.enumerate_children_finish` to get the result of the operation. :param attributes: an attribute query string :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_enumerate_children_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileEnumerator Finishes an async enumerate children operation. See :func:`~gi.repository.Gio.File.enumerate_children_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_equal(file2: ~gi.repository.Gio.File) -> bool Checks if the two given :obj:`~gi.repository.Gio.File` refer to the same file. Note that two :obj:`~gi.repository.Gio.File` 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. :param file2: the second :obj:`~gi.repository.Gio.File` .. method:: do_find_enclosing_mount(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.Mount Gets a :obj:`~gi.repository.Gio.Mount` for the :obj:`~gi.repository.Gio.File`\. :obj:`~gi.repository.Gio.Mount` is returned only for user interesting locations, see :obj:`~gi.repository.Gio.VolumeMonitor`\. If the ``GFileIface`` for ``file`` does not have a ``mount``, ``error`` will be set to :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` and :const:`None` ``will`` be returned. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_find_enclosing_mount_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously gets the mount for the file. For more details, see :func:`~gi.repository.Gio.File.find_enclosing_mount` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.find_enclosing_mount_finish` to get the result of the operation. :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_find_enclosing_mount_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.Mount Finishes an asynchronous find mount request. See :func:`~gi.repository.Gio.File.find_enclosing_mount_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_get_basename() -> str | None Gets the base name (the last component of the path) for a given :obj:`~gi.repository.Gio.File`\. 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 :const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME` attribute with :func:`~gi.repository.Gio.File.query_info`. This call does no blocking I/O. .. method:: do_get_child_for_display_name(display_name: str) -> ~gi.repository.Gio.File Gets the child of ``file`` for a given ``display_name`` (i.e. a UTF-8 version of the name). If this function fails, it returns :const:`None` and ``error`` will be set. This is very useful when constructing a :obj:`~gi.repository.Gio.File` for a new file and the user entered the filename in the user interface, for instance when you select a directory and type a filename in the file selector. This call does no blocking I/O. :param display_name: string to a possible child .. method:: do_get_parent() -> ~gi.repository.Gio.File | None Gets the parent directory for the ``file``\. If the ``file`` represents the root directory of the file system, then :const:`None` will be returned. This call does no blocking I/O. .. method:: do_get_parse_name() -> str 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 :obj:`~gi.repository.Gio.File` back using :func:`~gi.repository.Gio.File.parse_name`. This is generally used to show the :obj:`~gi.repository.Gio.File` 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 UTF-8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF-8 characters unescaped). This call does no blocking I/O. .. method:: do_get_path() -> str | None Gets the local pathname for :obj:`~gi.repository.Gio.File`\, if one exists. If non-:const:`None`, this is guaranteed to be an absolute, canonical path. It might contain symlinks. This call does no blocking I/O. .. method:: do_get_relative_path(descendant: ~gi.repository.Gio.File) -> str | None Gets the path for ``descendant`` relative to ``parent``\. This call does no blocking I/O. :param descendant: input :obj:`~gi.repository.Gio.File` .. method:: do_get_uri() -> str Gets the URI for the ``file``\. This call does no blocking I/O. .. method:: do_get_uri_scheme() -> str | None Gets the URI scheme for a :obj:`~gi.repository.Gio.File`\. RFC 3986 decodes the scheme as: .. code-block:: :dedent: URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] Common schemes include "file", "http", "ftp", etc. The scheme can be different from the one used to construct the :obj:`~gi.repository.Gio.File`\, in that it might be replaced with one that is logically equivalent to the :obj:`~gi.repository.Gio.File`\. This call does no blocking I/O. .. method:: do_has_uri_scheme(uri_scheme: str) -> bool Checks to see if a :obj:`~gi.repository.Gio.File` has a given URI scheme. This call does no blocking I/O. :param uri_scheme: a string containing a URI scheme .. method:: do_hash() -> int Creates a hash value for a :obj:`~gi.repository.Gio.File`\. This call does no blocking I/O. .. method:: do_is_native() -> bool Checks to see if a file is native to the platform. A native file is one expressed in the platform-native filename format, e.g. "C:\Windows" or "/usr/bin/". This does not mean the file is local, as it might be on a locally mounted remote filesystem. On some systems non-native files may be available using the native filesystem via a userspace filesystem (FUSE), in these cases this call will return :const:`False`, but :func:`~gi.repository.Gio.File.get_path` will still return a native path. This call does no blocking I/O. .. method:: do_make_directory(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Creates a directory. Note that this will only create a child directory of the immediate parent directory of the path or URI given by the :obj:`~gi.repository.Gio.File`\. To recursively create directories, see :func:`~gi.repository.Gio.File.make_directory_with_parents`. This function will fail if the parent directory does not exist, setting ``error`` to :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND`. If the file system doesn't support creating directories, this function will fail, setting ``error`` to :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED`. For a local :obj:`~gi.repository.Gio.File` the newly created directory will have the default (current) ownership and permissions of the current process. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_make_directory_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a directory. .. versionadded:: 2.38 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_make_directory_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous directory creation, started with :func:`~gi.repository.Gio.File.make_directory_async`. .. versionadded:: 2.38 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_make_symbolic_link(symlink_value: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Creates a symbolic link named ``file`` which contains the string ``symlink_value``\. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param symlink_value: a string with the path for the target of the new symlink :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_make_symbolic_link_async(symlink_value: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously creates a symbolic link named ``file`` which contains the string ``symlink_value``\. .. versionadded:: 2.74 :param symlink_value: a string with the path for the target of the new symlink :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_make_symbolic_link_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous symbolic link creation, started with :func:`~gi.repository.Gio.File.make_symbolic_link_async`. .. versionadded:: 2.74 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_measure_disk_usage(flags: ~gi.repository.Gio.FileMeasureFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, progress_callback: ~typing.Callable[[bool, int, int, int, ~typing.Any], None] | None = None, progress_data: ~typing.Any = None) -> ~typing.Tuple[bool, int, int, int] Recursively measures the disk usage of ``file``\. This is essentially an analog of the 'du' command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links). By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless :const:`~gi.repository.Gio.FileMeasureFlags.REPORT_ANY_ERROR` is given in ``flags``\. The returned size, ``disk_usage``\, is in bytes and should be formatted with :func:`~gi.repository.GLib.format_size` in order to get something reasonable for showing in a user interface. ``progress_callback`` and ``progress_data`` can be given to request periodic progress updates while scanning. See the documentation for :obj:`~gi.repository.Gio.FileMeasureProgressCallback` for information about when and how the callback will be invoked. .. versionadded:: 2.38 :param flags: :obj:`~gi.repository.Gio.FileMeasureFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` :param progress_callback: a :obj:`~gi.repository.Gio.FileMeasureProgressCallback` :param progress_data: user_data for ``progress_callback`` .. method:: do_measure_disk_usage_finish(result: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[bool, int, int, int] Collects the results from an earlier call to :func:`~gi.repository.Gio.File.measure_disk_usage_async`. See :func:`~gi.repository.Gio.File.measure_disk_usage` for more information. .. versionadded:: 2.38 :param result: the :obj:`~gi.repository.Gio.AsyncResult` passed to your :obj:`~gi.repository.Gio.AsyncReadyCallback` .. method:: do_monitor_dir(flags: ~gi.repository.Gio.FileMonitorFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileMonitor The type of the None singleton. :param flags: a set of :obj:`~gi.repository.Gio.FileMonitorFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_monitor_file(flags: ~gi.repository.Gio.FileMonitorFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileMonitor Obtains a file monitor for the given file. If no file notification mechanism exists, then regular polling of the file is used. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If ``flags`` contains :const:`~gi.repository.Gio.FileMonitorFlags.WATCH_HARD_LINKS` then the monitor will also attempt to report changes made to the file via another filename (ie, a hard link). Without this flag, you can only rely on changes made through the filename contained in ``file`` to be reported. Using this flag may result in an increase in resource usage, and may not have any effect depending on the :obj:`~gi.repository.Gio.FileMonitor` backend and/or filesystem type. :param flags: a set of :obj:`~gi.repository.Gio.FileMonitorFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_mount_enclosing_volume(flags: ~gi.repository.Gio.MountMountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts a ``mount_operation``\, mounting the volume that contains the file ``location``\. When this operation has completed, ``callback`` will be called with ``user_user`` data, and the operation can be finalized with :func:`~gi.repository.Gio.File.mount_enclosing_volume_finish`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation` or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied, or :const:`None` :param user_data: the data to pass to callback function .. method:: do_mount_enclosing_volume_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a mount operation started by :func:`~gi.repository.Gio.File.mount_enclosing_volume`. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_mount_mountable(flags: ~gi.repository.Gio.MountMountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Mounts a file of type G_FILE_TYPE_MOUNTABLE. Using ``mount_operation``\, you can request callbacks when, for instance, passwords are needed during authentication. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.mount_mountable_finish` to get the result of the operation. :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_mount_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.File Finishes a mount operation. See :func:`~gi.repository.Gio.File.mount_mountable` for details. Finish an asynchronous mount operation that was started with :func:`~gi.repository.Gio.File.mount_mountable`. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_move(destination: ~gi.repository.Gio.File, flags: ~gi.repository.Gio.FileCopyFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, progress_callback: ~typing.Callable[[int, int, ~typing.Any], None] | None = None, progress_callback_data: ~typing.Any = None) -> bool Tries to move the file or directory ``source`` to the location specified by ``destination``\. If native move operations are supported then this is used, otherwise a copy + delete fallback is used. The native implementation may support moving directories (for instance on moves inside the same filesystem), but the fallback code does not. If the flag :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is specified an already existing ``destination`` file is overwritten. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If ``progress_callback`` is not :const:`None`, then the operation can be monitored by setting this to a :obj:`~gi.repository.Gio.FileProgressCallback` function. ``progress_callback_data`` will be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation. If the ``source`` file does not exist, then the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error is returned, independent on the status of the ``destination``\. If :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is not specified and the target exists, then the error :const:`~gi.repository.Gio.IOErrorEnum.EXISTS` is returned. If trying to overwrite a file over a directory, the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error is returned. If trying to overwrite a directory with a directory the :const:`~gi.repository.Gio.IOErrorEnum.WOULD_MERGE` error is returned. If the source is a directory and the target does not exist, or :const:`~gi.repository.Gio.FileCopyFlags.OVERWRITE` is specified and the target is a file, then the :const:`~gi.repository.Gio.IOErrorEnum.WOULD_RECURSE` error may be returned (if the native move operation isn't available). :param destination: :obj:`~gi.repository.Gio.File` pointing to the destination location :param flags: set of :obj:`~gi.repository.Gio.FileCopyFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param progress_callback: :obj:`~gi.repository.Gio.FileProgressCallback` function for updates :param progress_callback_data: gpointer to user data for the callback function .. method:: do_move_async(destination: ~gi.repository.Gio.File, flags: ~gi.repository.Gio.FileCopyFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, progress_callback: ~typing.Callable[[int, int, ~typing.Any], None] | None = None, progress_callback_data: ~typing.Any = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously moves a file ``source`` to the location of ``destination``\. For details of the behaviour, see :func:`~gi.repository.Gio.File.move`. If ``progress_callback`` is not :const:`None`, then that function that will be called just like in :func:`~gi.repository.Gio.File.move`. The callback will run in the default main context of the thread calling :func:`~gi.repository.Gio.File.move_async` — the same context as ``callback`` is run in. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.move_finish` to get the result of the operation. .. versionadded:: 2.72 :param destination: :obj:`~gi.repository.Gio.File` pointing to the destination location :param flags: set of :obj:`~gi.repository.Gio.FileCopyFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param progress_callback: :obj:`~gi.repository.Gio.FileProgressCallback` function for updates :param progress_callback_data: gpointer to user data for the callback function :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_move_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous file movement, started with :func:`~gi.repository.Gio.File.move_async`. .. versionadded:: 2.72 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_open_readwrite(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileIOStream Opens an existing file for reading and writing. The result is a :obj:`~gi.repository.Gio.FileIOStream` that can be used to read and write the contents of the file. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. If the file is a directory, the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing. .. versionadded:: 2.22 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` .. method:: do_open_readwrite_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously opens ``file`` for reading and writing. For more details, see :func:`~gi.repository.Gio.File.open_readwrite` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.open_readwrite_finish` to get the result of the operation. .. versionadded:: 2.22 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_open_readwrite_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileIOStream Finishes an asynchronous file read operation started with :func:`~gi.repository.Gio.File.open_readwrite_async`. .. versionadded:: 2.22 :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_poll_mountable(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Polls a file of type :const:`~gi.repository.Gio.FileType.MOUNTABLE`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.mount_mountable_finish` to get the result of the operation. .. versionadded:: 2.22 :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied, or :const:`None` :param user_data: the data to pass to callback function .. method:: do_poll_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a poll operation. See :func:`~gi.repository.Gio.File.poll_mountable` for details. Finish an asynchronous poll operation that was polled with :func:`~gi.repository.Gio.File.poll_mountable`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_prefix_matches(file: ~gi.repository.Gio.File) -> bool The type of the None singleton. :param file: input :obj:`~gi.repository.Gio.File` .. method:: do_query_filesystem_info(attributes: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInfo Similar to :func:`~gi.repository.Gio.File.query_info`, but obtains information about the filesystem the ``file`` is on, rather than the file itself. For instance the amount of space available and the type of the filesystem. The ``attributes`` value is a string that specifies the attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. ``attributes`` should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "filesystem::*\" means all attributes in the filesystem namespace. The standard namespace for filesystem attributes is "filesystem". Common attributes of interest are :const:`~gi.repository.Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE` (the total size of the filesystem in bytes), :const:`~gi.repository.Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE` (number of bytes available), and :const:`~gi.repository.Gio.FILE_ATTRIBUTE_FILESYSTEM_TYPE` (type of the filesystem). If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param attributes: an attribute query string :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_query_filesystem_info_async(attributes: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously gets the requested information about the filesystem that the specified ``file`` is on. The result is a :obj:`~gi.repository.Gio.FileInfo` object that contains key-value attributes (such as type or size for the file). For more details, see :func:`~gi.repository.Gio.File.query_filesystem_info` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.query_info_finish` to get the result of the operation. :param attributes: an attribute query string :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_query_filesystem_info_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInfo Finishes an asynchronous filesystem info query. See :func:`~gi.repository.Gio.File.query_filesystem_info_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_query_info(attributes: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInfo Gets the requested information about specified ``file``\. The result is a :obj:`~gi.repository.Gio.FileInfo` object that contains key-value attributes (such as the type or size of the file). The ``attributes`` value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. ``attributes`` should be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*\" means all attributes in the standard namespace. An example attribute query be "standard::\*,owner::user". The standard attributes are available as defines, like :const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_NAME`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass :const:`~gi.repository.Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS` in ``flags`` the information about the symlink itself will be returned. Also, for symlinks that point to non-existing files the information about the symlink itself will be returned. If the file does not exist, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_FOUND` error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param attributes: an attribute query string :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_query_info_async(attributes: str, flags: ~gi.repository.Gio.FileQueryInfoFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously gets the requested information about specified ``file``\. The result is a :obj:`~gi.repository.Gio.FileInfo` object that contains key-value attributes (such as type or size for the file). For more details, see :func:`~gi.repository.Gio.File.query_info` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.query_info_finish` to get the result of the operation. :param attributes: an attribute query string :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_query_info_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInfo Finishes an asynchronous file info query. See :func:`~gi.repository.Gio.File.query_info_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_query_settable_attributes(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileAttributeInfoList Obtain the list of settable attributes for the file. Returns the type and full attribute name of all the attributes that can be set on this file. This doesn't mean setting it will always succeed though, you might get an access failure, or some specific file may not support a specific attribute. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_query_writable_namespaces(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileAttributeInfoList Obtain the list of attribute namespaces where new attributes can be created by a user. An example of this is extended attributes (in the "xattr" namespace). If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_read_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously opens ``file`` for reading. For more details, see :func:`~gi.repository.Gio.File.read` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.read_finish` to get the result of the operation. :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_read_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInputStream Finishes an asynchronous file read operation started with :func:`~gi.repository.Gio.File.read_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_read_fn(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInputStream The type of the None singleton. :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` .. method:: do_replace(etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileOutputStream Returns an output stream for overwriting the file, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created. This will try to replace the file in the safest way possible so that any errors during the writing will not affect an already existing copy of the file. For instance, for local files it may write to a temporary file and then atomically rename over the destination when the stream is closed. By default files created are generally readable by everyone, but if you pass :const:`~gi.repository.Gio.FileCreateFlags.PRIVATE` in ``flags`` the file will be made readable only to the current user, to the level that is supported on the target filesystem. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. If you pass in a non-:const:`None` ``etag`` value and ``file`` already exists, then this value is compared to the current entity tag of the file, and if they differ an :const:`~gi.repository.Gio.IOErrorEnum.WRONG_ETAG` error is returned. This generally means that the file has been changed since you last read it. You can get the new etag from :func:`~gi.repository.Gio.FileOutputStream.get_etag` after you've finished writing and closed the :obj:`~gi.repository.Gio.FileOutputStream`\. When you load a new file you can use :func:`~gi.repository.Gio.FileInputStream.query_info` to get the etag of the file. If ``make_backup`` is :const:`True`, this function will attempt to make a backup of the current file before overwriting it. If this fails a :const:`~gi.repository.Gio.IOErrorEnum.CANT_CREATE_BACKUP` error will be returned. If you want to replace anyway, try again with ``make_backup`` set to :const:`False`. If the file is a directory the :const:`~gi.repository.Gio.IOErrorEnum.IS_DIRECTORY` error will be returned, and if the file is some other form of non-regular file then a :const:`~gi.repository.Gio.IOErrorEnum.NOT_REGULAR_FILE` error will be returned. Some file systems don't allow all file names, and may return an :const:`~gi.repository.Gio.IOErrorEnum.INVALID_FILENAME` error, and if the name is to long :const:`~gi.repository.Gio.IOErrorEnum.FILENAME_TOO_LONG` will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. :param etag: an optional `entity tag <#entity-tags>`__ for the current :obj:`~gi.repository.Gio.File`\, or :obj:`~gi.repository.None` to ignore :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_replace_async(etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first. For more details, see :func:`~gi.repository.Gio.File.replace` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.replace_finish` to get the result of the operation. :param etag: an `entity tag <#entity-tags>`__ for the current :obj:`~gi.repository.Gio.File`\, or :const:`None` to ignore :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_replace_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileOutputStream Finishes an asynchronous file replace operation started with :func:`~gi.repository.Gio.File.replace_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_replace_readwrite(etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileIOStream Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created. For details about the behaviour, see :func:`~gi.repository.Gio.File.replace` which does the same thing but returns an output stream only. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing. .. versionadded:: 2.22 :param etag: an optional `entity tag <#entity-tags>`__ for the current :obj:`~gi.repository.Gio.File`\, or :obj:`~gi.repository.None` to ignore :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_replace_readwrite_async(etag: str | None, make_backup: bool, flags: ~gi.repository.Gio.FileCreateFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first. For more details, see :func:`~gi.repository.Gio.File.replace_readwrite` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.replace_readwrite_finish` to get the result of the operation. .. versionadded:: 2.22 :param etag: an `entity tag <#entity-tags>`__ for the current :obj:`~gi.repository.Gio.File`\, or :const:`None` to ignore :param make_backup: :const:`True` if a backup should be created :param flags: a set of :obj:`~gi.repository.Gio.FileCreateFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_replace_readwrite_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileIOStream Finishes an asynchronous file replace operation started with :func:`~gi.repository.Gio.File.replace_readwrite_async`. .. versionadded:: 2.22 :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_resolve_relative_path(relative_path: str) -> ~gi.repository.Gio.File Resolves a relative path for ``file`` to an absolute path. This call does no blocking I/O. If the ``relative_path`` is an absolute path name, the resolution is done absolutely (without taking ``file`` path as base). :param relative_path: a given relative path string .. method:: do_set_attribute(attribute: str, type: ~gi.repository.Gio.FileAttributeType, value_p: ~typing.Any, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sets an attribute in the file with attribute name ``attribute`` to ``value_p``\. Some attributes can be unset by setting ``type`` to :const:`~gi.repository.Gio.FileAttributeType.INVALID` and ``value_p`` to :const:`None`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param attribute: a string containing the attribute's name :param type: The type of the attribute :param value_p: a pointer to the value (or the pointer itself if the type is a pointer type) :param flags: a set of :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_set_attributes_async(info: ~gi.repository.Gio.FileInfo, flags: ~gi.repository.Gio.FileQueryInfoFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously sets the attributes of ``file`` with ``info``\. For more details, see :func:`~gi.repository.Gio.File.set_attributes_from_info`, which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.set_attributes_finish` to get the result of the operation. :param info: a :obj:`~gi.repository.Gio.FileInfo` :param flags: a :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_set_attributes_finish(result: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[bool, ~gi.repository.Gio.FileInfo] Finishes setting an attribute started in :func:`~gi.repository.Gio.File.set_attributes_async`. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_set_attributes_from_info(info: ~gi.repository.Gio.FileInfo, flags: ~gi.repository.Gio.FileQueryInfoFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Tries to set all attributes in the :obj:`~gi.repository.Gio.FileInfo` on the target values, not stopping on the first error. If there is any error during this operation then ``error`` will be set to the first error. Error on particular fields are flagged by setting the "status" field in the attribute value to :const:`~gi.repository.Gio.FileAttributeStatus.ERROR_SETTING`, which means you can also detect further errors. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param info: a :obj:`~gi.repository.Gio.FileInfo` :param flags: :obj:`~gi.repository.Gio.FileQueryInfoFlags` :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_set_display_name(display_name: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.File Renames ``file`` to the specified display name. The display name is converted from UTF-8 to the correct encoding for the target filesystem if possible and the ``file`` is renamed to this. If you want to implement a rename operation in the user interface the edit name (:const:`~gi.repository.Gio.FILE_ATTRIBUTE_STANDARD_EDIT_NAME`) should be used as the initial value in the rename widget, and then the result after editing should be passed to :func:`~gi.repository.Gio.File.set_display_name`. On success the resulting converted filename is returned. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param display_name: a string :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_set_display_name_async(display_name: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously sets the display name for a given :obj:`~gi.repository.Gio.File`\. For more details, see :func:`~gi.repository.Gio.File.set_display_name` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.set_display_name_finish` to get the result of the operation. :param display_name: a string :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_set_display_name_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.File Finishes setting a display name started with :func:`~gi.repository.Gio.File.set_display_name_async`. :param res: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_start_mountable(flags: ~gi.repository.Gio.DriveStartFlags, start_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts a file of type :const:`~gi.repository.Gio.FileType.MOUNTABLE`. Using ``start_operation``\, you can request callbacks when, for instance, passwords are needed during authentication. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.mount_mountable_finish` to get the result of the operation. .. versionadded:: 2.22 :param flags: flags affecting the operation :param start_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied, or :const:`None` :param user_data: the data to pass to callback function .. method:: do_start_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a start operation. See :func:`~gi.repository.Gio.File.start_mountable` for details. Finish an asynchronous start operation that was started with :func:`~gi.repository.Gio.File.start_mountable`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_stop_mountable(flags: ~gi.repository.Gio.MountUnmountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Stops a file of type :const:`~gi.repository.Gio.FileType.MOUNTABLE`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.stop_mountable_finish` to get the result of the operation. .. versionadded:: 2.22 :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied, or :const:`None` :param user_data: the data to pass to callback function .. method:: do_stop_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a stop operation, see :func:`~gi.repository.Gio.File.stop_mountable` for details. Finish an asynchronous stop operation that was started with :func:`~gi.repository.Gio.File.stop_mountable`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_trash(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Sends ``file`` to the "Trashcan", if possible. This is similar to deleting it, but the user can recover it before emptying the trashcan. Trashing is disabled for system mounts by default (see :func:`~gi.repository.Gio.unix_mount_is_system_internal`), so this call can return the :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED` error. Since GLib 2.66, the ``x-gvfs-notrash`` unix mount option can be used to disable :func:`~gi.repository.Gio.File.trash` support for particular mounts, the :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED` error will be returned in that case. Since 2.82, the ``x-gvfs-trash`` unix mount option can be used to enable :func:`~gi.repository.Gio.File.trash` support for particular system mounts. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: do_trash_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously sends ``file`` to the Trash location, if possible. .. versionadded:: 2.38 :param io_priority: the `I/O priority `__ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_trash_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous file trashing operation, started with :func:`~gi.repository.Gio.File.trash_async`. .. versionadded:: 2.38 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_unmount_mountable(flags: ~gi.repository.Gio.MountUnmountFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Unmounts a file of type G_FILE_TYPE_MOUNTABLE. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.unmount_mountable_finish` to get the result of the operation. .. deprecated:: 2.22 Use :func:`~gi.repository.Gio.File.unmount_mountable_with_operation` instead. :param flags: flags affecting the operation :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_unmount_mountable_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an unmount operation, see :func:`~gi.repository.Gio.File.unmount_mountable` for details. Finish an asynchronous unmount operation that was started with :func:`~gi.repository.Gio.File.unmount_mountable`. .. deprecated:: 2.22 Use :func:`~gi.repository.Gio.File.unmount_mountable_with_operation_finish` instead. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_unmount_mountable_with_operation(flags: ~gi.repository.Gio.MountUnmountFlags, mount_operation: ~gi.repository.Gio.MountOperation | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Unmounts a file of type :const:`~gi.repository.Gio.FileType.MOUNTABLE`. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be returned. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.File.unmount_mountable_finish` to get the result of the operation. .. versionadded:: 2.22 :param flags: flags affecting the operation :param mount_operation: a :obj:`~gi.repository.Gio.MountOperation`\, or :const:`None` to avoid user interaction :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_unmount_mountable_with_operation_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an unmount operation, see :func:`~gi.repository.Gio.File.unmount_mountable_with_operation` for details. Finish an asynchronous unmount operation that was started with :func:`~gi.repository.Gio.File.unmount_mountable_with_operation`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult`