gio.file_info

Module for FileInfo class

Types 3

Stores information about a file system object referenced by a gio.file.File.

Functionality for manipulating basic metadata for files. gio.file_info.FileInfo implements methods for getting information that all files should contain, and allows for manipulation of extended attributes.

See file-attributes.html for more information on how GIO handles file attributes.

To obtain a gio.file_info.FileInfo for a gio.file.File, use gio.file.File.queryInfo (or its async variant). To obtain a gio.file_info.FileInfo for a file input or output stream, use gio.file_input_stream.FileInputStream.queryInfo or gio.file_output_stream.FileOutputStream.queryInfo (or their async variants).

To change the actual attributes of a file, you should then set the attribute in the gio.file_info.FileInfo and call gio.file.File.setAttributesFromInfo or gio.file.File.setAttributesAsync on a gio.file.File.

However, not all attributes can be changed in the file. For instance, the actual size of a file cannot be changed via gio.file_info.FileInfo.setSize. You may call gio.file.File.querySettableAttributes and gio.file.File.queryWritableNamespaces to discover the settable attributes of a particular file at runtime.

The direct accessors, such as gio.file_info.FileInfo.getName, are slightly more optimized than the generic attribute accessors, such as gio.file_info.FileInfo.getAttributeByteString.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 gio.file_info.FileInfo. Use gio.file_info.FileInfo.hasAttribute or gio.file_info.FileInfo.listAttributes to check what attributes are specified for a gio.file_info.FileInfo.

gio.file_attribute_matcher.FileAttributeMatcher allows for searching through a gio.file_info.FileInfo for attributes.

Methods
GType _gType() @property
FileInfo self()Returns `this`, for use in `with` statements.
FileInfoGidBuilder builder()Get builder for [gio.file_info.FileInfo] Returns: New builder object
void clearStatus()Clears the status information from info.
void copyInto(gio.file_info.FileInfo destInfo)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.
gio.file_info.FileInfo dup()Duplicates a file info structure. Returns: a duplicate #GFileInfo of other.
glib.date_time.DateTime getAccessDateTime()Gets the access time of the current info and returns it as a #GDateTime.
string getAttributeAsString(string attribute)Gets the value of an attribute, formatted as a string. This escapes things as needed to make the string valid UTF-8.
bool getAttributeBoolean(string attribute)Gets the value of a boolean attribute. If the attribute does not contain a boolean value, false will be returned.
string getAttributeByteString(string attribute)Gets the value of a byte string attribute. If the attribute does not contain a byte string, null will be returned.
bool getAttributeData(string attribute, out gio.types.FileAttributeType type, out void * valuePp, out gio.types.FileAttributeStatus status)Gets the attribute type, value and status for an attribute key.
string getAttributeFilePath(string attribute)Gets the value of a byte string attribute as a file path.
int getAttributeInt32(string attribute)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.
long getAttributeInt64(string 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.
gobject.object.ObjectWrap getAttributeObject(string attribute)Gets the value of a #GObject attribute. If the attribute does not contain a #GObject, null will be returned.
gio.types.FileAttributeStatus getAttributeStatus(string attribute)Gets the attribute status for an attribute key.
string getAttributeString(string attribute)Gets the value of a string attribute. If the attribute does not contain a string, null will be returned.
string[] getAttributeStringv(string attribute)Gets the value of a stringv attribute. If the attribute does not contain a stringv, null will be returned.
gio.types.FileAttributeType getAttributeType(string attribute)Gets the attribute type for an attribute key.
uint getAttributeUint32(string attribute)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.
ulong getAttributeUint64(string 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.
string getContentType()Gets the file's content type.
glib.date_time.DateTime getCreationDateTime()Gets the creation time of the current info and returns it as a #GDateTime.
glib.date_time.DateTime getDeletionDate()Returns the #GDateTime representing the deletion date of the file, as available in [gio.types.FILE_ATTRIBUTE_TRASH_DELETION_DATE]. If the [gio.types.FILE_ATTRIBUTE_TRASH_DELETION_DATE] attribute is...
string getDisplayName()Gets a display name for a file. This is guaranteed to always be set.
string getEditName()Gets the edit name for a file.
string getEtag()Gets the [entity tag](iface.File.html#entity-tags) for a given #GFileInfo. See [gio.types.FILE_ATTRIBUTE_ETAG_VALUE].
gio.types.FileType getFileType()Gets a file's type (whether it is a regular file, symlink, etc). This is different from the file's content type, see [gio.file_info.FileInfo.getContentType].
gio.icon.Icon getIcon()Gets the icon for a file.
bool getIsBackup()Checks if a file is a backup file.
bool getIsHidden()Checks if a file is hidden.
bool getIsSymlink()Checks if a file is a symlink.
glib.date_time.DateTime getModificationDateTime()Gets the modification time of the current info and returns it as a #GDateTime.
void getModificationTime(out glib.time_val.TimeVal result)Gets the modification time of the current info and sets it in result.
string getName()Gets the name for a file. This is guaranteed to always be set.
long getSize()Gets the file's size (in bytes). The size is retrieved through the value of the [gio.types.FILE_ATTRIBUTE_STANDARD_SIZE] attribute and is converted from #guint64 to #goffset before returning the re...
int getSortOrder()Gets the value of the sort_order attribute from the #GFileInfo. See [gio.types.FILE_ATTRIBUTE_STANDARD_SORT_ORDER].
gio.icon.Icon getSymbolicIcon()Gets the symbolic icon for a file.
string getSymlinkTarget()Gets the symlink target for a given #GFileInfo.
bool hasAttribute(string attribute)Checks if a file info structure has an attribute named attribute.
bool hasNamespace(string nameSpace)Checks if a file info structure has an attribute in the specified name_space.
string[] listAttributes(string nameSpace = null)Lists the file info structure's attributes.
void removeAttribute(string attribute)Removes all cases of attribute from info if it exists.
void setAccessDateTime(glib.date_time.DateTime atime)Sets the [gio.types.FILE_ATTRIBUTE_TIME_ACCESS] and [gio.types.FILE_ATTRIBUTE_TIME_ACCESS_USEC] attributes in the file info to the given date/time value.
void setAttribute(string attribute, gio.types.FileAttributeType type, void * valueP)Sets the attribute to contain the given value, if possible. To unset the attribute, use [gio.types.FileAttributeType.Invalid] for type.
void setAttributeBoolean(string attribute, bool attrValue)Sets the attribute to contain the given attr_value, if possible.
void setAttributeByteString(string attribute, string attrValue)Sets the attribute to contain the given attr_value, if possible.
void setAttributeFilePath(string attribute, string attrValue)Sets the attribute to contain the given attr_value, if possible.
void setAttributeInt32(string attribute, int attrValue)Sets the attribute to contain the given attr_value, if possible.
void setAttributeInt64(string attribute, long attrValue)Sets the attribute to contain the given attr_value, if possible.
void setAttributeMask(gio.file_attribute_matcher.FileAttributeMatcher mask)Sets mask on info to match specific attribute types.
void setAttributeObject(string attribute, gobject.object.ObjectWrap attrValue)Sets the attribute to contain the given attr_value, if possible.
bool setAttributeStatus(string attribute, gio.types.FileAttributeStatus status)Sets the attribute status for an attribute key. This is only needed by external code that implement [gio.file.File.setAttributesFromInfo] or similar functions.
void setAttributeString(string attribute, string attrValue)Sets the attribute to contain the given attr_value, if possible.
void setAttributeStringv(string attribute, string[] attrValue)Sets the attribute to contain the given attr_value, if possible.
void setAttributeUint32(string attribute, uint attrValue)Sets the attribute to contain the given attr_value, if possible.
void setAttributeUint64(string attribute, ulong attrValue)Sets the attribute to contain the given attr_value, if possible.
void setContentType(string contentType)Sets the content type attribute for a given #GFileInfo. See [gio.types.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE].
void setCreationDateTime(glib.date_time.DateTime creationTime)Sets the [gio.types.FILE_ATTRIBUTE_TIME_CREATED] and [gio.types.FILE_ATTRIBUTE_TIME_CREATED_USEC] attributes in the file info to the given date/time value.
void setDisplayName(string displayName)Sets the display name for the current #GFileInfo. See [gio.types.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME].
void setEditName(string editName)Sets the edit name for the current file. See [gio.types.FILE_ATTRIBUTE_STANDARD_EDIT_NAME].
void setFileType(gio.types.FileType type)Sets the file type in a #GFileInfo to type. See [gio.types.FILE_ATTRIBUTE_STANDARD_TYPE].
void setIcon(gio.icon.Icon icon)Sets the icon for a given #GFileInfo. See [gio.types.FILE_ATTRIBUTE_STANDARD_ICON].
void setIsHidden(bool isHidden)Sets the "is_hidden" attribute in a #GFileInfo according to is_hidden. See [gio.types.FILE_ATTRIBUTE_STANDARD_IS_HIDDEN].
void setIsSymlink(bool isSymlink)Sets the "is_symlink" attribute in a #GFileInfo according to is_symlink. See [gio.types.FILE_ATTRIBUTE_STANDARD_IS_SYMLINK].
void setModificationDateTime(glib.date_time.DateTime mtime)Sets the [gio.types.FILE_ATTRIBUTE_TIME_MODIFIED] and [gio.types.FILE_ATTRIBUTE_TIME_MODIFIED_USEC] attributes in the file info to the given date/time value.
void setModificationTime(glib.time_val.TimeVal mtime)Sets the [gio.types.FILE_ATTRIBUTE_TIME_MODIFIED] and [gio.types.FILE_ATTRIBUTE_TIME_MODIFIED_USEC] attributes in the file info to the given time value.
void setName(string name)Sets the name attribute for the current #GFileInfo. See [gio.types.FILE_ATTRIBUTE_STANDARD_NAME].
void setSize(long size)Sets the [gio.types.FILE_ATTRIBUTE_STANDARD_SIZE] attribute in the file info to the given size.
void setSortOrder(int sortOrder)Sets the sort order attribute in the file info structure. See [gio.types.FILE_ATTRIBUTE_STANDARD_SORT_ORDER].
void setSymbolicIcon(gio.icon.Icon icon)Sets the symbolic icon for a given #GFileInfo. See [gio.types.FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON].
void setSymlinkTarget(string symlinkTarget)Sets the [gio.types.FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET] attribute in the file info to the given symlink target.
void unsetAttributeMask()Unsets a mask set by [gio.file_info.FileInfo.setAttributeMask], if one is set.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new file info structure. Returns: a #GFileInfo.

Fluent builder implementation template for gio.file_info.FileInfo

Fluent builder for gio.file_info.FileInfo

Methods
FileInfo build()Create object from builder. Returns: New object