class Gio::FileInfo
- Gio::FileInfo
- GObject::Object
- Reference
- Object
Overview
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.
#GFileAttributeMatcher allows for searching through a #GFileInfo for attributes.
Defined in:
lib/gi-crystal/src/auto/gio-2.0/file_info.crConstructors
-
.new : self
Creates a new file info structure.
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#access_date_time : GLib::DateTime?
Gets the access time of the current @info and returns it as a #GDateTime.
-
#access_date_time=(atime : GLib::DateTime) : Nil
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.
-
#attribute_as_string(attribute : String) : String?
Gets the value of a attribute, formatted as a string.
-
#attribute_boolean(attribute : String) : Bool
Gets the value of a boolean attribute.
-
#attribute_byte_string(attribute : String) : String?
Gets the value of a byte string attribute.
-
#attribute_data(attribute : String) : Bool
Gets the attribute type, value and status for an attribute key.
-
#attribute_int32(attribute : String) : Int32
Gets a signed 32-bit integer contained within the attribute.
-
#attribute_int64(attribute : String) : Int64
Gets a signed 64-bit integer contained within the attribute.
-
#attribute_mask=(mask : Gio::FileAttributeMatcher) : Nil
Sets @mask on @info to match specific attribute types.
-
#attribute_object(attribute : String) : GObject::Object?
Gets the value of a #GObject attribute.
-
#attribute_status(attribute : String) : Gio::FileAttributeStatus
Gets the attribute status for an attribute key.
-
#attribute_string(attribute : String) : String?
Gets the value of a string attribute.
-
#attribute_stringv(attribute : String) : Enumerable(String)?
Gets the value of a stringv attribute.
-
#attribute_type(attribute : String) : Gio::FileAttributeType
Gets the attribute type for an attribute key.
-
#attribute_uint32(attribute : String) : UInt32
Gets an unsigned 32-bit integer contained within the attribute.
-
#attribute_uint64(attribute : String) : UInt64
Gets a unsigned 64-bit integer contained within the attribute.
-
#clear_status : Nil
Clears the status information from @info.
-
#content_type : String?
Gets the file's content type.
-
#content_type=(content_type : String) : Nil
Sets the content type attribute for a given #GFileInfo.
-
#copy_into(dest_info : Gio::FileInfo) : Nil
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.
-
#creation_date_time : GLib::DateTime?
Gets the creation time of the current @info and returns it as a #GDateTime.
-
#creation_date_time=(creation_time : GLib::DateTime) : Nil
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.
-
#deletion_date : GLib::DateTime?
Returns the #GDateTime representing the deletion date of the file, as available in G_FILE_ATTRIBUTE_TRASH_DELETION_DATE.
-
#display_name : String
Gets a display name for a file.
-
#display_name=(display_name : String) : Nil
Sets the display name for the current #GFileInfo.
-
#dup : Gio::FileInfo
Duplicates a file info structure.
-
#edit_name : String
Gets the edit name for a file.
-
#edit_name=(edit_name : String) : Nil
Sets the edit name for the current file.
-
#etag : String?
Gets the [entity tag][gfile-etag] for a given #GFileInfo.
-
#file_type : Gio::FileType
Gets a file's type (whether it is a regular file, symlink, etc).
-
#file_type=(type : Gio::FileType) : Nil
Sets the file type in a #GFileInfo to @type.
-
#has_attribute(attribute : String) : Bool
Checks if a file info structure has an attribute named @attribute.
-
#has_namespace(name_space : String) : Bool
Checks if a file info structure has an attribute in the specified @name_space.
-
#icon : Gio::Icon?
Gets the icon for a file.
-
#icon=(icon : Gio::Icon) : Nil
Sets the icon for a given #GFileInfo.
-
#is_backup : Bool
Checks if a file is a backup file.
-
#is_hidden : Bool
Checks if a file is hidden.
-
#is_hidden=(is_hidden : Bool) : Nil
Sets the "is_hidden" attribute in a #GFileInfo according to @is_hidden.
-
#is_symlink : Bool
Checks if a file is a symlink.
-
#is_symlink=(is_symlink : Bool) : Nil
Sets the "is_symlink" attribute in a #GFileInfo according to @is_symlink.
-
#list_attributes(name_space : String?) : Enumerable(String)?
Lists the file info structure's attributes.
-
#modification_date_time : GLib::DateTime?
Gets the modification time of the current @info and returns it as a #GDateTime.
-
#modification_date_time=(mtime : GLib::DateTime) : Nil
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.
-
#modification_time : GLib::TimeVal
Gets the modification time of the current @info and sets it in @result.
-
#modification_time=(mtime : GLib::TimeVal) : Nil
Sets the %G_FILE_ATTRIBUTE_TIME_MODIFIED and %G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC attributes in the file info to the given time value.
-
#name : Path
Gets the name for a file.
-
#name=(name : String) : Nil
Sets the name attribute for the current #GFileInfo.
-
#remove_attribute(attribute : String) : Nil
Removes all cases of @attribute from @info if it exists.
-
#set_attribute(attribute : String, type : Gio::FileAttributeType, value_p : Pointer(Void)) : Nil
Sets the @attribute to contain the given value, if possible.
-
#set_attribute_boolean(attribute : String, attr_value : Bool) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#set_attribute_byte_string(attribute : String, attr_value : String) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#set_attribute_int32(attribute : String, attr_value : Int32) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#set_attribute_int64(attribute : String, attr_value : Int64) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#set_attribute_object(attribute : String, attr_value : GObject::Object) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#set_attribute_status(attribute : String, status : Gio::FileAttributeStatus) : Bool
Sets the attribute status for an attribute key.
-
#set_attribute_string(attribute : String, attr_value : String) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#set_attribute_stringv(attribute : String, attr_value : Enumerable(String)) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#set_attribute_uint32(attribute : String, attr_value : UInt32) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#set_attribute_uint64(attribute : String, attr_value : UInt64) : Nil
Sets the @attribute to contain the given @attr_value, if possible.
-
#size : Int64
Gets the file's size (in bytes).
-
#size=(size : Int64) : Nil
Sets the %G_FILE_ATTRIBUTE_STANDARD_SIZE attribute in the file info to the given size.
-
#sort_order : Int32
Gets the value of the sort_order attribute from the #GFileInfo.
-
#sort_order=(sort_order : Int32) : Nil
Sets the sort order attribute in the file info structure.
-
#symbolic_icon : Gio::Icon?
Gets the symbolic icon for a file.
-
#symbolic_icon=(icon : Gio::Icon) : Nil
Sets the symbolic icon for a given #GFileInfo.
-
#symlink_target : String?
Gets the symlink target for a given #GFileInfo.
-
#symlink_target=(symlink_target : String) : Nil
Sets the %G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in the file info to the given symlink target.
-
#unset_attribute_mask : Nil
Unsets a mask set by g_file_info_set_attribute_mask(), if one is set.
Instance methods inherited from class GObject::Object
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void)?
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void)?
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void)?) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void)?
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void)?
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
cast?(obj : GObject::Object) : self?
cast?,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
compat_control(what : UInt64, data : Pointer(Void)?) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Constructor Detail
Class Method Detail
Instance Method Detail
Gets the access time of the current @info and returns it as a #GDateTime.
This requires the %G_FILE_ATTRIBUTE_TIME_ACCESS attribute. If %G_FILE_ATTRIBUTE_TIME_ACCESS_USEC is provided, the resulting #GDateTime will 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().
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.
Gets the value of a attribute, formatted as a string. This escapes things as needed to make the string valid UTF-8.
Gets the value of a boolean attribute. If the attribute does not
contain a boolean value, false
will be returned.
Gets the value of a byte string attribute. If the attribute does
not contain a byte string, nil
will be returned.
Gets the attribute type, value and status for an attribute key.
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.
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.
Sets @mask on @info to match specific attribute types.
Gets the value of a #GObject attribute. If the attribute does
not contain a #GObject, nil
will be returned.
Gets the attribute status for an attribute key.
Gets the value of a string attribute. If the attribute does
not contain a string, nil
will be returned.
Gets the value of a stringv attribute. If the attribute does
not contain a stringv, nil
will be returned.
Gets the attribute type for an attribute key.
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.
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.
Sets the content type attribute for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.
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.
Gets the creation time of the current @info and returns it as a #GDateTime.
This requires the %G_FILE_ATTRIBUTE_TIME_CREATED attribute. If %G_FILE_ATTRIBUTE_TIME_CREATED_USEC is provided, the resulting #GDateTime will 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().
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.
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, nil
is returned.
Sets the display name for the current #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.
Sets the edit name for the current file. See %G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME.
Gets the [entity tag][gfile-etag] for a given #GFileInfo. See %G_FILE_ATTRIBUTE_ETAG_VALUE.
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().
Sets the file type in a #GFileInfo to @type. See %G_FILE_ATTRIBUTE_STANDARD_TYPE.
Checks if a file info structure has an attribute named @attribute.
Checks if a file info structure has an attribute in the specified @name_space.
Sets the icon for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_ICON.
Sets the "is_symlink" attribute in a #GFileInfo according to @is_symlink. See %G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.
Lists the file info structure's attributes.
Gets the modification time of the current @info and returns it as a #GDateTime.
This requires the %G_FILE_ATTRIBUTE_TIME_MODIFIED attribute. If %G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC is provided, the resulting #GDateTime will 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().
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.
Gets the modification time of the current @info and sets it in @result.
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.
Sets the name attribute for the current #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_NAME.
Removes all cases of @attribute from @info if it exists.
Sets the @attribute to contain the given value, if possible. To unset the attribute, use %G_FILE_ATTRIBUTE_TYPE_INVALID for @type.
Sets the @attribute to contain the given @attr_value, if possible.
Sets the @attribute to contain the given @attr_value, if possible.
Sets the @attribute to contain the given @attr_value, if possible.
Sets the @attribute to contain the given @attr_value, if possible.
Sets the @attribute to contain the given @attr_value, if possible.
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.
Sets the @attribute to contain the given @attr_value, if possible.
Sets the @attribute to contain the given @attr_value, if possible.
Sinze: 2.22
Sets the @attribute to contain the given @attr_value, if possible.
Sets the @attribute to contain the given @attr_value, if possible.
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.
Sets the %G_FILE_ATTRIBUTE_STANDARD_SIZE attribute in the file info to the given size.
Gets the value of the sort_order attribute from the #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
Sets the sort order attribute in the file info structure. See %G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
Sets the symbolic icon for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON.
Sets the %G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in the file info to the given symlink target.
Unsets a mask set by g_file_info_set_attribute_mask(), if one is set.