Class
GioFileInfo
Description
final class Gio.FileInfo : GObject.Object
{
/* No available fields */
}
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 [GFileAttribute][gio-GFileAttribute] for more information on how GIO handles file attributes.
To obtain a GFileInfo
for a GFile
, use g_file_query_info()
(or its
async variant). To obtain a GFileInfo
for a file input or output
stream, use g_file_input_stream_query_info()
or
g_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 g_file_set_attributes_from_info()
or g_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 g_file_info_set_size().
You may call g_file_query_settable_attributes()
and
g_file_query_writable_namespaces()
to discover the settable attributes
of a particular file at runtime.
The direct accessors, such as g_file_info_get_name(), are slightly more optimized than the generic attribute accessors, such as g_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 g_file_info_has_attribute()
or
g_file_info_list_attributes()
to check what attributes are specified for a
GFileInfo
.
GFileAttributeMatcher
allows for searching through a GFileInfo
for attributes.
Instance methods
g_file_info_copy_into
First clears all of the [GFileAttribute][gio-GFileAttribute] of dest_info
,
and then copies all of the file attributes from src_info
to dest_info
.
g_file_info_get_access_date_time
Gets the access time of the current info
and returns it as a
GDateTime
.
since: 2.70
g_file_info_get_attribute_as_string
Gets the value of an attribute, formatted as a string. This escapes things as needed to make the string valid UTF-8.
g_file_info_get_attribute_boolean
Gets the value of a boolean attribute. If the attribute does not
contain a boolean value, FALSE
will be returned.
g_file_info_get_attribute_byte_string
Gets the value of a byte string attribute. If the attribute does
not contain a byte string, NULL
will be returned.
g_file_info_get_attribute_int32
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.
g_file_info_get_attribute_int64
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.
g_file_info_get_attribute_object
Gets the value of a GObject
attribute. If the attribute does
not contain a GObject
, NULL
will be returned.
g_file_info_get_attribute_string
Gets the value of a string attribute. If the attribute does
not contain a string, NULL
will be returned.
g_file_info_get_attribute_stringv
Gets the value of a stringv attribute. If the attribute does
not contain a stringv, NULL
will be returned.
since: 2.22
g_file_info_get_attribute_uint32
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.
g_file_info_get_attribute_uint64
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.
g_file_info_get_creation_date_time
Gets the creation time of the current info
and returns it as a
GDateTime
.
since: 2.70
g_file_info_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.
since: 2.36
g_file_info_get_etag
Gets the [entity tag][gfile-etag] for a given
GFileInfo
. See G_FILE_ATTRIBUTE_ETAG_VALUE
.
g_file_info_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().
g_file_info_get_modification_date_time
Gets the modification time of the current info
and returns it as a
GDateTime
.
since: 2.62
g_file_info_get_modification_time
Gets the modification time of the current info
and sets it
in result
.
deprecated: 2.62
g_file_info_get_size
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.
g_file_info_get_sort_order
Gets the value of the sort_order attribute from the GFileInfo
.
See G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER
.
g_file_info_has_namespace
Checks if a file info structure has an attribute in the
specified name_space
.
since: 2.22
g_file_info_set_access_date_time
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.
since: 2.70
g_file_info_set_attribute
Sets the attribute
to contain the given value, if possible. To unset the
attribute, use G_FILE_ATTRIBUTE_TYPE_INVALID
for type
.
g_file_info_set_attribute_byte_string
Sets the attribute
to contain the given attr_value
,
if possible.
g_file_info_set_attribute_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.
since: 2.22
g_file_info_set_content_type
Sets the content type attribute for a given GFileInfo
.
See G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE
.
g_file_info_set_creation_date_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.
since: 2.70
g_file_info_set_display_name
Sets the display name for the current GFileInfo
.
See G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
.
g_file_info_set_edit_name
Sets the edit name for the current file.
See G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME
.
g_file_info_set_file_type
Sets the file type in a GFileInfo
to type
.
See G_FILE_ATTRIBUTE_STANDARD_TYPE
.
g_file_info_set_is_hidden
Sets the “is_hidden” attribute in a GFileInfo
according to is_hidden
.
See G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN
.
g_file_info_set_is_symlink
Sets the “is_symlink” attribute in a GFileInfo
according to is_symlink
.
See G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK
.
g_file_info_set_modification_date_time
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.
since: 2.62
g_file_info_set_modification_time
Sets the G_FILE_ATTRIBUTE_TIME_MODIFIED
and
G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC
attributes in the file info to the
given time value.
deprecated: 2.62
g_file_info_set_name
Sets the name attribute for the current GFileInfo
.
See G_FILE_ATTRIBUTE_STANDARD_NAME
.
g_file_info_set_size
Sets the G_FILE_ATTRIBUTE_STANDARD_SIZE
attribute in the file info
to the given size.
g_file_info_set_sort_order
Sets the sort order attribute in the file info structure. See
G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER
.
g_file_info_set_symbolic_icon
Sets the symbolic icon for a given GFileInfo
.
See G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON
.
since: 2.34
g_file_info_set_symlink_target
Sets the G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET
attribute in the file info
to the given symlink target.
g_file_info_unset_attribute_mask
Unsets a mask set by g_file_info_set_attribute_mask(), if one is set.
Signals
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.