It derives from <GObject>.
Stores information about a file system object referenced by a
<GFile>.
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
<GFile>, use file:query-info (or its async variant). To obtain a
<GFileInfo> for a file input or output stream,
use file-input-stream:query-info or
file-output-stream: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
file:set-attributes-from-info? or
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 file-info:set-size. You may call file:query-settable-attributes and
file:query-writable-namespaces to discover
the settable attributes of a particular file at runtime.
The direct accessors, such as file-info:get-name, are slightly more optimized than the
generic attribute accessors, such as file-info: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 file-info:has-attribute? or
file-info:list-attributes to
check what attributes are specified for a
<GFileInfo>.
<GFileAttributeMatcher> allows for
searching through a <GFileInfo> for attributes.
Clears the status information from self.
Passed: a <GFileInfo>.
a <GFileInfo>.
First clears all of the GFileAttribute of dest-info, and then copies all of the file attributes from self to dest-info.
Passed: a <GFileInfo>.
source to copy attributes from.
Passed: a <GFileInfo>.
destination to copy attributes to.
Duplicates a file info structure.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a <GFileInfo>.
a duplicate <GFileInfo> of self.
Gets the access time of the current self 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 file-info:get-attribute-uint32.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a <GDateTime>, or #f.
access time, or #f if unknown
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
Gio.FileAttributeType.BYTE_STRING for output as UTF-8, use
filename-to-utf8 instead:
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);
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a string, or #f.
a UTF-8 string associated with the given attribute, or #f
if the attribute wasn’t set. When you’re done with the string it must
be freed with byte-array:free.
Gets the value of a boolean attribute. If the attribute does not
contain a boolean value, #f will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a boolean.
the boolean value contained within the attribute.
Gets the value of a byte string attribute. If the attribute does not
contain a byte string, #f will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a string, or #f.
the contents of the attribute value as a byte string, or #f
otherwise.
Gets the attribute type, value and status for an attribute key.
Passed: a <GFileInfo>.
Passed: a string.
a file attribute key
Returned: a boolean.
#t if self has an attribute named attribute,
#f otherwise.
Returned: a <GFileAttributeType>.
return location for the attribute type, or #f
Returned: a foreign pointer.
return location for the attribute value, or #f; the attribute
value will not be #f
Returned: a <GFileAttributeStatus>.
return location for the attribute status, or #f
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a file name, as a string, or #f.
the contents of the attribute value as a file path, or #f
otherwise.
Gets a signed 32-bit integer contained within the attribute. If the attribute does not contain a signed 32-bit integer, or is invalid, 0 will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a 32-bit integer.
a signed 32-bit integer from the attribute.
Gets a signed 64-bit integer contained within the attribute. If the attribute does not contain a signed 64-bit integer, or is invalid, 0 will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a 64-bit integer.
a signed 64-bit integer from the attribute.
Gets the value of a <GObject> attribute. If
the attribute does not contain a <GObject>,
#f will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a <GObject>, or #f.
a <GObject> associated with the given
attribute, or #f otherwise.
Gets the attribute status for an attribute key.
Passed: a <GFileInfo>.
Passed: a string.
a file attribute key
Returned: a <GFileAttributeStatus>.
a <GFileAttributeStatus> for the given
attribute, or unset if the key
is invalid.
Gets the value of a string attribute. If the attribute does not contain
a string, #f will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a string, or #f.
the contents of the attribute value as a UTF-8 string, or
#f otherwise.
Gets the value of a stringv attribute. If the attribute does not
contain a stringv, #f will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a vector, each a string, or #f.
the contents of the attribute value as a stringv, or #f
otherwise. Do not free. These returned strings are UTF-8.
Gets the attribute type for an attribute key.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a <GFileAttributeType>.
a <GFileAttributeType> for the given
attribute, or invalid if the key
is not set.
Gets an unsigned 32-bit integer contained within the attribute. If the attribute does not contain an unsigned 32-bit integer, or is invalid, 0 will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: an unsigned 32-bit integer.
an unsigned 32-bit integer from the attribute.
Gets a unsigned 64-bit integer contained within the attribute. If the attribute does not contain an unsigned 64-bit integer, or is invalid, 0 will be returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: an unsigned 64-bit integer.
a unsigned 64-bit integer from the attribute.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a string, or #f.
a string containing the file’s content type, or #f if unknown.
Gets the creation time of the current self 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 file-info:get-attribute-uint32.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a <GDateTime>, or #f.
creation time, or #f if unknown
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,
#f is returned.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a <GDateTime>, or #f.
a <GDateTime>, or #f.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a string.
a string containing the display 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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a string.
a string containing the edit name.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a string, or #f.
a string containing the value of the "etag:value" attribute.
Gets a file’s type (whether it is a regular file, symlink, etc). This
is different from the file’s content type, see file-info:get-content-type.
It is an error to call this if the <GFileInfo>
does not contain G_FILE_ATTRIBUTE_STANDARD_TYPE.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a <GFileType>.
a <GFileType> for the given file.
Gets the icon for a file.
It is an error to call this if the <GFileInfo>
does not contain G_FILE_ATTRIBUTE_STANDARD_ICON.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a <GIcon>, or #f.
<GIcon> for the given self.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a boolean.
#t if file is a backup file, #f otherwise.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a boolean.
#t if the file is a hidden file, #f otherwise.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a boolean.
#t if the given self is a symlink.
Gets the modification time of the current self 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 file-info:get-attribute-uint32.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a <GDateTime>, or #f.
modification time, or #f if unknown
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a file name, as a string.
a string containing the file name.
Gets the file’s size (in bytes). The size is retrieved through the
value of the G_FILE_ATTRIBUTE_STANDARD_SIZE attribute and is
converted from guint64 to goffset before returning the
result.
It is an error to call this if the <GFileInfo>
does not contain G_FILE_ATTRIBUTE_STANDARD_SIZE.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a 64-bit integer.
a goffset containing the file’s size (in bytes).
Gets the value of the sort_order attribute from the
<GFileInfo>. See
G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
It is an error to call this if the <GFileInfo>
does not contain G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a 32-bit integer.
a gint32 containing the value of the "standard::sort_order"
attribute.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a <GIcon>, or #f.
<GIcon> for the given self.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Returned: a file name, as a string, or #f.
a string containing the symlink target.
Checks if a file info structure has an attribute named attribute.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Returned: a boolean.
#t if self has an attribute named attribute,
#f otherwise.
Checks if a file info structure has an attribute in the specified name-space.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute namespace.
Returned: a boolean.
#t if self has an attribute in name-space, #f
otherwise.
Lists the file info structure’s attributes.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed, or left out: a string, or #f.
a file attribute key’s namespace, or #f to list all attributes.
Returned: a vector, each a string, or #f.
a null-terminated array of strings of all of the possible attribute
types for the given name-space, or #f on error.
Creates a new file info structure.
Returned: a <GFileInfo>.
a <GFileInfo>.
Removes all cases of attribute from self if it exists.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a <GDateTime>.
a <GDateTime>.
Sets the attribute to contain the given value, if possible. To
unset the attribute, use invalid for
type.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: a <GFileAttributeType>, or one
of its symbols.
Passed: a foreign pointer, or a bytevector.
pointer to the value
Sets the attribute to contain the given attr-value, if possible.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: a boolean.
a boolean value.
Sets the attribute to contain the given attr-value, if possible.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: a string.
a byte string.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: a file name, as a string.
a file path.
Sets the attribute to contain the given attr-value, if possible.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: a 32-bit integer.
a signed 32-bit integer
Sets the attribute to contain the given attr-value, if possible.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
attribute name to set.
Passed: a 64-bit integer.
int64 value to set attribute to.
Sets mask on self to match specific attribute types.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a <GFileAttributeMatcher>.
Sets the attribute to contain the given attr-value, if possible.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: a <GObject>.
a <GObject>.
Sets the attribute status for an attribute key. This is only needed by
external code that implement file:set-attributes-from-info? or similar
functions.
The attribute must exist in self for this to work. Otherwise
#f is returned and self is unchanged.
Passed: a <GFileInfo>.
Passed: a string.
a file attribute key
Passed: a <GFileAttributeStatus>, or
one of its symbols.
Returned: a boolean.
#t if the status was changed, #f if the key was not set.
Sets the attribute to contain the given attr-value, if possible.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: a string.
a UTF-8 string.
Sets the attribute to contain the given attr-value, if possible.
Sinze: 2.22
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key
Passed: a list or vector, each a string.
a #f terminated array of UTF-8 strings.
Sets the attribute to contain the given attr-value, if possible.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: an unsigned 32-bit integer.
an unsigned 32-bit integer.
Sets the attribute to contain the given attr-value, if possible.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a file attribute key.
Passed: an unsigned 64-bit integer.
an unsigned 64-bit integer.
Sets the content type attribute for a given
<GFileInfo>. See
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a content type.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a <GDateTime>.
a <GDateTime>.
Sets the display name for the current
<GFileInfo>. See
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a string containing a display name.
Sets the edit name for the current file. See
G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a string.
a string containing an edit name.
Sets the file type in a <GFileInfo> to
type. See G_FILE_ATTRIBUTE_STANDARD_TYPE.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a <GFileType>, or one of its symbols.
a <GFileType>.
Sets the icon for a given <GFileInfo>. See
G_FILE_ATTRIBUTE_STANDARD_ICON.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a <GIcon>.
a <GIcon>.
Sets the "is_hidden" attribute in a <GFileInfo>
according to is-hidden. See
G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a boolean.
a gboolean.
Sets the "is_symlink" attribute in a <GFileInfo>
according to is-symlink. See
G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a boolean.
a gboolean.
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.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a <GDateTime>.
a <GDateTime>.
Sets the name attribute for the current
<GFileInfo>. See
G_FILE_ATTRIBUTE_STANDARD_NAME.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a file name, as a string.
a string containing a name.
Sets the G_FILE_ATTRIBUTE_STANDARD_SIZE attribute in the file
info to the given size.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a 64-bit integer.
a goffset containing the file’s size.
Sets the sort order attribute in the file info structure. See
G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a 32-bit integer.
a sort order integer.
Sets the symbolic icon for a given <GFileInfo>.
See G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a <GIcon>.
a <GIcon>.
Sets the G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in
the file info to the given symlink target.
Passed: a <GFileInfo>.
a <GFileInfo>.
Passed: a file name, as a string.
a static string containing a path to a symlink target.
Unsets a mask set by file-info:set-attribute-mask, if one is set.
Passed: a <GFileInfo>.