class Gio::FileInfo
- Gio::FileInfo
- GObject::Object
- Reference
- Object
Overview
Stores information about a file system object referenced by a Gio::File
.
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 Gio::File
, use
Gio::File#query_info
(or its async variant). To obtain a GFileInfo
for a file input or output stream, use Gio::FileInputStream#query_info
or Gio::FileOutputStream#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 Gio::File#attributes_from_info=
or Gio::File#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 Gio::FileInfo#size=
.
You may call Gio::File#query_settable_attributes
and
Gio::File#query_writable_namespaces
to discover the settable attributes
of a particular file at runtime.
The direct accessors, such as Gio::FileInfo#name
, are slightly more
optimized than the generic attribute accessors, such as
Gio::FileInfo#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
Gio::FileInfo#has_attribute
or Gio::FileInfo#list_attributes
to check what attributes are specified for a GFileInfo
.
Gio::FileAttributeMatcher
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
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#access_date_time : GLib::DateTime | Nil
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 | Nil
Gets the value of an attribute, formatted as a string.
-
#attribute_boolean(attribute : String) : Bool
Gets the value of a boolean attribute.
-
#attribute_byte_string(attribute : String) : String | Nil
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_file_path(attribute : String) : Path | Nil
Gets the value of a byte string attribute as a file path.
-
#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 | Nil
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 | Nil
Gets the value of a string attribute.
-
#attribute_stringv(attribute : String) : Enumerable(String) | Nil
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 | Nil
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 of dest_info, and then copies all of the file attributes from src_info to dest_info.
-
#creation_date_time : GLib::DateTime | Nil
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 | Nil
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 | Nil
Gets the [entity tag][iface@Gio.File#entity-tags] 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.
-
#hash(hasher)
See
Object#hash(hasher)
-
#icon : Gio::Icon | Nil
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 | Nil) : Enumerable(String) | Nil
Lists the file info structure's attributes.
-
#modification_date_time : GLib::DateTime | Nil
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.
DEPRECATED
-
#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.
DEPRECATED
-
#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_file_path(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 | Nil
Gets the symbolic icon for a file.
-
#symbolic_icon=(icon : Gio::Icon) : Nil
Sets the symbolic icon for a given #GFileInfo.
-
#symlink_target : Path | Nil
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
==(other : self)
==,
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) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
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) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
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,
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
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : 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
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
Class Method Detail
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Gets the access time of the current info 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 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 an 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 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.
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.
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.
Sets the content type attribute for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.
First clears all of the 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.
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 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.
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.
Sets the display name for the current #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_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.
Sets the edit name for the current file. See %G_FILE_ATTRIBUTE_STANDARD_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.
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().
It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_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.
Gets the icon for a file.
It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_ICON.
Sets the icon for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_ICON.
Checks if a file is a backup file.
It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP.
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.
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.
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 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.
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 it will be used too.
DEPRECATED
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.
DEPRECATED
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.
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.
This function is meant to be used by language bindings that have specific handling for Unix paths.
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.
It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_SIZE.
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.
It is an error to call this if the #GFileInfo does not contain %G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
Sets the sort order attribute in the file info structure. See %G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
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.
Sets the symbolic icon for a given #GFileInfo. See %G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON.
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.
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.