Interface (GI Interface)

Gio-2.0GioFile

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

To construct a Gio.File, you can use:

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

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

All Gio.Files have a basename (get with 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 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 Gio.File to use to actually access the file, because there is no way to go from a display name to the actual name.

Using Gio.File 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 Gio.Files 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 Gio.Files point to the same file you can query for the G_FILE_ATTRIBUTE_ID_FILE attribute. Note that Gio.File 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 Gio.Files.

Many Gio.File 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 Gio.AsyncReadyCallback which is then used to finalize the operation, producing a 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 Gio.File operations almost always take a noticeable amount of time, and so do not have synchronous analogs. Notable cases include:

One notable feature of Gio.Files 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.

interface File {
    $signals: GObject.Object.SignalSignatures;
    _init(...args: any[]): void;
    append_to(
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileOutputStream;
    append_to_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileOutputStream>;
    append_to_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    append_to_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileOutputStream>;
    append_to_finish(res: Gio.AsyncResult): Gio.FileOutputStream;
    bind_property(
        source_property: string,
        target: GObject.Object,
        target_property: string,
        flags: GObject.BindingFlags,
    ): GObject.Binding;
    bind_property_full(
        source_property: string,
        target: GObject.Object,
        target_property: string,
        flags: GObject.BindingFlags,
        transform_to?: BindingTransformFunc,
        transform_from?: BindingTransformFunc,
        notify?: DestroyNotify,
    ): GObject.Binding;
    bind_property_full(
        source_property: string,
        target: GObject.Object,
        target_property: string,
        flags: GObject.BindingFlags,
        transform_to: Closure<any, any>,
        transform_from: Closure<any, any>,
    ): GObject.Binding;
    block_signal_handler(id: number): void;
    build_attribute_list_for_copy(
        flags: Gio.FileCopyFlags,
        cancellable?: Gio.Cancellable,
    ): string;
    connect<K extends "notify">(
        signal: K,
        callback: SignalCallback<Gio.File, GObject.Object.SignalSignatures[K]>,
    ): number;
    connect(signal: string, callback: (...args: any[]) => any): number;
    connect_after<K extends "notify">(
        signal: K,
        callback: SignalCallback<Gio.File, GObject.Object.SignalSignatures[K]>,
    ): number;
    connect_after(signal: string, callback: (...args: any[]) => any): number;
    copy(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
    ): boolean;
    copy_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
    ): Promise<boolean>;
    copy_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        progress_callback: FileProgressCallback,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    copy_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    copy_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        progress_callback_closure: Closure<any, any>,
        ready_callback_closure: Closure,
    ): void;
    copy_attributes(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    copy_finish(res: Gio.AsyncResult): boolean;
    create(
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileOutputStream;
    create_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileOutputStream>;
    create_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    create_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileOutputStream>;
    create_finish(res: Gio.AsyncResult): Gio.FileOutputStream;
    create_readwrite(
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileIOStream;
    create_readwrite_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileIOStream>;
    create_readwrite_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    create_readwrite_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileIOStream>;
    create_readwrite_finish(res: Gio.AsyncResult): Gio.FileIOStream;
    delete(cancellable?: Gio.Cancellable): boolean;
    delete_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    delete_async(
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    delete_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    delete_finish(result: Gio.AsyncResult): boolean;
    disconnect(id: number): void;
    dup(): Gio.File;
    eject_mountable(
        flags: Gio.MountUnmountFlags,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    eject_mountable(
        flags: Gio.MountUnmountFlags,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    eject_mountable(
        flags: Gio.MountUnmountFlags,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    eject_mountable_finish(result: Gio.AsyncResult): boolean;
    eject_mountable_with_operation(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    eject_mountable_with_operation(
        flags: Gio.MountUnmountFlags,
        mount_operation: Gio.MountOperation,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    eject_mountable_with_operation(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    eject_mountable_with_operation_finish(result: Gio.AsyncResult): boolean;
    emit<K extends "notify">(
        signal: K,
        ...args: GjsParameters<GObject.Object.SignalSignatures[K]> extends [
            any,
            ...Q[],
        ]
            ? Q
            : never,
    ): void;
    emit(signal: string, ...args: any[]): void;
    enumerate_children(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileEnumerator;
    enumerate_children_async(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileEnumerator>;
    enumerate_children_async(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    enumerate_children_async(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileEnumerator>;
    enumerate_children_finish(res: Gio.AsyncResult): Gio.FileEnumerator;
    equal(file2: Gio.File): boolean;
    find_enclosing_mount(cancellable?: Gio.Cancellable): Gio.Mount;
    find_enclosing_mount_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.Mount>;
    find_enclosing_mount_async(
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    find_enclosing_mount_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.Mount>;
    find_enclosing_mount_finish(res: Gio.AsyncResult): Gio.Mount;
    force_floating(): void;
    freeze_notify(): void;
    get_basename(): string;
    get_child(name: string): Gio.File;
    get_child_for_display_name(display_name: string): Gio.File;
    get_data(key: string): any;
    get_parent(): Gio.File;
    get_parse_name(): string;
    get_path(): string;
    get_property(property_name: string, value: any): any;
    get_qdata(quark: number): any;
    get_relative_path(descendant: Gio.File): string;
    get_uri(): string;
    get_uri_scheme(): string;
    getv(names: string[], values: any[]): void;
    has_parent(parent?: Gio.File): boolean;
    has_prefix(prefix: Gio.File): boolean;
    has_uri_scheme(uri_scheme: string): boolean;
    hash(): number;
    is_floating(): boolean;
    is_native(): boolean;
    load_bytes(cancellable: Gio.Cancellable): [GLib.Bytes, string];
    load_bytes_async(
        cancellable?: Gio.Cancellable,
    ): Promise<[GLib.Bytes, string]>;
    load_bytes_async(
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    load_bytes_async(
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<[GLib.Bytes, string]>;
    load_bytes_finish(result: Gio.AsyncResult): [GLib.Bytes, string];
    load_contents(
        cancellable: Gio.Cancellable,
    ): [boolean, Uint8Array<ArrayBufferLike>, string];
    load_contents_async(
        cancellable?: Gio.Cancellable,
    ): Promise<[Uint8Array<ArrayBufferLike>, string]>;
    load_contents_async(
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    load_contents_async(
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<[Uint8Array<ArrayBufferLike>, string]>;
    load_contents_finish(
        res: Gio.AsyncResult,
    ): [boolean, Uint8Array<ArrayBufferLike>, string];
    load_partial_contents_finish(
        res: Gio.AsyncResult,
    ): [boolean, Uint8Array<ArrayBufferLike>, string];
    make_directory(cancellable?: Gio.Cancellable): boolean;
    make_directory_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    make_directory_async(
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    make_directory_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    make_directory_finish(result: Gio.AsyncResult): boolean;
    make_directory_with_parents(cancellable?: Gio.Cancellable): boolean;
    make_symbolic_link(
        symlink_value: string,
        cancellable?: Gio.Cancellable,
    ): boolean;
    make_symbolic_link_async(
        symlink_value: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    make_symbolic_link_async(
        symlink_value: string,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    make_symbolic_link_async(
        symlink_value: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    make_symbolic_link_finish(result: Gio.AsyncResult): boolean;
    measure_disk_usage(
        flags: Gio.FileMeasureFlags,
        cancellable: Gio.Cancellable,
        progress_callback: FileMeasureProgressCallback,
    ): [boolean, number, number, number];
    measure_disk_usage_finish(
        result: Gio.AsyncResult,
    ): [boolean, number, number, number];
    monitor(
        flags: Gio.FileMonitorFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileMonitor;
    monitor_directory(
        flags: Gio.FileMonitorFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileMonitor;
    monitor_file(
        flags: Gio.FileMonitorFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileMonitor;
    mount_enclosing_volume(
        flags: NONE,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    mount_enclosing_volume(
        flags: NONE,
        mount_operation: Gio.MountOperation,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    mount_enclosing_volume(
        flags: NONE,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    mount_enclosing_volume_finish(result: Gio.AsyncResult): boolean;
    mount_mountable(
        flags: NONE,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.File>;
    mount_mountable(
        flags: NONE,
        mount_operation: Gio.MountOperation,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    mount_mountable(
        flags: NONE,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.File>;
    mount_mountable_finish(result: Gio.AsyncResult): Gio.File;
    move(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
    ): boolean;
    move_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
    ): Promise<boolean>;
    move_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        progress_callback: FileProgressCallback,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    move_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    move_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        progress_callback_closure: Closure<any, any>,
        ready_callback_closure: Closure,
    ): void;
    move_finish(result: Gio.AsyncResult): boolean;
    notify(property_name: string): void;
    notify_by_pspec(pspec: GObject.ParamSpec): void;
    open_readwrite(cancellable?: Gio.Cancellable): Gio.FileIOStream;
    open_readwrite_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileIOStream>;
    open_readwrite_async(
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    open_readwrite_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileIOStream>;
    open_readwrite_finish(res: Gio.AsyncResult): Gio.FileIOStream;
    peek_path(): string;
    poll_mountable(cancellable?: Gio.Cancellable): Promise<boolean>;
    poll_mountable(
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    poll_mountable(
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    poll_mountable_finish(result: Gio.AsyncResult): boolean;
    query_default_handler(cancellable?: Gio.Cancellable): Gio.AppInfo;
    query_default_handler_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.AppInfo>;
    query_default_handler_async(
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    query_default_handler_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.AppInfo>;
    query_default_handler_finish(result: Gio.AsyncResult): Gio.AppInfo;
    query_exists(cancellable?: Gio.Cancellable): boolean;
    query_file_type(
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileType;
    query_filesystem_info(
        attributes: string,
        cancellable?: Gio.Cancellable,
    ): Gio.FileInfo;
    query_filesystem_info_async(
        attributes: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileInfo>;
    query_filesystem_info_async(
        attributes: string,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    query_filesystem_info_async(
        attributes: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileInfo>;
    query_filesystem_info_finish(res: Gio.AsyncResult): Gio.FileInfo;
    query_info(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileInfo;
    query_info_async(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileInfo>;
    query_info_async(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    query_info_async(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileInfo>;
    query_info_finish(res: Gio.AsyncResult): Gio.FileInfo;
    query_settable_attributes(
        cancellable?: Gio.Cancellable,
    ): FileAttributeInfoList;
    query_writable_namespaces(
        cancellable?: Gio.Cancellable,
    ): FileAttributeInfoList;
    read(cancellable?: Gio.Cancellable): Gio.FileInputStream;
    read_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileInputStream>;
    read_async(
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    read_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileInputStream>;
    read_finish(res: Gio.AsyncResult): Gio.FileInputStream;
    ref(): GObject.Object;
    ref_sink(): GObject.Object;
    replace(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileOutputStream;
    replace_async(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileOutputStream>;
    replace_async(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    replace_async(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileOutputStream>;
    replace_contents(
        contents: string | Uint8Array<ArrayBufferLike>,
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): [boolean, string];
    replace_contents_async(
        contents: string | Uint8Array<ArrayBufferLike>,
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Promise<string>;
    replace_contents_async(
        contents: string | Uint8Array<ArrayBufferLike>,
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    replace_contents_async(
        contents: string | Uint8Array<ArrayBufferLike>,
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<string>;
    replace_contents_async(
        contents: Uint8Array,
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback,
    ): void;
    replace_contents_bytes_async(
        contents: Uint8Array<ArrayBufferLike> | GLib.Bytes,
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    replace_contents_finish(res: Gio.AsyncResult): [boolean, string];
    replace_finish(res: Gio.AsyncResult): Gio.FileOutputStream;
    replace_readwrite(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileIOStream;
    replace_readwrite_async(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileIOStream>;
    replace_readwrite_async(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    replace_readwrite_async(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileIOStream>;
    replace_readwrite_finish(res: Gio.AsyncResult): Gio.FileIOStream;
    resolve_relative_path(relative_path: string): Gio.File;
    run_dispose(): void;
    set(properties: { [key: string]: any }): void;
    set_attribute(
        attribute: string,
        type: Gio.FileAttributeType,
        value_p: any,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    set_attribute_byte_string(
        attribute: string,
        value: string,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    set_attribute_int32(
        attribute: string,
        value: number,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    set_attribute_int64(
        attribute: string,
        value: number,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    set_attribute_string(
        attribute: string,
        value: string,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    set_attribute_uint32(
        attribute: string,
        value: number,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    set_attribute_uint64(
        attribute: string,
        value: number,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    set_attributes_async(
        info: Gio.FileInfo,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.FileInfo>;
    set_attributes_async(
        info: Gio.FileInfo,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    set_attributes_async(
        info: Gio.FileInfo,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.FileInfo>;
    set_attributes_finish(result: Gio.AsyncResult): [boolean, Gio.FileInfo];
    set_attributes_from_info(
        info: Gio.FileInfo,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    set_data(key: string, data?: any): void;
    set_display_name(
        display_name: string,
        cancellable?: Gio.Cancellable,
    ): Gio.File;
    set_display_name_async(
        display_name: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<Gio.File>;
    set_display_name_async(
        display_name: string,
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    set_display_name_async(
        display_name: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<Gio.File>;
    set_display_name_finish(res: Gio.AsyncResult): Gio.File;
    set_property(property_name: string, value: any): void;
    start_mountable(
        flags: NONE,
        start_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    start_mountable(
        flags: NONE,
        start_operation: Gio.MountOperation,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    start_mountable(
        flags: NONE,
        start_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    start_mountable_finish(result: Gio.AsyncResult): boolean;
    steal_data(key: string): any;
    steal_qdata(quark: number): any;
    stop_emission_by_name(detailedName: string): void;
    stop_mountable(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    stop_mountable(
        flags: Gio.MountUnmountFlags,
        mount_operation: Gio.MountOperation,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    stop_mountable(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    stop_mountable_finish(result: Gio.AsyncResult): boolean;
    supports_thread_contexts(): boolean;
    thaw_notify(): void;
    trash(cancellable?: Gio.Cancellable): boolean;
    trash_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    trash_async(
        io_priority: number,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    trash_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    trash_finish(result: Gio.AsyncResult): boolean;
    unblock_signal_handler(id: number): void;
    unmount_mountable(
        flags: Gio.MountUnmountFlags,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    unmount_mountable(
        flags: Gio.MountUnmountFlags,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    unmount_mountable(
        flags: Gio.MountUnmountFlags,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    unmount_mountable_finish(result: Gio.AsyncResult): boolean;
    unmount_mountable_with_operation(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
    ): Promise<boolean>;
    unmount_mountable_with_operation(
        flags: Gio.MountUnmountFlags,
        mount_operation: Gio.MountOperation,
        cancellable: Gio.Cancellable,
        callback: AsyncReadyCallback<Gio.File>,
    ): void;
    unmount_mountable_with_operation(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void | Promise<boolean>;
    unmount_mountable_with_operation_finish(result: Gio.AsyncResult): boolean;
    unref(): void;
    vfunc_append_to(
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileOutputStream;
    vfunc_append_to_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_append_to_finish(res: Gio.AsyncResult): Gio.FileOutputStream;
    vfunc_constructed(): void;
    vfunc_copy(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
    ): boolean;
    vfunc_copy_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_copy_finish(res: Gio.AsyncResult): boolean;
    vfunc_create(
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileOutputStream;
    vfunc_create_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_create_finish(res: Gio.AsyncResult): Gio.FileOutputStream;
    vfunc_create_readwrite(
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileIOStream;
    vfunc_create_readwrite_async(
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_create_readwrite_finish(res: Gio.AsyncResult): Gio.FileIOStream;
    vfunc_delete_file(cancellable?: Gio.Cancellable): boolean;
    vfunc_delete_file_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_delete_file_finish(result: Gio.AsyncResult): boolean;
    vfunc_dispatch_properties_changed(
        n_pspecs: number,
        pspecs: GObject.ParamSpec,
    ): void;
    vfunc_dispose(): void;
    vfunc_dup(): Gio.File;
    vfunc_eject_mountable(
        flags: Gio.MountUnmountFlags,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_eject_mountable_finish(result: Gio.AsyncResult): boolean;
    vfunc_eject_mountable_with_operation(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_eject_mountable_with_operation_finish(
        result: Gio.AsyncResult,
    ): boolean;
    vfunc_enumerate_children(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileEnumerator;
    vfunc_enumerate_children_async(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_enumerate_children_finish(res: Gio.AsyncResult): Gio.FileEnumerator;
    vfunc_equal(file2: Gio.File): boolean;
    vfunc_finalize(): void;
    vfunc_find_enclosing_mount(cancellable?: Gio.Cancellable): Gio.Mount;
    vfunc_find_enclosing_mount_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_find_enclosing_mount_finish(res: Gio.AsyncResult): Gio.Mount;
    vfunc_get_basename(): string;
    vfunc_get_child_for_display_name(display_name: string): Gio.File;
    vfunc_get_parent(): Gio.File;
    vfunc_get_parse_name(): string;
    vfunc_get_path(): string;
    vfunc_get_property(
        property_id: number,
        value: any,
        pspec: GObject.ParamSpec,
    ): void;
    vfunc_get_relative_path(descendant: Gio.File): string;
    vfunc_get_uri(): string;
    vfunc_get_uri_scheme(): string;
    vfunc_has_uri_scheme(uri_scheme: string): boolean;
    vfunc_hash(): number;
    vfunc_is_native(): boolean;
    vfunc_make_directory(cancellable?: Gio.Cancellable): boolean;
    vfunc_make_directory_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_make_directory_finish(result: Gio.AsyncResult): boolean;
    vfunc_make_symbolic_link(
        symlink_value: string,
        cancellable?: Gio.Cancellable,
    ): boolean;
    vfunc_make_symbolic_link_async(
        symlink_value: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_make_symbolic_link_finish(result: Gio.AsyncResult): boolean;
    vfunc_measure_disk_usage(
        flags: Gio.FileMeasureFlags,
        cancellable: Gio.Cancellable,
        progress_callback: FileMeasureProgressCallback,
    ): [boolean, number, number, number];
    vfunc_measure_disk_usage_finish(
        result: Gio.AsyncResult,
    ): [boolean, number, number, number];
    vfunc_monitor_dir(
        flags: Gio.FileMonitorFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileMonitor;
    vfunc_monitor_file(
        flags: Gio.FileMonitorFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileMonitor;
    vfunc_mount_enclosing_volume(
        flags: NONE,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_mount_enclosing_volume_finish(result: Gio.AsyncResult): boolean;
    vfunc_mount_mountable(
        flags: NONE,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_mount_mountable_finish(result: Gio.AsyncResult): Gio.File;
    vfunc_move(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
    ): boolean;
    vfunc_move_async(
        destination: Gio.File,
        flags: Gio.FileCopyFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        progress_callback?: FileProgressCallback,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_move_finish(result: Gio.AsyncResult): boolean;
    vfunc_notify(pspec: GObject.ParamSpec): void;
    vfunc_open_readwrite(cancellable?: Gio.Cancellable): Gio.FileIOStream;
    vfunc_open_readwrite_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_open_readwrite_finish(res: Gio.AsyncResult): Gio.FileIOStream;
    vfunc_poll_mountable(
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_poll_mountable_finish(result: Gio.AsyncResult): boolean;
    vfunc_prefix_matches(file: Gio.File): boolean;
    vfunc_query_exists(cancellable?: Gio.Cancellable): boolean;
    vfunc_query_filesystem_info(
        attributes: string,
        cancellable?: Gio.Cancellable,
    ): Gio.FileInfo;
    vfunc_query_filesystem_info_async(
        attributes: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_query_filesystem_info_finish(res: Gio.AsyncResult): Gio.FileInfo;
    vfunc_query_info(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileInfo;
    vfunc_query_info_async(
        attributes: string,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_query_info_finish(res: Gio.AsyncResult): Gio.FileInfo;
    vfunc_query_settable_attributes(
        cancellable?: Gio.Cancellable,
    ): FileAttributeInfoList;
    vfunc_query_writable_namespaces(
        cancellable?: Gio.Cancellable,
    ): FileAttributeInfoList;
    vfunc_read_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_read_finish(res: Gio.AsyncResult): Gio.FileInputStream;
    vfunc_read_fn(cancellable?: Gio.Cancellable): Gio.FileInputStream;
    vfunc_replace(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileOutputStream;
    vfunc_replace_async(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_replace_finish(res: Gio.AsyncResult): Gio.FileOutputStream;
    vfunc_replace_readwrite(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        cancellable?: Gio.Cancellable,
    ): Gio.FileIOStream;
    vfunc_replace_readwrite_async(
        etag: string,
        make_backup: boolean,
        flags: Gio.FileCreateFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_replace_readwrite_finish(res: Gio.AsyncResult): Gio.FileIOStream;
    vfunc_resolve_relative_path(relative_path: string): Gio.File;
    vfunc_set_attribute(
        attribute: string,
        type: Gio.FileAttributeType,
        value_p: any,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    vfunc_set_attributes_async(
        info: Gio.FileInfo,
        flags: Gio.FileQueryInfoFlags,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_set_attributes_finish(
        result: Gio.AsyncResult,
    ): [boolean, Gio.FileInfo];
    vfunc_set_attributes_from_info(
        info: Gio.FileInfo,
        flags: Gio.FileQueryInfoFlags,
        cancellable?: Gio.Cancellable,
    ): boolean;
    vfunc_set_display_name(
        display_name: string,
        cancellable?: Gio.Cancellable,
    ): Gio.File;
    vfunc_set_display_name_async(
        display_name: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_set_display_name_finish(res: Gio.AsyncResult): Gio.File;
    vfunc_set_property(
        property_id: number,
        value: any,
        pspec: GObject.ParamSpec,
    ): void;
    vfunc_start_mountable(
        flags: NONE,
        start_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_start_mountable_finish(result: Gio.AsyncResult): boolean;
    vfunc_stop_mountable(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_stop_mountable_finish(result: Gio.AsyncResult): boolean;
    vfunc_trash(cancellable?: Gio.Cancellable): boolean;
    vfunc_trash_async(
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_trash_finish(result: Gio.AsyncResult): boolean;
    vfunc_unmount_mountable(
        flags: Gio.MountUnmountFlags,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_unmount_mountable_finish(result: Gio.AsyncResult): boolean;
    vfunc_unmount_mountable_with_operation(
        flags: Gio.MountUnmountFlags,
        mount_operation?: Gio.MountOperation,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    vfunc_unmount_mountable_with_operation_finish(
        result: Gio.AsyncResult,
    ): boolean;
    watch_closure(closure: Closure): void;
}

Hierarchy (View Summary)

Index

Properties - Inherited from GObject

Methods

append_to append_to_async append_to_finish build_attribute_list_for_copy copy copy_async copy_attributes copy_finish create create_async create_finish create_readwrite create_readwrite_async create_readwrite_finish delete delete_async delete_finish dup eject_mountable eject_mountable_finish eject_mountable_with_operation eject_mountable_with_operation_finish enumerate_children enumerate_children_async enumerate_children_finish equal find_enclosing_mount find_enclosing_mount_async find_enclosing_mount_finish get_basename get_child get_child_for_display_name get_parent get_parse_name get_path get_relative_path get_uri get_uri_scheme has_parent has_prefix has_uri_scheme hash is_native load_bytes load_bytes_async load_bytes_finish load_contents load_contents_async load_contents_finish load_partial_contents_finish make_directory make_directory_async make_directory_finish make_directory_with_parents make_symbolic_link make_symbolic_link_async make_symbolic_link_finish measure_disk_usage measure_disk_usage_finish monitor monitor_directory monitor_file mount_enclosing_volume mount_enclosing_volume_finish mount_mountable mount_mountable_finish move move_async move_finish open_readwrite open_readwrite_async open_readwrite_finish peek_path poll_mountable poll_mountable_finish query_default_handler query_default_handler_async query_default_handler_finish query_exists query_file_type query_filesystem_info query_filesystem_info_async query_filesystem_info_finish query_info query_info_async query_info_finish query_settable_attributes query_writable_namespaces read read_async read_finish replace replace_async replace_contents replace_contents_async replace_contents_bytes_async replace_contents_finish replace_finish replace_readwrite replace_readwrite_async replace_readwrite_finish resolve_relative_path set_attribute set_attribute_byte_string set_attribute_int32 set_attribute_int64 set_attribute_string set_attribute_uint32 set_attribute_uint64 set_attributes_async set_attributes_finish set_attributes_from_info set_display_name set_display_name_async set_display_name_finish start_mountable start_mountable_finish stop_mountable stop_mountable_finish supports_thread_contexts trash trash_async trash_finish unmount_mountable unmount_mountable_finish unmount_mountable_with_operation unmount_mountable_with_operation_finish

Methods - Inherited from GObject

Methods - Inherited from Gio.File.Interface

vfunc_append_to vfunc_append_to_async vfunc_append_to_finish vfunc_copy vfunc_copy_async vfunc_copy_finish vfunc_create vfunc_create_async vfunc_create_finish vfunc_create_readwrite vfunc_create_readwrite_async vfunc_create_readwrite_finish vfunc_delete_file vfunc_delete_file_async vfunc_delete_file_finish vfunc_dup vfunc_eject_mountable vfunc_eject_mountable_finish vfunc_eject_mountable_with_operation vfunc_eject_mountable_with_operation_finish vfunc_enumerate_children vfunc_enumerate_children_async vfunc_enumerate_children_finish vfunc_equal vfunc_find_enclosing_mount vfunc_find_enclosing_mount_async vfunc_find_enclosing_mount_finish vfunc_get_basename vfunc_get_child_for_display_name vfunc_get_parent vfunc_get_parse_name vfunc_get_path vfunc_get_relative_path vfunc_get_uri vfunc_get_uri_scheme vfunc_has_uri_scheme vfunc_hash vfunc_is_native vfunc_make_directory vfunc_make_directory_async vfunc_make_directory_finish vfunc_make_symbolic_link vfunc_make_symbolic_link_async vfunc_make_symbolic_link_finish vfunc_measure_disk_usage vfunc_measure_disk_usage_finish vfunc_monitor_dir vfunc_monitor_file vfunc_mount_enclosing_volume vfunc_mount_enclosing_volume_finish vfunc_mount_mountable vfunc_mount_mountable_finish vfunc_move vfunc_move_async vfunc_move_finish vfunc_open_readwrite vfunc_open_readwrite_async vfunc_open_readwrite_finish vfunc_poll_mountable vfunc_poll_mountable_finish vfunc_prefix_matches vfunc_query_exists vfunc_query_filesystem_info vfunc_query_filesystem_info_async vfunc_query_filesystem_info_finish vfunc_query_info vfunc_query_info_async vfunc_query_info_finish vfunc_query_settable_attributes vfunc_query_writable_namespaces vfunc_read_async vfunc_read_finish vfunc_read_fn vfunc_replace vfunc_replace_async vfunc_replace_finish vfunc_replace_readwrite vfunc_replace_readwrite_async vfunc_replace_readwrite_finish vfunc_resolve_relative_path vfunc_set_attribute vfunc_set_attributes_async vfunc_set_attributes_finish vfunc_set_attributes_from_info vfunc_set_display_name vfunc_set_display_name_async vfunc_set_display_name_finish vfunc_start_mountable vfunc_start_mountable_finish vfunc_stop_mountable vfunc_stop_mountable_finish vfunc_trash vfunc_trash_async vfunc_trash_finish vfunc_unmount_mountable vfunc_unmount_mountable_finish vfunc_unmount_mountable_with_operation vfunc_unmount_mountable_with_operation_finish

Properties - Inherited from GObject

Compile-time signal type information.

This instance property is generated only for TypeScript type checking. It is not defined at runtime and should not be accessed in JS code.

Methods

  • Prepares the file attribute query string for copying to file.

    This function prepares an attribute query string to be passed to g_file_query_info() to get a list of attributes normally copied with the file (see g_file_copy_attributes() for the detailed description). This function is used by the implementation of g_file_copy_attributes() and is useful when one needs to query and set the attributes in two stages (e.g., for recursive move of a directory).

    Parameters

    Returns string

    an attribute query string for g_file_query_info(), or null if an error occurs.

  • Deletes a file. If the file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().

    If file doesn’t exist, Gio.IOErrorEnum.NOT_FOUND will be returned. This allows for deletion to be implemented avoiding time-of-check to time-of-use races:

    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 null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns boolean

    true if the file was deleted. false otherwise.

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

    g_file_dup() is useful when a second handle is needed to the same underlying file, for use in a separate thread (Gio.File is not thread-safe). For use within the same thread, use g_object_ref() to increment the existing object’s reference count.

    This call does no blocking I/O.

    Returns Gio.File

    a new Gio.File that is a duplicate of the given Gio.File.

  • Gets the requested information about the files in a directory. The result is a Gio.FileEnumerator object that will give out 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 G_FILE_ATTRIBUTE_STANDARD_NAME. G_FILE_ATTRIBUTE_STANDARD_NAME should always be specified if you plan to call g_file_enumerator_get_child() or g_file_enumerator_iterate() on the returned enumerator.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If the file does not exist, the Gio.IOErrorEnum.NOT_FOUND error will be returned. If the file is not a directory, the Gio.IOErrorEnum.NOT_DIRECTORY error will be returned. Other errors are possible too.

    Parameters

    Returns Gio.FileEnumerator

    A Gio.FileEnumerator if successful, null on error. Free the returned object with g_object_unref().

  • Checks if the two given GFiles refer to the same file.

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

    This call does no blocking I/O.

    Parameters

    Returns boolean

    true if file1 and file2 are equal.

  • Asynchronously gets the mount for the file.

    For more details, see g_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 g_file_find_enclosing_mount_finish() to get the result of the operation.

    Parameters

    Returns Promise<Gio.Mount>

  • Asynchronously gets the mount for the file.

    For more details, see g_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 g_file_find_enclosing_mount_finish() to get the result of the operation.

    Parameters

    Returns void

  • Asynchronously gets the mount for the file.

    For more details, see g_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 g_file_find_enclosing_mount_finish() to get the result of the operation.

    Parameters

    Returns void | Promise<Gio.Mount>

  • Gets the base name (the last component of the path) for a given 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 G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().

    This call does no blocking I/O.

    Returns string

    string containing the Gio.File's base name, or null if given Gio.File is invalid. The returned string should be freed with g_free() when no longer needed.

  • 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 Gio.File that points to it. You can use this for instance to create that file.

    This call does no blocking I/O.

    Parameters

    • name: string

      string containing the child's basename

    Returns Gio.File

    a Gio.File to a child specified by name. Free the returned object with g_object_unref().

  • 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 null and error will be set. This is very useful when constructing a 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.

    Parameters

    • display_name: string

      string to a possible child

    Returns Gio.File

    a Gio.File to the specified child, or null if the display name couldn't be converted. Free the returned object with g_object_unref().

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

    This call does no blocking I/O.

    Returns Gio.File

    a Gio.File structure to the parent of the given Gio.File or null if there is no parent. Free the returned object with g_object_unref().

  • 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 Gio.File back using g_file_parse_name().

    This is generally used to show the 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.

    Returns string

    a string containing the Gio.File's parse name. The returned string should be freed with g_free() when no longer needed.

  • Gets the local pathname for Gio.File, if one exists. If non-null, this is guaranteed to be an absolute, canonical path. It might contain symlinks.

    This call does no blocking I/O.

    Returns string

    string containing the Gio.File's path, or null if no such path exists. The returned string should be freed with g_free() when no longer needed.

  • Gets the path for descendant relative to parent.

    This call does no blocking I/O.

    Parameters

    Returns string

    string with the relative path from descendant to parent, or null if descendant doesn't have parent as prefix. The returned string should be freed with g_free() when no longer needed.

  • Gets the URI for the file.

    This call does no blocking I/O.

    Returns string

    a string containing the Gio.File's URI. If the Gio.File was constructed with an invalid URI, an invalid URI is returned. The returned string should be freed with g_free() when no longer needed.

  • Gets the URI scheme for a Gio.File. RFC 3986 decodes the scheme as:

    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 Gio.File, in that it might be replaced with one that is logically equivalent to the Gio.File.

    This call does no blocking I/O.

    Returns string

    a string containing the URI scheme for the given Gio.File or null if the Gio.File was constructed with an invalid URI. The returned string should be freed with g_free() when no longer needed.

  • Checks if file has a parent, and optionally, if it is parent.

    If parent is null then this function returns true if file has any parent at all. If parent is non-null then true is only returned if file is an immediate child of parent.

    Parameters

    • Optionalparent: Gio.File

      the parent to check for, or null

    Returns boolean

    true if file is an immediate child of parent (or any parent in the case that parent is null).

  • 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 Gio.File is not a prefix of itself. If you want to check for equality, use g_file_equal().

    This call does no I/O, as it works purely on names. As such it can sometimes return false even if file is inside a prefix (from a filesystem point of view), because the prefix of file is an alias of prefix.

    Parameters

    Returns boolean

    true if the file's parent, grandparent, etc is prefix, false otherwise.

  • Checks to see if a Gio.File has a given URI scheme.

    This call does no blocking I/O.

    Parameters

    • uri_scheme: string

      a string containing a URI scheme

    Returns boolean

    true if Gio.File's backend supports the given URI scheme, false if URI scheme is null, not supported, or Gio.File is invalid.

  • 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 false, but g_file_get_path() will still return a native path.

    This call does no blocking I/O.

    Returns boolean

    true if file is native

  • Loads the contents of file and returns it as 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 g_file_load_contents() and g_bytes_new_take().

    For resources, etag_out will be set to null.

    The data contained in the resulting GLib.Bytes is always zero-terminated, but this is not included in the GLib.Bytes length. The resulting GLib.Bytes should be freed with g_bytes_unref() when no longer in use.

    Parameters

    Returns [GLib.Bytes, string]

    a GLib.Bytes or null and error is set

  • Asynchronously loads the contents of file as 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 g_file_load_contents_async() and g_bytes_new_take().

    callback should call g_file_load_bytes_finish() to get the result of this asynchronous operation.

    See g_file_load_bytes() for more information.

    Parameters

    Returns Promise<[GLib.Bytes, string]>

  • Asynchronously loads the contents of file as 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 g_file_load_contents_async() and g_bytes_new_take().

    callback should call g_file_load_bytes_finish() to get the result of this asynchronous operation.

    See g_file_load_bytes() for more information.

    Parameters

    Returns void

  • Asynchronously loads the contents of file as 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 g_file_load_contents_async() and g_bytes_new_take().

    callback should call g_file_load_bytes_finish() to get the result of this asynchronous operation.

    See g_file_load_bytes() for more information.

    Parameters

    Returns void | Promise<[GLib.Bytes, string]>

  • 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 g_free() when no longer needed.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns [boolean, Uint8Array<ArrayBufferLike>, string]

    true if the file's contents were successfully loaded. false if there were errors.

  • Starts an asynchronous load of the file's contents.

    For more details, see g_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 g_file_load_contents_finish() with the Gio.AsyncResult returned by the callback.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns Promise<[Uint8Array<ArrayBufferLike>, string]>

  • Starts an asynchronous load of the file's contents.

    For more details, see g_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 g_file_load_contents_finish() with the Gio.AsyncResult returned by the callback.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns void

  • Starts an asynchronous load of the file's contents.

    For more details, see g_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 g_file_load_contents_finish() with the Gio.AsyncResult returned by the callback.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns void | Promise<[Uint8Array<ArrayBufferLike>, string]>

  • 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 g_free() when no longer needed. If etag_out is present, it will be set to the new entity tag for the file.

    Returns [boolean, Uint8Array<ArrayBufferLike>, string]

    true if the load was successful. If false and error is present, it will be set appropriately.

  • Finishes an asynchronous partial load operation that was started with g_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 g_free() when no longer needed.

    Returns [boolean, Uint8Array<ArrayBufferLike>, string]

    true if the load was successful. If false and error is present, it will be set appropriately.

  • 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 Gio.File. To recursively create directories, see g_file_make_directory_with_parents().

    This function will fail if the parent directory does not exist, setting error to Gio.IOErrorEnum.NOT_FOUND. If the file system doesn't support creating directories, this function will fail, setting error to Gio.IOErrorEnum.NOT_SUPPORTED. If the directory already exists, Gio.IOErrorEnum.EXISTS will be returned.

    For a local Gio.File the newly created directory will have the default (current) ownership and permissions of the current process.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns boolean

    true on successful creation, false otherwise.

  • 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 Gio.IOErrorEnum.NOT_SUPPORTED. If the directory itself already exists, this function will fail setting error to Gio.IOErrorEnum.EXISTS, unlike the similar g_mkdir_with_parents().

    For a local Gio.File the newly created directories will have the default (current) ownership and permissions of the current process.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns boolean

    true if all directories have been successfully created, false otherwise.

  • Creates a symbolic link named file which contains the string symlink_value.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    • symlink_value: string

      a string with the path for the target of the new symlink

    • Optionalcancellable: Gio.Cancellable

      optional Gio.Cancellable object, null to ignore

    Returns boolean

    true on the creation of a new symlink, false otherwise.

  • Collects the results from an earlier call to g_file_measure_disk_usage_async(). See g_file_measure_disk_usage() for more information.

    Parameters

    Returns [boolean, number, number, number]

    true if successful, with the out parameters set. false otherwise, with error set.

  • Finishes a mount operation started by g_file_mount_enclosing_volume().

    Parameters

    Returns boolean

    true if successful. If an error has occurred, this function will return false and set error appropriately if present.

  • Opens an existing file for reading and writing. The result is a Gio.FileIOStream that can be used to read and write the contents of the file.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If the file does not exist, the Gio.IOErrorEnum.NOT_FOUND error will be returned. If the file is a directory, the 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.

    Parameters

    Returns Gio.FileIOStream

    Gio.FileIOStream or null on error. Free the returned object with g_object_unref().

  • Exactly like g_file_get_path(), but caches the result via g_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.

    Returns string

    string containing the Gio.File's path, or null if no such path exists. The returned string is owned by file.

  • Finishes a poll operation. See g_file_poll_mountable() for details.

    Finish an asynchronous poll operation that was polled with g_file_poll_mountable().

    Parameters

    Returns boolean

    true if the operation finished successfully. false otherwise.

  • Utility function to check if a particular file exists.

    The fallback implementation of this API is using Gio.File.query_info and therefore may do blocking I/O. To asynchronously query the existence of a file, use Gio.File.query_info_async.

    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 g_file_create() which will either atomically create the file or fail with a 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.

    Parameters

    Returns boolean

    true if the file exists (and can be detected without error), false otherwise (or if cancelled).

  • Similar to g_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 G_FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem in bytes), G_FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes available), and G_FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem).

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If the file does not exist, the Gio.IOErrorEnum.NOT_FOUND error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

    Parameters

    Returns Gio.FileInfo

    a Gio.FileInfo or null if there was an error. Free the returned object with g_object_unref().

  • Asynchronously gets the requested information about the filesystem that the specified file is on. The result is a Gio.FileInfo object that contains key-value attributes (such as type or size for the file).

    For more details, see g_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 g_file_query_info_finish() to get the result of the operation.

    Parameters

    Returns Promise<Gio.FileInfo>

  • Asynchronously gets the requested information about the filesystem that the specified file is on. The result is a Gio.FileInfo object that contains key-value attributes (such as type or size for the file).

    For more details, see g_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 g_file_query_info_finish() to get the result of the operation.

    Parameters

    Returns void

  • Asynchronously gets the requested information about the filesystem that the specified file is on. The result is a Gio.FileInfo object that contains key-value attributes (such as type or size for the file).

    For more details, see g_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 g_file_query_info_finish() to get the result of the operation.

    Parameters

    Returns void | Promise<Gio.FileInfo>

  • Gets the requested information about specified file.

    The result is a 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. In particular this means that if a file is inaccessible (due to being in a folder with restrictive permissions), for example, you can expect the returned Gio.FileInfo to have very few attributes set. You should check whether an attribute is set using Gio.FileInfo.has_attribute before trying to retrieve its value.

    It is guaranteed that if any of the following attributes are listed in attributes, they will always be set in the returned Gio.FileInfo, even if the user doesn’t have permissions to access the file:

    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 might be "standard::*,owner::user". The standard attributes are available as defines, like Gio.FILE_ATTRIBUTE_STANDARD_NAME.

    If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error 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 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 Gio.IOErrorEnum.NOT_FOUND error will be returned. Other errors are possible too, and depend on what kind of file system the file is on.

    Parameters

    Returns Gio.FileInfo

    a Gio.FileInfo for the given file

  • 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 null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns FileAttributeInfoList

    a Gio.FileAttributeInfoList describing the settable attributes. When you are done with it, release it with g_file_attribute_info_list_unref()

  • 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 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 null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If you pass in a non-null etag value and file already exists, then this value is compared to the current entity tag of the file, and if they differ an 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 g_file_output_stream_get_etag() after you've finished writing and closed the Gio.FileOutputStream. When you load a new file you can use g_file_input_stream_query_info() to get the etag of the file.

    If make_backup is true, this function will attempt to make a backup of the current file before overwriting it. If this fails a Gio.IOErrorEnum.CANT_CREATE_BACKUP error will be returned. If you want to replace anyway, try again with make_backup set to false.

    If the file is a directory the Gio.IOErrorEnum.IS_DIRECTORY error will be returned, and if the file is some other form of non-regular file then a Gio.IOErrorEnum.NOT_REGULAR_FILE error will be returned. Some file systems don't allow all file names, and may return an Gio.IOErrorEnum.INVALID_FILENAME error, and if the name is to long Gio.IOErrorEnum.FILENAME_TOO_LONG will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

    Parameters

    Returns Gio.FileOutputStream

    a Gio.FileOutputStream or null on error. Free the returned object with g_object_unref().

  • Replaces the contents of file with contents of length bytes.

    If etag is specified (not null), any existing file must have that etag, or the error Gio.IOErrorEnum.WRONG_ETAG will be returned.

    If make_backup is true, this function will attempt to make a backup of file. Internally, it uses g_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 null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error 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.

    Parameters

    Returns [boolean, string]

    true if successful. If an error has occurred, this function will return false and set error appropriately if present.

  • 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 g_file_replace_contents_finish().

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If make_backup is 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 g_file_replace_contents_bytes_async() for a GLib.Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

    Parameters

    Returns Promise<string>

  • 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 g_file_replace_contents_finish().

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If make_backup is 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 g_file_replace_contents_bytes_async() for a GLib.Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

    Parameters

    Returns void

  • 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 g_file_replace_contents_finish().

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If make_backup is 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 g_file_replace_contents_bytes_async() for a GLib.Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

    Parameters

    Returns void | Promise<string>

  • Parameters

    Returns void

  • Finishes an asynchronous replace of the given file. See g_file_replace_contents_async(). Sets new_etag to the new entity tag for the document, if present.

    Returns [boolean, string]

    true on success, false on failure.

  • 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 g_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.

    Parameters

    Returns Gio.FileIOStream

    a Gio.FileIOStream or null on error. Free the returned object with g_object_unref().

  • 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).

    Parameters

    • relative_path: string

      a given relative path string

    Returns Gio.File

    a Gio.File for the resolved path.

  • 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 (G_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 g_file_set_display_name().

    On success the resulting converted filename is returned.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns Gio.File

    a Gio.File specifying what file was renamed to, or null if there was an error. Free the returned object with g_object_unref().

  • Asynchronously sets the display name for a given Gio.File.

    For more details, see g_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 g_file_set_display_name_finish() to get the result of the operation.

    Parameters

    Returns Promise<Gio.File>

  • Asynchronously sets the display name for a given Gio.File.

    For more details, see g_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 g_file_set_display_name_finish() to get the result of the operation.

    Parameters

    Returns void

  • Asynchronously sets the display name for a given Gio.File.

    For more details, see g_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 g_file_set_display_name_finish() to get the result of the operation.

    Parameters

    Returns void | Promise<Gio.File>

  • Finishes a start operation. See g_file_start_mountable() for details.

    Finish an asynchronous start operation that was started with g_file_start_mountable().

    Parameters

    Returns boolean

    true if the operation finished successfully. false otherwise.

  • Finishes a stop operation, see g_file_stop_mountable() for details.

    Finish an asynchronous stop operation that was started with g_file_stop_mountable().

    Parameters

    Returns boolean

    true if the operation finished successfully. false otherwise.

  • Checks if file supports thread-default main contexts (see GLib.MainContext.push_thread_default) If this returns false, you cannot perform asynchronous operations on file in a thread that has a thread-default context.

    Returns boolean

    Whether or not file supports thread-default contexts.

  • 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 g_unix_mount_entry_is_system_internal()), so this call can return the Gio.IOErrorEnum.NOT_SUPPORTED error. Since GLib 2.66, the x-gvfs-notrash unix mount option can be used to disable g_file_trash() support for particular mounts, the 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 g_file_trash() support for particular system mounts.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns boolean

    true on successful trash, false otherwise.

  • Finishes an unmount operation, see g_file_unmount_mountable() for details.

    Finish an asynchronous unmount operation that was started with g_file_unmount_mountable().

    Parameters

    Returns boolean

    true if the operation finished successfully. false otherwise.

  • Finishes an unmount operation, see g_file_unmount_mountable_with_operation() for details.

    Finish an asynchronous unmount operation that was started with g_file_unmount_mountable_with_operation().

    Parameters

    Returns boolean

    true if the operation finished successfully. false otherwise.

Methods - Inherited from GObject

  • Creates a binding between source_property on source and target_property on target.

    Whenever the source_property is changed the target_property is updated using the same value. For instance:

      g_object_bind_property (action, "active", widget, "sensitive", 0);
    

    Will result in the "sensitive" property of the widget GObject.Object instance to be updated with the same value of the "active" property of the action GObject.Object instance.

    If flags contains GObject.BindingFlags.BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well.

    The binding will automatically be removed when either the source or the target instances are finalized. To remove the binding without affecting the source and the target you can just call g_object_unref() on the returned GObject.Binding instance.

    Removing the binding by calling g_object_unref() on it must only be done if the binding, source and target are only used from a single thread and it is clear that both source and target outlive the binding. Especially it is not safe to rely on this if the binding, source or target can be finalized from different threads. Keep another reference to the binding and use g_binding_unbind() instead to be on the safe side.

    A GObject.Object can have multiple bindings.

    Parameters

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Complete version of g_object_bind_property().

    Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    If flags contains GObject.BindingFlags.BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well. The transform_from function is only used in case of bidirectional bindings, otherwise it will be ignored

    The binding will automatically be removed when either the source or the target instances are finalized. This will release the reference that is being held on the GObject.Binding instance; if you want to hold on to the GObject.Binding instance, you will need to hold a reference to it.

    To remove the binding, call g_binding_unbind().

    A GObject.Object can have multiple bindings.

    The same user_data parameter will be used for both transform_to and transform_from transformation functions; the notify function will be called once, when the binding is removed. If you need different data for each transformation function, please use g_object_bind_property_with_closures() instead.

    Parameters

    • source_property: string

      the property on source to bind

    • target: GObject.Object

      the target GObject.Object

    • target_property: string

      the property on target to bind

    • flags: GObject.BindingFlags

      flags to pass to GObject.Binding

    • Optionaltransform_to: BindingTransformFunc

      the transformation function from the source to the target, or null to use the default

    • Optionaltransform_from: BindingTransformFunc

      the transformation function from the target to the source, or null to use the default

    • Optionalnotify: DestroyNotify

      a function to call when disposing the binding, to free resources used by the transformation functions, or null if not required

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    This function is the language bindings friendly version of g_object_bind_property_full(), using GClosures instead of function pointers.

    Parameters

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Disconnects a handler from an instance so it will not be called during any future or currently ongoing emissions of the signal it has been connected to.

    Parameters

    • id: number

      Handler ID of the handler to be disconnected

    Returns void

  • This function is intended for GObject.Object implementations to re-enforce a [floating][floating-ref] object reference. Doing this is seldom required: all GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling g_object_ref_sink().

    Returns void

  • Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one GObject.Object::notify signal is emitted for each property modified while the object is frozen.

    This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.

    Returns void

  • Gets a named field from the objects table of associations (see g_object_set_data()).

    Parameters

    • key: string

      name of the key for that association

    Returns any

    the data if found, or null if no such data exists.

  • Gets a property of an object.

    The value can be:

    • an empty GObject.Value initialized by G_VALUE_INIT, which will be automatically initialized with the expected type of the property (since GLib 2.60)
    • a GObject.Value initialized with the expected type of the property
    • a GObject.Value initialized with a type to which the expected type of the property can be transformed

    In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling GObject.Value.unset.

    Note that GObject.Object.get_property is really intended for language bindings, GObject.Object.get is much more convenient for C programming.

    Parameters

    • property_name: string

      The name of the property to get

    • value: any

      Return location for the property value. Can be an empty GObject.Value initialized by G_VALUE_INIT (auto-initialized with expected type since GLib 2.60), a GObject.Value initialized with the expected property type, or a GObject.Value initialized with a transformable type

    Returns any

  • This function gets back user data pointers stored via g_object_set_qdata().

    Parameters

    • quark: number

      A GLib.Quark, naming the user data pointer

    Returns any

    The user data pointer set, or null

  • Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

    Parameters

    • names: string[]

      the names of each property to get

    • values: any[]

      the values of each property to get

    Returns void

  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    • property_name: string

      the name of a property installed on the class of object.

    Returns void

  • Emits a "notify" signal for the property specified by pspec on object.

    This function omits the property name lookup, hence it is faster than g_object_notify().

    One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:

      typedef enum
    {
    PROP_FOO = 1,
    PROP_LAST
    } MyObjectProperty;

    static GParamSpec *properties[PROP_LAST];

    static void
    my_object_class_init (MyObjectClass *klass)
    {
    properties[PROP_FOO] = g_param_spec_int ("foo", NULL, NULL,
    0, 100,
    50,
    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
    g_object_class_install_property (gobject_class,
    PROP_FOO,
    properties[PROP_FOO]);
    }

    and then notify a change on the "foo" property with:

      g_object_notify_by_pspec (self, properties[PROP_FOO]);
    

    Parameters

    Returns void

  • Increases the reference count of object.

    Since GLib 2.56, if GLIB_VERSION_MAX_ALLOWED is 2.56 or greater, the type of object will be propagated to the return type (using the GCC typeof() extension), so any casting the caller needs to do on the return type must be explicit.

    Returns GObject.Object

    the same object

  • Increase the reference count of object, and possibly remove the [floating][floating-ref] reference, if object has a floating reference.

    In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.

    Since GLib 2.56, the type of object will be propagated to the return type under the same conditions as for g_object_ref().

    Returns GObject.Object

    object

  • Releases all references to other objects. This can be used to break reference cycles.

    This function should only be called from object system implementations.

    Returns void

  • Sets multiple properties of an object at once. The properties argument should be a dictionary mapping property names to values.

    Parameters

    • properties: { [key: string]: any }

      Object containing the properties to set

    Returns void

  • Each object carries around a table of associations from strings to pointers. This function lets you set an association.

    If the object already had an association with that name, the old association will be destroyed.

    Internally, the key is converted to a GLib.Quark using g_quark_from_string(). This means a copy of key is kept permanently (even after object has been finalized) — so it is recommended to only use a small, bounded set of values for key in your program, to avoid the GLib.Quark storage growing unbounded.

    Parameters

    • key: string

      name of the key

    • Optionaldata: any

      data to associate with that key

    Returns void

  • Sets a property on an object.

    Parameters

    • property_name: string

      The name of the property to set

    • value: any

      The value to set the property to

    Returns void

  • Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

    Parameters

    • key: string

      name of the key

    Returns any

    the data if found, or null if no such data exists.

  • This function gets back user data pointers stored via g_object_set_qdata() and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

    void
    object_add_to_user_list (GObject *object,
    const gchar *new_string)
    {
    // the quark, naming the object data
    GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
    // retrieve the old string list
    GList *list = g_object_steal_qdata (object, quark_string_list);

    // prepend new string
    list = g_list_prepend (list, g_strdup (new_string));
    // this changed 'list', so we need to set it again
    g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
    }
    static void
    free_string_list (gpointer data)
    {
    GList *node, *list = data;

    for (node = list; node; node = node->next)
    g_free (node->data);
    g_list_free (list);
    }

    Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().

    Parameters

    • quark: number

      A GLib.Quark, naming the user data pointer

    Returns any

    The user data pointer set, or null

  • Stops a signal's emission by the given signal name. This will prevent the default handler and any subsequent signal handlers from being invoked.

    Parameters

    • detailedName: string

      Name of the signal to stop emission of

    Returns void

  • Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

    Duplicate notifications for each property are squashed so that at most one GObject.Object::notify signal is emitted for each property, in the reverse order in which they have been queued.

    It is an error to call this function when the freeze count is zero.

    Returns void

  • Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

    If the pointer to the GObject.Object may be reused in future (for example, if it is an instance variable of another object), it is recommended to clear the pointer to null rather than retain a dangling pointer to a potentially invalid GObject.Object instance. Use g_clear_object() for this.

    Returns void

  • the constructed function is called by g_object_new() as the final step of the object creation process. At the point of the call, all construction properties have been set on the object. The purpose of this call is to allow for object initialisation steps that can only be performed after construction properties have been set. constructed implementors should chain up to the constructed call of their parent class to allow it to complete its initialisation.

    Returns void

  • the dispose function is supposed to drop all references to other objects, but keep the instance otherwise intact, so that client method invocations still work. It may be run multiple times (due to reference loops). Before returning, dispose should chain up to the dispose method of the parent class.

    Returns void

  • instance finalization function, should finish the finalization of the instance begun in dispose and chain up to the finalize method of the parent class.

    Returns void

  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    Returns void

  • the generic setter for all properties of this type. Should be overridden for every type with properties. If implementations of set_property don't emit property change notification explicitly, this will be done implicitly by the type system. However, if the notify signal is emitted explicitly, the type system will not emit it a second time.

    Parameters

    Returns void

  • This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling g_closure_invalidate() on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, g_object_ref() and g_object_unref() are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

    Parameters

    Returns void

Methods - Inherited from Gio.File.Interface

  • Deletes a file. If the file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().

    If file doesn’t exist, Gio.IOErrorEnum.NOT_FOUND will be returned. This allows for deletion to be implemented avoiding time-of-check to time-of-use races:

    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 null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns boolean

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

    g_file_dup() is useful when a second handle is needed to the same underlying file, for use in a separate thread (Gio.File is not thread-safe). For use within the same thread, use g_object_ref() to increment the existing object’s reference count.

    This call does no blocking I/O.

    Returns Gio.File

  • Gets the requested information about the files in a directory. The result is a Gio.FileEnumerator object that will give out 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 G_FILE_ATTRIBUTE_STANDARD_NAME. G_FILE_ATTRIBUTE_STANDARD_NAME should always be specified if you plan to call g_file_enumerator_get_child() or g_file_enumerator_iterate() on the returned enumerator.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If the file does not exist, the Gio.IOErrorEnum.NOT_FOUND error will be returned. If the file is not a directory, the Gio.IOErrorEnum.NOT_DIRECTORY error will be returned. Other errors are possible too.

    Parameters

    Returns Gio.FileEnumerator

  • Checks if the two given GFiles refer to the same file.

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

    This call does no blocking I/O.

    Parameters

    Returns boolean

  • Gets the base name (the last component of the path) for a given 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 G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().

    This call does no blocking I/O.

    Returns string

  • 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 null and error will be set. This is very useful when constructing a 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.

    Parameters

    • display_name: string

      string to a possible child

    Returns Gio.File

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

    This is generally used to show the 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.

    Returns string

  • Gets the local pathname for Gio.File, if one exists. If non-null, this is guaranteed to be an absolute, canonical path. It might contain symlinks.

    This call does no blocking I/O.

    Returns string

  • Gets the URI scheme for a Gio.File. RFC 3986 decodes the scheme as:

    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 Gio.File, in that it might be replaced with one that is logically equivalent to the Gio.File.

    This call does no blocking I/O.

    Returns string

  • 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 false, but g_file_get_path() will still return a native path.

    This call does no blocking I/O.

    Returns boolean

  • 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 Gio.File. To recursively create directories, see g_file_make_directory_with_parents().

    This function will fail if the parent directory does not exist, setting error to Gio.IOErrorEnum.NOT_FOUND. If the file system doesn't support creating directories, this function will fail, setting error to Gio.IOErrorEnum.NOT_SUPPORTED. If the directory already exists, Gio.IOErrorEnum.EXISTS will be returned.

    For a local Gio.File the newly created directory will have the default (current) ownership and permissions of the current process.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns boolean

  • Creates a symbolic link named file which contains the string symlink_value.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    • symlink_value: string

      a string with the path for the target of the new symlink

    • Optionalcancellable: Gio.Cancellable

      optional Gio.Cancellable object, null to ignore

    Returns boolean

  • 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 Gio.File is not a prefix of itself. If you want to check for equality, use g_file_equal().

    This call does no I/O, as it works purely on names. As such it can sometimes return false even if file is inside a prefix (from a filesystem point of view), because the prefix of file is an alias of prefix.

    Parameters

    Returns boolean

  • Utility function to check if a particular file exists.

    The fallback implementation of this API is using Gio.File.query_info and therefore may do blocking I/O. To asynchronously query the existence of a file, use Gio.File.query_info_async.

    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 g_file_create() which will either atomically create the file or fail with a 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.

    Parameters

    Returns boolean

  • Similar to g_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 G_FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem in bytes), G_FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes available), and G_FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem).

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If the file does not exist, the Gio.IOErrorEnum.NOT_FOUND error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

    Parameters

    Returns Gio.FileInfo

  • Gets the requested information about specified file.

    The result is a 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. In particular this means that if a file is inaccessible (due to being in a folder with restrictive permissions), for example, you can expect the returned Gio.FileInfo to have very few attributes set. You should check whether an attribute is set using Gio.FileInfo.has_attribute before trying to retrieve its value.

    It is guaranteed that if any of the following attributes are listed in attributes, they will always be set in the returned Gio.FileInfo, even if the user doesn’t have permissions to access the file:

    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 might be "standard::*,owner::user". The standard attributes are available as defines, like Gio.FILE_ATTRIBUTE_STANDARD_NAME.

    If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error 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 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 Gio.IOErrorEnum.NOT_FOUND error will be returned. Other errors are possible too, and depend on what kind of file system the file is on.

    Parameters

    Returns Gio.FileInfo

  • 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 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 null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    If you pass in a non-null etag value and file already exists, then this value is compared to the current entity tag of the file, and if they differ an 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 g_file_output_stream_get_etag() after you've finished writing and closed the Gio.FileOutputStream. When you load a new file you can use g_file_input_stream_query_info() to get the etag of the file.

    If make_backup is true, this function will attempt to make a backup of the current file before overwriting it. If this fails a Gio.IOErrorEnum.CANT_CREATE_BACKUP error will be returned. If you want to replace anyway, try again with make_backup set to false.

    If the file is a directory the Gio.IOErrorEnum.IS_DIRECTORY error will be returned, and if the file is some other form of non-regular file then a Gio.IOErrorEnum.NOT_REGULAR_FILE error will be returned. Some file systems don't allow all file names, and may return an Gio.IOErrorEnum.INVALID_FILENAME error, and if the name is to long Gio.IOErrorEnum.FILENAME_TOO_LONG will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.

    Parameters

    Returns Gio.FileOutputStream

  • 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 g_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.

    Parameters

    Returns Gio.FileIOStream

  • 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).

    Parameters

    • relative_path: string

      a given relative path string

    Returns 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 (G_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 g_file_set_display_name().

    On success the resulting converted filename is returned.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns Gio.File

  • 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 g_unix_mount_entry_is_system_internal()), so this call can return the Gio.IOErrorEnum.NOT_SUPPORTED error. Since GLib 2.66, the x-gvfs-notrash unix mount option can be used to disable g_file_trash() support for particular mounts, the 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 g_file_trash() support for particular system mounts.

    If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

    Parameters

    Returns boolean

Interfaces

ConstructorProps
Interface