Struct gio::FileInfo

source ·
#[repr(transparent)]
pub struct FileInfo { /* private fields */ }
Expand description

Functionality for manipulating basic metadata for files. FileInfo 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 FileInfo for a File, use FileExt::query_info() (or its async variant). To obtain a FileInfo for a file input or output stream, use FileInputStreamExt::query_info() or FileOutputStreamExt::query_info() (or their async variants).

To change the actual attributes of a file, you should then set the attribute in the FileInfo and call FileExt::set_attributes_from_info() or FileExt::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 set_size(). You may call FileExt::query_settable_attributes() and FileExt::query_writable_namespaces() to discover the settable attributes of a particular file at runtime.

The direct accessors, such as name(), are slightly more optimized than the generic attribute accessors, such as attribute_byte_string().This optimization will matter only if calling the API in a tight loop.

FileAttributeMatcher allows for searching through a FileInfo for attributes.

Implements

glib::ObjectExt

Implementations

Gets the modification time of the current self and sets it in result.

Deprecated since 2.62

Use modification_date_time() instead, as GTimeVal is deprecated due to the year 2038 problem.

Returns
result

a GTimeVal.

Sets the FILE_ATTRIBUTE_TIME_MODIFIED and FILE_ATTRIBUTE_TIME_MODIFIED_USEC attributes in the file info to the given time value.

FILE_ATTRIBUTE_TIME_MODIFIED_NSEC will be cleared.

Deprecated since 2.62

Use set_modification_date_time() instead, as GTimeVal is deprecated due to the year 2038 problem.

mtime

a GTimeVal.

Creates a new file info structure.

Returns

a FileInfo.

Clears the status information from self.

First clears all of the [GFileAttribute][gio-GFileAttribute] of dest_info, and then copies all of the file attributes from self to dest_info.

dest_info

destination to copy attributes to.

Duplicates a file info structure.

Returns

a duplicate FileInfo of self.

Available on crate feature v2_70 only.

Gets the access time of the current self and returns it as a glib::DateTime.

This requires the FILE_ATTRIBUTE_TIME_ACCESS attribute. If FILE_ATTRIBUTE_TIME_ACCESS_USEC is provided, the resulting glib::DateTime will have microsecond precision.

If nanosecond precision is needed, FILE_ATTRIBUTE_TIME_ACCESS_NSEC must be queried separately using attribute_uint32().

Returns

access time, or None if unknown

Gets the value of a attribute, formatted as a string. This escapes things as needed to make the string valid UTF-8.

attribute

a file attribute key.

Returns

a UTF-8 string associated with the given attribute, or None if the attribute wasn’t set. When you’re done with the string it must be freed with g_free().

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

attribute

a file attribute key.

Returns

the boolean value contained within the attribute.

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

attribute

a file attribute key.

Returns

the contents of the attribute value as a byte string, or None 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.

attribute

a file attribute key.

Returns

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.

attribute

a file attribute key.

Returns

a signed 64-bit integer from the attribute.

Gets the value of a glib::Object attribute. If the attribute does not contain a glib::Object, None will be returned.

attribute

a file attribute key.

Returns

a glib::Object associated with the given attribute, or None otherwise.

Gets the attribute status for an attribute key.

attribute

a file attribute key

Returns

a FileAttributeStatus for the given attribute, or FileAttributeStatus::Unset if the key is invalid.

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

attribute

a file attribute key.

Returns

the contents of the attribute value as a UTF-8 string, or None otherwise.

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

attribute

a file attribute key.

Returns

the contents of the attribute value as a stringv, or None otherwise. Do not free. These returned strings are UTF-8.

Gets the attribute type for an attribute key.

attribute

a file attribute key.

Returns

a FileAttributeType for the given attribute, or FileAttributeType::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.

attribute

a file attribute key.

Returns

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.

attribute

a file attribute key.

Returns

a unsigned 64-bit integer from the attribute.

Gets the file’s content type.

Returns

a string containing the file’s content type, or None if unknown.

Available on crate feature v2_70 only.

Gets the creation time of the current self and returns it as a glib::DateTime.

This requires the FILE_ATTRIBUTE_TIME_CREATED attribute. If FILE_ATTRIBUTE_TIME_CREATED_USEC is provided, the resulting glib::DateTime will have microsecond precision.

If nanosecond precision is needed, FILE_ATTRIBUTE_TIME_CREATED_NSEC must be queried separately using attribute_uint32().

Returns

creation time, or None if unknown

Returns the glib::DateTime 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, None is returned.

Returns

a glib::DateTime, or None.

Gets a display name for a file. This is guaranteed to always be set.

Returns

a string containing the display name.

Gets the edit name for a file.

Returns

a string containing the edit name.

Gets the [entity tag][gfile-etag] for a given FileInfo. See FILE_ATTRIBUTE_ETAG_VALUE.

Returns

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 content_type().

Returns

a FileType for the given file.

Gets the icon for a file.

Returns

Icon for the given self.

Checks if a file is a backup file.

Returns

true if file is a backup file, false otherwise.

Checks if a file is hidden.

Returns

true if the file is a hidden file, false otherwise.

Checks if a file is a symlink.

Returns

true if the given self is a symlink.

Available on crate feature v2_62 only.

Gets the modification time of the current self and returns it as a glib::DateTime.

This requires the FILE_ATTRIBUTE_TIME_MODIFIED attribute. If FILE_ATTRIBUTE_TIME_MODIFIED_USEC is provided, the resulting glib::DateTime will have microsecond precision.

If nanosecond precision is needed, FILE_ATTRIBUTE_TIME_MODIFIED_NSEC must be queried separately using attribute_uint32().

Returns

modification time, or None if unknown

Gets the name for a file. This is guaranteed to always be set.

Returns

a string containing the file name.

Gets the file’s size (in bytes). The size is retrieved through the value of the FILE_ATTRIBUTE_STANDARD_SIZE attribute and is converted from guint64 to goffset before returning the result.

Returns

a goffset containing the file’s size (in bytes).

Gets the value of the sort_order attribute from the FileInfo. See FILE_ATTRIBUTE_STANDARD_SORT_ORDER.

Returns

a gint32 containing the value of the “standard::sort_order” attribute.

Gets the symbolic icon for a file.

Returns

Icon for the given self.

Gets the symlink target for a given FileInfo.

Returns

a string containing the symlink target.

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

attribute

a file attribute key.

Returns

true if self has an attribute named attribute, false otherwise.

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

name_space

a file attribute namespace.

Returns

true if self has an attribute in name_space, false otherwise.

Lists the file info structure’s attributes.

name_space

a file attribute key’s namespace, or None to list all attributes.

Returns

a null-terminated array of strings of all of the possible attribute types for the given name_space, or None on error.

Removes all cases of attribute from self if it exists.

attribute

a file attribute key.

Available on crate feature v2_70 only.

Sets the FILE_ATTRIBUTE_TIME_ACCESS and FILE_ATTRIBUTE_TIME_ACCESS_USEC attributes in the file info to the given date/time value.

FILE_ATTRIBUTE_TIME_ACCESS_NSEC will be cleared.

atime

a glib::DateTime.

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

attribute

a file attribute key.

attr_value

a boolean value.

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

attribute

a file attribute key.

attr_value

a byte string.

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

attribute

a file attribute key.

attr_value

a signed 32-bit integer

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

attribute

attribute name to set.

attr_value

int64 value to set attribute to.

Sets mask on self to match specific attribute types.

mask

a FileAttributeMatcher.

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

attribute

a file attribute key.

attr_value

a glib::Object.

Sets the attribute status for an attribute key. This is only needed by external code that implement FileExt::set_attributes_from_info() or similar functions.

The attribute must exist in self for this to work. Otherwise false is returned and self is unchanged.

attribute

a file attribute key

status

a FileAttributeStatus

Returns

true if the status was changed, false if the key was not set.

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

attribute

a file attribute key.

attr_value

a UTF-8 string.

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

Sinze: 2.22

attribute

a file attribute key

attr_value

a None terminated array of UTF-8 strings.

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

attribute

a file attribute key.

attr_value

an unsigned 32-bit integer.

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

attribute

a file attribute key.

attr_value

an unsigned 64-bit integer.

Sets the content type attribute for a given FileInfo. See FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.

content_type

a content type. See [GContentType][gio-GContentType]

Available on crate feature v2_70 only.

Sets the FILE_ATTRIBUTE_TIME_CREATED and FILE_ATTRIBUTE_TIME_CREATED_USEC attributes in the file info to the given date/time value.

FILE_ATTRIBUTE_TIME_CREATED_NSEC will be cleared.

creation_time

a glib::DateTime.

Sets the display name for the current FileInfo. See FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.

display_name

a string containing a display name.

Sets the edit name for the current file. See FILE_ATTRIBUTE_STANDARD_EDIT_NAME.

edit_name

a string containing an edit name.

Sets the file type in a FileInfo to type_. See FILE_ATTRIBUTE_STANDARD_TYPE.

type_

a FileType.

Sets the icon for a given FileInfo. See FILE_ATTRIBUTE_STANDARD_ICON.

icon

a Icon.

Sets the “is_hidden” attribute in a FileInfo according to is_hidden. See FILE_ATTRIBUTE_STANDARD_IS_HIDDEN.

is_hidden

a gboolean.

Sets the “is_symlink” attribute in a FileInfo according to is_symlink. See FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.

a gboolean.

Available on crate feature v2_62 only.

Sets the FILE_ATTRIBUTE_TIME_MODIFIED and FILE_ATTRIBUTE_TIME_MODIFIED_USEC attributes in the file info to the given date/time value.

FILE_ATTRIBUTE_TIME_MODIFIED_NSEC will be cleared.

mtime

a glib::DateTime.

Sets the name attribute for the current FileInfo. See FILE_ATTRIBUTE_STANDARD_NAME.

name

a string containing a name.

Sets the FILE_ATTRIBUTE_STANDARD_SIZE attribute in the file info to the given size.

size

a goffset containing the file’s size.

Sets the sort order attribute in the file info structure. See FILE_ATTRIBUTE_STANDARD_SORT_ORDER.

sort_order

a sort order integer.

Sets the symbolic icon for a given FileInfo. See FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON.

icon

a Icon.

Sets the FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in the file info to the given symlink target.

a static string containing a path to a symlink target.

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

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T. Read more
Upcasts an object to a reference of its superclass or interface T. Read more
Tries to downcast to a subclass or interface implementor T. Read more
Tries to downcast to a reference of its subclass or interface implementor T. Read more
Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Casts to T unconditionally. Read more
Casts to &T unconditionally. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Returns true if the object is an instance of (can be cast to) T.
Returns the type of the object.
Returns the ObjectClass of the object. Read more
Returns the class of the object.
Returns the class of the object in the given type T. Read more
Returns the interface T of the object. Read more
Sets the property property_name of the object to value value. Read more
Sets the property property_name of the object to value value. Read more
Sets multiple properties of the object at once. Read more
Sets multiple properties of the object at once. Read more
Gets the property property_name of the object and cast it to the type V. Read more
Gets the property property_name of the object. Read more
Check if the object has a property property_name of the given type_. Read more
Get the type of the property property_name of this object. Read more
Get the ParamSpec of the property property_name of this object.
Return all ParamSpec of the properties of this object.
Freeze all property notifications until the return guard object is dropped. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Block a given signal handler. Read more
Unblock a given signal handler.
Stop emission of the currently emitted signal.
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect a closure to the signal signal_name on this object. Read more
Connect a closure to the signal signal_id on this object. Read more
Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures. Read more
Emit signal by signal id. Read more
Same as Self::emit but takes Value for the arguments.
Emit signal by its name. Read more
Emit signal by its name. Read more
Emit signal by its name with details. Read more
Emit signal by its name with details. Read more
Emit signal by signal id with details. Read more
Emit signal by signal id with details. Read more
Disconnect a previously connected signal handler.
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Notify that the given property has changed its value. Read more
Notify that the given property has changed its value. Read more
Downgrade this object to a weak reference.
Add a callback to be notified when the Object is disposed.
Add a callback to be notified when the Object is disposed. Read more
Bind property source_property on this object to the target_property on the target object. Read more
Returns the strong reference count of this object.
Runs the dispose mechanism of the object. Read more
Ensures that the type has been registered with the type system.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.