Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: FileInfo

[39:7] extends: object

Stores information about a file system object referenced by a [iface@Gio.File]. Functionality for manipulating basic metadata for files. GFileInfo implements methods for getting information that all files should contain, and allows for manipulation of extended attributes. See the file attributes document for more information on how GIO handles file attributes. To obtain a GFileInfo for a [iface@Gio.File], use [method@Gio.File.query_info] (or its async variant). To obtain a GFileInfo for a file input or output stream, use [method@Gio.FileInputStream.query_info] or [method@Gio.FileOutputStream.query_info] (or their async variants). To change the actual attributes of a file, you should then set the attribute in the GFileInfo and call [method@Gio.File.set_attributes_from_info] or [method@Gio.File.set_attributes_async] on a GFile. However, not all attributes can be changed in the file. For instance, the actual size of a file cannot be changed via [method@Gio.FileInfo.set_size]. You may call [method@Gio.File.query_settable_attributes] and [method@Gio.File.query_writable_namespaces] to discover the settable attributes of a particular file at runtime. The direct accessors, such as [method@Gio.FileInfo.get_name], are slightly more optimized than the generic attribute accessors, such as [method@Gio.FileInfo.get_attribute_byte_string].This optimization will matter only if calling the API in a tight loop. It is an error to call these accessors without specifying their required file attributes when creating the GFileInfo. Use [method@Gio.FileInfo.has_attribute] or [method@Gio.FileInfo.list_attributes] to check what attributes are specified for a GFileInfo. [struct@Gio.FileAttributeMatcher] allows for searching through a GFileInfo for attributes.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • FileInfo ()

    Creates a new file info structure.

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as Object.

    • @r A Object object.
  • clear_status ()

    Clears the status information from @info.

    • @r None.
  • copy_into (object dest_info)

    First clears all of the GFileAttribute of @dest_info, and then copies all of the file attributes from @src_info to @dest_info.

    • @p dest_info is destination to copy attributes to..
    • @r None.
  • dup ()

    Duplicates a file info structure.

  • get_access_date_time ()

    Gets the access time of the current @info and returns it as a #GDateTime. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_TIME_ACCESS. If %G_FILE_ATTRIBUTE_TIME_ACCESS_USEC is provided, the resulting #GDateTime will additionally have microsecond precision. If nanosecond precision is needed, %G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC must be queried separately using g_file_info_get_attribute_uint32().

  • get_attribute_as_string (string attribute)

    Gets the value of an attribute, formatted as a human readable string. This escapes things as needed to make the string valid UTF-8 and readable by humans. It’s not meant to be a machine readable or reversible escaping format. To format file name attributes of type [enum@Gio.FileAttributeType.BYTE_STRING] for output as UTF-8, use [func@GLib.filename_to_utf8] instead: c const char *trash_orig_path_byte_string; g_autofree char *trash_orig_path_utf8 = NULL; trash_orig_path_byte_string = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_TRASH_ORIG_PATH); trash_orig_path_utf8 = g_filename_to_utf8 (trash_orig_path_byte_string, -1, NULL, NULL, NULL); if (trash_orig_path_utf8 != NULL) g_message ("Some larger UTF-8 string with filename embedded as %s", trash_orig_path_utf8);

    • @p attribute is a file attribute key..
  • get_attribute_boolean (string attribute)

    Gets the value of a boolean attribute. If the attribute does not contain a boolean value, %FALSE will be returned.

    • @p attribute is a file attribute key..
  • get_attribute_byte_string (string attribute)

    Gets the value of a byte string attribute. If the attribute does not contain a byte string, %NULL will be returned.

    • @p attribute is a file attribute key..
  • get_attribute_file_path (string attribute)

    Gets the value of a byte string attribute as a file path. If the attribute does not contain a byte string, NULL will be returned. This function is meant to be used by language bindings that have specific handling for Unix paths.

    • @p attribute is a file attribute key..
  • get_attribute_object (string attribute)

    Gets the value of a #GObject attribute. If the attribute does not contain a #GObject, %NULL will be returned.

    • @p attribute is a file attribute key..
  • get_attribute_status (string attribute)

    Gets the attribute status for an attribute key.

    • @p attribute is a file attribute key.
  • get_attribute_string (string attribute)

    Gets the value of a string attribute. If the attribute does not contain a string, %NULL will be returned.

    • @p attribute is a file attribute key..
  • get_attribute_stringv (string attribute)

    Gets the value of a stringv attribute. If the attribute does not contain a stringv, %NULL will be returned.

    • @p attribute is a file attribute key..
  • get_attribute_type (string attribute)

    Gets the attribute type for an attribute key.

    • @p attribute is a file attribute key..
  • get_content_type ()

    Gets the file's content type. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.

  • get_creation_date_time ()

    Gets the creation time of the current @info and returns it as a #GDateTime. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_TIME_CREATED. If %G_FILE_ATTRIBUTE_TIME_CREATED_USEC is provided, the resulting #GDateTime will additionally have microsecond precision. If nanosecond precision is needed, %G_FILE_ATTRIBUTE_TIME_CREATED_NSEC must be queried separately using g_file_info_get_attribute_uint32().

  • get_deletion_date ()

    Returns the #GDateTime representing the deletion date of the file, as available in %G_FILE_ATTRIBUTE_TRASH_DELETION_DATE. If the %G_FILE_ATTRIBUTE_TRASH_DELETION_DATE attribute is unset, %NULL is returned.

  • get_display_name ()

    Gets a display name for a file. This is guaranteed to always be set. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.

  • get_edit_name ()

    Gets the edit name for a file. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME.

  • get_etag ()

    Gets the [entity tag][iface@Gio.File#entity-tags] for a given #GFileInfo. See %G_FILE_ATTRIBUTE_ETAG_VALUE. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_ETAG_VALUE.

  • get_file_type ()

    Gets a file's type (whether it is a regular file, symlink, etc). This is different from the file's content type, see g_file_info_get_content_type(). It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_TYPE.

  • get_icon ()

    Gets the icon for a file. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_ICON.

  • get_is_backup ()

    Checks if a file is a backup file. The exact semantics of what constitutes a backup file are backend-specific. For local files, a file is considered a backup if its name ends with ~ and it is a regular file. This follows the POSIX convention used by text editors such as Emacs. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP.

  • get_is_hidden ()

    Checks if a file is hidden. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN.

  • get_is_symlink ()

    Checks if a file is a symlink. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.

  • get_modification_date_time ()

    Gets the modification time of the current @info and returns it as a #GDateTime. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_TIME_MODIFIED. If %G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC is provided, the resulting #GDateTime will additionally have microsecond precision. If nanosecond precision is needed, %G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC must be queried separately using g_file_info_get_attribute_uint32().

  • get_name ()

    Gets the name for a file. This is guaranteed to always be set. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_NAME.

  • get_symbolic_icon ()

    Gets the symbolic icon for a file. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON.

  • get_symlink_target ()

    Gets the symlink target for a given #GFileInfo. It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET.

  • has_attribute (string attribute)

    Checks if a file info structure has an attribute named @attribute.

    • @p attribute is a file attribute key..
  • has_namespace (string name_space)

    Checks if a file info structure has an attribute in the specified

    • @name_space. ``
    • @p name_space is a file attribute namespace..
  • list_attributes (string name_space)

    Lists the file info structure's attributes.

    • @p name_space is a file attribute key's namespace, or %NULL to list all attributes..
  • remove_attribute (string attribute)

    Removes all cases of @attribute from @info if it exists.

    • @p attribute is a file attribute key..
    • @r None.
  • set_access_date_time (object atime)

    Sets the %G_FILE_ATTRIBUTE_TIME_ACCESS and %G_FILE_ATTRIBUTE_TIME_ACCESS_USEC attributes in the file info to the given date/time value. %G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC will be cleared.

    • @p atime is a #GDateTime..
    • @r None.
  • set_attribute (string attribute, string type, value_p)

    Sets the @attribute to contain the given value, if possible. To unset the attribute, use %G_FILE_ATTRIBUTE_TYPE_INVALID for @type.

    • @p attribute is a file attribute key..
    • @p type is a #GFileAttributeType.
    • @p value_p is pointer to the value.
    • @r None.
  • set_attribute_boolean (string attribute, bool attr_value)

    Sets the @attribute to contain the given @attr_value, if possible.

    • @p attribute is a file attribute key..
    • @p attr_value is a boolean value..
    • @r None.
  • set_attribute_byte_string (string attribute, string attr_value)

    Sets the @attribute to contain the given @attr_value, if possible.

    • @p attribute is a file attribute key..
    • @p attr_value is a byte string..
    • @r None.
  • set_attribute_file_path (string attribute, string attr_value)

    Sets the @attribute to contain the given @attr_value, if possible. This function is meant to be used by language bindings that have specific handling for Unix paths.

    • @p attribute is a file attribute key..
    • @p attr_value is a file path..
    • @r None.
  • set_attribute_mask (object mask)

    Sets @mask on @info to match specific attribute types.

    • @p mask is a #GFileAttributeMatcher..
    • @r None.
  • set_attribute_object (string attribute, object attr_value)

    Sets the @attribute to contain the given @attr_value, if possible.

    • @p attribute is a file attribute key..
    • @p attr_value is a #GObject..
    • @r None.
  • set_attribute_status (string attribute, string status)

    Sets the attribute status for an attribute key. This is only needed by external code that implement g_file_set_attributes_from_info() or similar functions. The attribute must exist in @info for this to work. Otherwise %FALSE is returned and @info is unchanged.

    • @p attribute is a file attribute key.
    • @p status is a #GFileAttributeStatus.
  • set_attribute_string (string attribute, string attr_value)

    Sets the @attribute to contain the given @attr_value, if possible.

    • @p attribute is a file attribute key..
    • @p attr_value is a UTF-8 string..
    • @r None.
  • set_attribute_stringv (string attribute, list attr_value)

    Sets the @attribute to contain the given @attr_value, if possible. Sinze: 2.22

    • @p attribute is a file attribute key.
    • @p attr_value is a %NULL terminated array of UTF-8 strings..
    • @r None.
  • set_content_type (string content_type)

    Sets the content type attribute for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.

  • set_creation_date_time (object creation_time)

    Sets the %G_FILE_ATTRIBUTE_TIME_CREATED and %G_FILE_ATTRIBUTE_TIME_CREATED_USEC attributes in the file info to the given date/time value. %G_FILE_ATTRIBUTE_TIME_CREATED_NSEC will be cleared.

    • @p creation_time is a #GDateTime..
    • @r None.
  • set_display_name (string display_name)

    Sets the display name for the current #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.

    • @p display_name is a string containing a display name..
    • @r None.
  • set_edit_name (string edit_name)

    Sets the edit name for the current file. See %G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME.

    • @p edit_name is a string containing an edit name..
    • @r None.
  • set_file_type (string type)

    Sets the file type in a #GFileInfo to @type. See %G_FILE_ATTRIBUTE_STANDARD_TYPE.

    • @p type is a #GFileType..
    • @r None.
  • set_icon (object icon)

    Sets the icon for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_ICON.

    • @p icon is a #GIcon..
    • @r None.
  • set_is_hidden (bool is_hidden)

    Sets the "is_hidden" attribute in a #GFileInfo according to @is_hidden. See %G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN.

    • @p is_hidden is a #gboolean..
    • @r None.
  • set_is_symlink (bool is_symlink)

    Sets the "is_symlink" attribute in a #GFileInfo according to @is_symlink. See %G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.

    • @p is_symlink is a #gboolean..
    • @r None.
  • set_modification_date_time (object mtime)

    Sets the %G_FILE_ATTRIBUTE_TIME_MODIFIED and %G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC attributes in the file info to the given date/time value. %G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC will be cleared.

    • @p mtime is a #GDateTime..
    • @r None.
  • set_modification_time (mtime)

    Sets the %G_FILE_ATTRIBUTE_TIME_MODIFIED and %G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC attributes in the file info to the given time value. %G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC will be cleared.

    • @p mtime is a #GTimeVal..
    • @r None.
  • set_name (string name)

    Sets the name attribute for the current #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_NAME.

    • @p name is a string containing a name..
    • @r None.
  • set_symbolic_icon (object icon)

    Sets the symbolic icon for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON.

    • @p icon is a #GIcon..
    • @r None.
  • set_symlink_target (string symlink_target)

    Sets the %G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in the file info to the given symlink target.

    • @p symlink_target is a static string containing a path to a symlink target..
    • @r None.
  • unset_attribute_mask ()

    Unsets a mask set by g_file_info_set_attribute_mask(), if one is set.

    • @r None.