Gio.FileInfo¶
| Subclasses: | None |
|---|
Methods¶
| Inherited: | GObject.Object (37) |
|---|---|
| Structs: | GObject.ObjectClass (5) |
Virtual Methods¶
| Inherited: | GObject.Object (7) |
|---|
Properties¶
None
Signals¶
| Inherited: | GObject.Object (1) |
|---|
Fields¶
| Inherited: | GObject.Object (1) |
|---|
Class Details¶
-
class
Gio.FileInfo(**kwargs)¶ Bases: GObject.ObjectAbstract: No Structure: Gio.FileInfoClassFunctionality for manipulating basic metadata for files.
Gio.FileInfoimplements methods for getting information that all files should contain, and allows for manipulation of extended attributes.See GFileAttribute for more information on how GIO handles file attributes.
To obtain a
Gio.FileInfofor aGio.File, useGio.File.query_info() (or its async variant). To obtain aGio.FileInfofor a file input or output stream, useGio.FileInputStream.query_info() orGio.FileOutputStream.query_info() (or their async variants).To change the actual attributes of a file, you should then set the attribute in the
Gio.FileInfoand callGio.File.set_attributes_from_info() orGio.File.set_attributes_async() on aGio.File.However, not all attributes can be changed in the file. For instance, the actual size of a file cannot be changed via
Gio.FileInfo.set_size(). You may callGio.File.query_settable_attributes() andGio.File.query_writable_namespaces() to discover the settable attributes of a particular file at runtime.Gio.FileAttributeMatcherallows for searching through aGio.FileInfofor attributes.-
classmethod
new()[source]¶ Returns: a Gio.FileInfo.Return type: Gio.FileInfoCreates a new file info structure.
-
copy_into(dest_info)[source]¶ Parameters: dest_info ( Gio.FileInfo) – destination to copy attributes to.First clears all of the GFileAttribute of dest_info, and then copies all of the file attributes from self to dest_info.
-
dup()[source]¶ Returns: a duplicate Gio.FileInfoof self.Return type: Gio.FileInfoDuplicates a file info structure.
-
get_attribute_as_string(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: a UTF-8 string associated with the given attribute, or Noneif the attribute wasn’t set. When you’re done with the string it must be freed withGLib.free().Return type: strorNoneGets the value of a attribute, formatted as a string. This escapes things as needed to make the string valid UTF-8.
-
get_attribute_boolean(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: the boolean value contained within the attribute. Return type: boolGets the value of a boolean attribute. If the attribute does not contain a boolean value,
Falsewill be returned.
-
get_attribute_byte_string(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: the contents of the attribute value as a byte string, or Noneotherwise.Return type: strorNoneGets the value of a byte string attribute. If the attribute does not contain a byte string,
Nonewill be returned.
-
get_attribute_data(attribute)[source]¶ Parameters: attribute ( str) – a file attribute keyReturns: Trueif self has an attribute named attribute,Falseotherwise.type: return location for the attribute type, or Nonevalue_pp: return location for the attribute value, or None; the attribute value will not beNonestatus: return location for the attribute status, or NoneReturn type: ( bool, type:Gio.FileAttributeType, value_pp:object, status:Gio.FileAttributeStatus)Gets the attribute type, value and status for an attribute key.
-
get_attribute_int32(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: a signed 32-bit integer from the attribute. Return type: intGets 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.
-
get_attribute_int64(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: a signed 64-bit integer from the attribute. Return type: intGets 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.
-
get_attribute_object(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: a GObject.Objectassociated with the given attribute, orNoneotherwise.Return type: GObject.ObjectorNoneGets the value of a
GObject.Objectattribute. If the attribute does not contain aGObject.Object,Nonewill be returned.
-
get_attribute_status(attribute)[source]¶ Parameters: attribute ( str) – a file attribute keyReturns: a Gio.FileAttributeStatusfor the given attribute, orGio.FileAttributeStatus.UNSETif the key is invalid.Return type: Gio.FileAttributeStatusGets the attribute status for an attribute key.
-
get_attribute_string(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: the contents of the attribute value as a UTF-8 string, or Noneotherwise.Return type: strorNoneGets the value of a string attribute. If the attribute does not contain a string,
Nonewill be returned.
-
get_attribute_stringv(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: the contents of the attribute value as a stringv, or Noneotherwise. Do not free. These returned strings are UTF-8.Return type: [ str] orNoneGets the value of a stringv attribute. If the attribute does not contain a stringv,
Nonewill be returned.New in version 2.22.
-
get_attribute_type(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: a Gio.FileAttributeTypefor the given attribute, orGio.FileAttributeType.INVALIDif the key is not set.Return type: Gio.FileAttributeTypeGets the attribute type for an attribute key.
-
get_attribute_uint32(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: an unsigned 32-bit integer from the attribute. Return type: intGets 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.
-
get_attribute_uint64(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: a unsigned 64-bit integer from the attribute. Return type: intGets 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.
-
get_content_type()[source]¶ Returns: a string containing the file’s content type, or Noneif unknown.Return type: strorNoneGets the file’s content type.
-
get_deletion_date()[source]¶ Returns: a GLib.DateTime, orNone.Return type: GLib.DateTimeorNoneReturns the
GLib.DateTimerepresenting the deletion date of the file, as available inGio.FILE_ATTRIBUTE_TRASH_DELETION_DATE. If theGio.FILE_ATTRIBUTE_TRASH_DELETION_DATEattribute is unset,Noneis returned.New in version 2.36.
-
get_display_name()[source]¶ Returns: a string containing the display name. Return type: strGets a display name for a file. This is guaranteed to always be set.
-
get_edit_name()[source]¶ Returns: a string containing the edit name. Return type: strGets the edit name for a file.
-
get_etag()[source]¶ Returns: a string containing the value of the “etag:value” attribute. Return type: strGets the entity tag for a given
Gio.FileInfo. SeeGio.FILE_ATTRIBUTE_ETAG_VALUE.
-
get_file_type()[source]¶ Returns: a Gio.FileTypefor the given file.Return type: Gio.FileTypeGets a file’s type (whether it is a regular file, symlink, etc). This is different from the file’s content type, see
Gio.FileInfo.get_content_type().
-
get_icon()[source]¶ Returns: Gio.Iconfor the given self.Return type: Gio.IconGets the icon for a file.
-
get_is_backup()[source]¶ Returns: Trueif file is a backup file,Falseotherwise.Return type: boolChecks if a file is a backup file.
Returns: Trueif the file is a hidden file,Falseotherwise.Return type: boolChecks if a file is hidden.
-
get_is_symlink()[source]¶ Returns: Trueif the given self is a symlink.Return type: boolChecks if a file is a symlink.
-
get_modification_date_time()[source]¶ Returns: modification time, or Noneif unknownReturn type: GLib.DateTimeorNoneGets the modification time of the current self and returns it as a
GLib.DateTime.This requires the
Gio.FILE_ATTRIBUTE_TIME_MODIFIEDattribute. IfGio.FILE_ATTRIBUTE_TIME_MODIFIED_USECis provided, the resultingGLib.DateTimewill have microsecond precision.New in version 2.62.
-
get_modification_time()[source]¶ Returns: a GLib.TimeVal.Return type: result: GLib.TimeValGets the modification time of the current self and sets it in result.
Deprecated since version 2.62: Use
Gio.FileInfo.get_modification_date_time() instead, asGLib.TimeValis deprecated due to the year 2038 problem.
-
get_name()[source]¶ Returns: a string containing the file name. Return type: strGets the name for a file. This is guaranteed to always be set.
-
get_size()[source]¶ Returns: a #goffset containing the file’s size. Return type: intGets the file’s size.
-
get_sort_order()[source]¶ Returns: a #gint32 containing the value of the “standard::sort_order” attribute. Return type: intGets the value of the sort_order attribute from the
Gio.FileInfo. SeeGio.FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
-
get_symbolic_icon()[source]¶ Returns: Gio.Iconfor the given self.Return type: Gio.IconGets the symbolic icon for a file.
New in version 2.34.
-
get_symlink_target()[source]¶ Returns: a string containing the symlink target. Return type: strGets the symlink target for a given
Gio.FileInfo.
-
has_attribute(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Returns: Trueif self has an attribute named attribute,Falseotherwise.Return type: boolChecks if a file info structure has an attribute named attribute.
-
has_namespace(name_space)[source]¶ Parameters: name_space ( str) – a file attribute namespace.Returns: Trueif self has an attribute in name_space,Falseotherwise.Return type: boolChecks if a file info structure has an attribute in the specified name_space.
New in version 2.22.
-
list_attributes(name_space)[source]¶ Parameters: name_space ( strorNone) – a file attribute key’s namespace, orNoneto list all attributes.Returns: a null-terminated array of strings of all of the possible attribute types for the given name_space, or Noneon error.Return type: [ str] orNoneLists the file info structure’s attributes.
-
remove_attribute(attribute)[source]¶ Parameters: attribute ( str) – a file attribute key.Removes all cases of attribute from self if it exists.
-
set_attribute(attribute, type, value_p)[source]¶ Parameters: - attribute (
str) – a file attribute key. - type (
Gio.FileAttributeType) – aGio.FileAttributeType - value_p (
object) – pointer to the value
Sets the attribute to contain the given value, if possible. To unset the attribute, use
Gio.FileAttributeType.INVALIDfor type.- attribute (
-
set_attribute_boolean(attribute, attr_value)[source]¶ Parameters: Sets the attribute to contain the given attr_value, if possible.
-
set_attribute_byte_string(attribute, attr_value)[source]¶ Parameters: Sets the attribute to contain the given attr_value, if possible.
-
set_attribute_int32(attribute, attr_value)[source]¶ Parameters: Sets the attribute to contain the given attr_value, if possible.
-
set_attribute_int64(attribute, attr_value)[source]¶ Parameters: Sets the attribute to contain the given attr_value, if possible.
-
set_attribute_mask(mask)[source]¶ Parameters: mask ( Gio.FileAttributeMatcher) – aGio.FileAttributeMatcher.Sets mask on self to match specific attribute types.
-
set_attribute_object(attribute, attr_value)[source]¶ Parameters: - attribute (
str) – a file attribute key. - attr_value (
GObject.Object) – aGObject.Object.
Sets the attribute to contain the given attr_value, if possible.
- attribute (
-
set_attribute_status(attribute, status)[source]¶ Parameters: - attribute (
str) – a file attribute key - status (
Gio.FileAttributeStatus) – aGio.FileAttributeStatus
Returns: Trueif the status was changed,Falseif the key was not set.Return type: Sets the attribute status for an attribute key. This is only needed by external code that implement
Gio.File.set_attributes_from_info() or similar functions.The attribute must exist in self for this to work. Otherwise
Falseis returned and self is unchanged.New in version 2.22.
- attribute (
-
set_attribute_string(attribute, attr_value)[source]¶ Parameters: Sets the attribute to contain the given attr_value, if possible.
-
set_attribute_stringv(attribute, attr_value)[source]¶ Parameters: Sets the attribute to contain the given attr_value, if possible.
Sinze: 2.22
-
set_attribute_uint32(attribute, attr_value)[source]¶ Parameters: Sets the attribute to contain the given attr_value, if possible.
-
set_attribute_uint64(attribute, attr_value)[source]¶ Parameters: Sets the attribute to contain the given attr_value, if possible.
-
set_content_type(content_type)[source]¶ Parameters: content_type ( str) – a content type. See GContentTypeSets the content type attribute for a given
Gio.FileInfo. SeeGio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.
-
set_display_name(display_name)[source]¶ Parameters: display_name ( str) – a string containing a display name.Sets the display name for the current
Gio.FileInfo. SeeGio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.
-
set_edit_name(edit_name)[source]¶ Parameters: edit_name ( str) – a string containing an edit name.Sets the edit name for the current file. See
Gio.FILE_ATTRIBUTE_STANDARD_EDIT_NAME.
-
set_file_type(type)[source]¶ Parameters: type ( Gio.FileType) – aGio.FileType.Sets the file type in a
Gio.FileInfoto type. SeeGio.FILE_ATTRIBUTE_STANDARD_TYPE.
-
set_icon(icon)[source]¶ Parameters: icon ( Gio.Icon) – aGio.Icon.Sets the icon for a given
Gio.FileInfo. SeeGio.FILE_ATTRIBUTE_STANDARD_ICON.
Parameters: is_hidden ( bool) – abool.Sets the “is_hidden” attribute in a
Gio.FileInfoaccording to is_hidden. SeeGio.FILE_ATTRIBUTE_STANDARD_IS_HIDDEN.
-
set_is_symlink(is_symlink)[source]¶ Parameters: is_symlink ( bool) – abool.Sets the “is_symlink” attribute in a
Gio.FileInfoaccording to is_symlink. SeeGio.FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.
-
set_modification_date_time(mtime)[source]¶ Parameters: mtime ( GLib.DateTime) – aGLib.DateTime.Sets the
Gio.FILE_ATTRIBUTE_TIME_MODIFIEDandGio.FILE_ATTRIBUTE_TIME_MODIFIED_USECattributes in the file info to the given date/time value.New in version 2.62.
-
set_modification_time(mtime)[source]¶ Parameters: mtime ( GLib.TimeVal) – aGLib.TimeVal.Sets the
Gio.FILE_ATTRIBUTE_TIME_MODIFIEDandGio.FILE_ATTRIBUTE_TIME_MODIFIED_USECattributes in the file info to the given time value.Deprecated since version 2.62: Use
Gio.FileInfo.set_modification_date_time() instead, asGLib.TimeValis deprecated due to the year 2038 problem.
-
set_name(name)[source]¶ Parameters: name ( str) – a string containing a name.Sets the name attribute for the current
Gio.FileInfo. SeeGio.FILE_ATTRIBUTE_STANDARD_NAME.
-
set_size(size)[source]¶ Parameters: size ( int) – a #goffset containing the file’s size.Sets the
Gio.FILE_ATTRIBUTE_STANDARD_SIZEattribute in the file info to the given size.
-
set_sort_order(sort_order)[source]¶ Parameters: sort_order ( int) – a sort order integer.Sets the sort order attribute in the file info structure. See
Gio.FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
-
set_symbolic_icon(icon)[source]¶ Parameters: icon ( Gio.Icon) – aGio.Icon.Sets the symbolic icon for a given
Gio.FileInfo. SeeGio.FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON.New in version 2.34.
-
set_symlink_target(symlink_target)[source]¶ Parameters: symlink_target ( str) – a static string containing a path to a symlink target.Sets the
Gio.FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGETattribute in the file info to the given symlink target.
-
unset_attribute_mask()[source]¶ Unsets a mask set by
Gio.FileInfo.set_attribute_mask(), if one is set.
-
classmethod