Interface

Gio-2.0GioFileNamespace

interface FileNamespace {
    $gtype: GType<Gio.File>;
    prototype: Gio.File;
    new_build_filenamev(args: string[]): Gio.File;
    new_for_commandline_arg(arg: string): Gio.File;
    new_for_commandline_arg_and_cwd(arg: string, cwd: string): Gio.File;
    new_for_path(path: string): Gio.File;
    new_for_uri(uri: string): Gio.File;
    new_tmp(tmpl: string): [Gio.File, Gio.FileIOStream];
    new_tmp_async(
        tmpl: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    new_tmp_dir_async(
        tmpl: string,
        io_priority: number,
        cancellable?: Gio.Cancellable,
        callback?: AsyncReadyCallback<Gio.File>,
    ): void;
    new_tmp_dir_finish(result: Gio.AsyncResult): Gio.File;
    new_tmp_finish(result: Gio.AsyncResult): [Gio.File, Gio.FileIOStream];
    parse_name(parse_name: string): Gio.File;
}
Index

Properties

$gtype: GType<Gio.File>
prototype: Gio.File

Methods

  • Constructs a Gio.File from a vector of elements using the correct separator for filenames.

    Using this function is equivalent to calling g_build_filenamev(), followed by g_file_new_for_path() on the result.

    Parameters

    • args: string[]

      null-terminated array of strings containing the path elements.

    Returns Gio.File

  • Creates a Gio.File with the given argument from the command line. The value of arg can be either a URI, an absolute path or a relative path resolved relative to the current working directory. This operation never fails, but the returned object might not support any I/O operation if arg points to a malformed path.

    Note that on Windows, this function expects its argument to be in UTF-8 -- not the system code page. This means that you should not use this function with string from argv as it is passed to main(). g_win32_get_command_line() will return a UTF-8 version of the commandline. Gio.Application also uses UTF-8 but g_application_command_line_create_file_for_arg() may be more useful for you there. It is also always possible to use this function with GLib.OptionContext arguments of type GLib.OptionArg.FILENAME.

    Parameters

    • arg: string

      a command line string

    Returns Gio.File

  • Creates a Gio.File with the given argument from the command line.

    This function is similar to g_file_new_for_commandline_arg() except that it allows for passing the current working directory as an argument instead of using the current working directory of the process.

    This is useful if the commandline argument was given in a context other than the invocation of the current process.

    See also g_application_command_line_create_file_for_arg().

    Parameters

    • arg: string

      a command line string

    • cwd: string

      the current working directory of the commandline

    Returns Gio.File

  • Constructs a Gio.File for a given path. This operation never fails, but the returned object might not support any I/O operation if path is malformed.

    Parameters

    • path: string

      a string containing a relative or absolute path. The string must be encoded in the glib filename encoding.

    Returns Gio.File

  • Constructs a Gio.File for a given URI. This operation never fails, but the returned object might not support any I/O operation if uri is malformed or if the uri type is not supported.

    Parameters

    • uri: string

      a UTF-8 string containing a URI

    Returns Gio.File

  • Opens a file in the preferred directory for temporary files (as returned by g_get_tmp_dir()) and returns a Gio.File and Gio.FileIOStream pointing to it.

    tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is null, a default template is used.

    Unlike the other Gio.File constructors, this will return null if a temporary file could not be created.

    Parameters

    • tmpl: string

      Template for the file name, as in g_file_open_tmp(), or null for a default template

    Returns [Gio.File, Gio.FileIOStream]

  • Asynchronously opens a file in the preferred directory for temporary files (as returned by g_get_tmp_dir()) as g_file_new_tmp().

    tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is null, a default template is used.

    Parameters

    Returns void

  • Asynchronously creates a directory in the preferred directory for temporary files (as returned by g_get_tmp_dir()) as g_dir_make_tmp().

    tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is null, a default template is used.

    Parameters

    Returns void

  • Constructs a Gio.File with the given parse_name (i.e. something given by g_file_get_parse_name()). This operation never fails, but the returned object might not support any I/O operation if the parse_name cannot be parsed.

    Parameters

    • parse_name: string

      a file name or path to be parsed

    Returns Gio.File