FileInfo

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.

class FileInfo : ObjectG {}

Constructors

this
this()

Creates a new file info structure.

Members

Functions

clearStatus
void clearStatus()

Clears the status information from info.

copyInto
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.

dup
gio.file_info.FileInfo dup()

Duplicates a file info structure.

getAccessDateTime
glib.date_time.DateTime getAccessDateTime()

Gets the access time of the current info and returns it as a #GDateTime.

getAttributeAsString
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.

getAttributeBoolean
bool getAttributeBoolean(string attribute)

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

getAttributeByteString
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.

getAttributeData
bool getAttributeData(string attribute, gio.types.FileAttributeType type, void* valuePp, gio.types.FileAttributeStatus status)

Gets the attribute type, value and status for an attribute key.

getAttributeFilePath
string getAttributeFilePath(string attribute)

Gets the value of a byte string attribute as a file path.

getAttributeInt32
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.

getAttributeInt64
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.

getAttributeObject
gobject.object.ObjectG getAttributeObject(string attribute)

Gets the value of a #GObject attribute. If the attribute does not contain a #GObject, null will be returned.

getAttributeStatus
gio.types.FileAttributeStatus getAttributeStatus(string attribute)

Gets the attribute status for an attribute key.

getAttributeString
string getAttributeString(string attribute)

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

getAttributeStringv
string[] getAttributeStringv(string attribute)

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

getAttributeType
gio.types.FileAttributeType getAttributeType(string attribute)

Gets the attribute type for an attribute key.

getAttributeUint32
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.

getAttributeUint64
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.

getContentType
string getContentType()

Gets the file's content type.

getCreationDateTime
glib.date_time.DateTime getCreationDateTime()

Gets the creation time of the current info and returns it as a #GDateTime.

getDeletionDate
glib.date_time.DateTime getDeletionDate()

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, null is returned.

getDisplayName
string getDisplayName()

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

getEditName
string getEditName()

Gets the edit name for a file.

getEtag
string getEtag()

Gets the entity tag for a given #GFileInfo. See G_FILE_ATTRIBUTE_ETAG_VALUE.

getFileType
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.

getIcon
gio.icon.Icon getIcon()

Gets the icon for a file.

getIsBackup
bool getIsBackup()

Checks if a file is a backup file.

getIsHidden
bool getIsHidden()

Checks if a file is hidden.

getIsSymlink
bool getIsSymlink()

Checks if a file is a symlink.

getModificationDateTime
glib.date_time.DateTime getModificationDateTime()

Gets the modification time of the current info and returns it as a #GDateTime.

getModificationTime
void getModificationTime(glib.time_val.TimeVal result)

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

getName
string getName()

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

getSize
long getSize()

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.

getSortOrder
int getSortOrder()

Gets the value of the sort_order attribute from the #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.

getSymbolicIcon
gio.icon.Icon getSymbolicIcon()

Gets the symbolic icon for a file.

getSymlinkTarget
string getSymlinkTarget()

Gets the symlink target for a given #GFileInfo.

hasAttribute
bool hasAttribute(string attribute)

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

hasNamespace
bool hasNamespace(string nameSpace)

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

listAttributes
string[] listAttributes(string nameSpace)

Lists the file info structure's attributes.

removeAttribute
void removeAttribute(string attribute)

Removes all cases of attribute from info if it exists.

setAccessDateTime
void setAccessDateTime(glib.date_time.DateTime atime)

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.

setAttribute
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.

setAttributeBoolean
void setAttributeBoolean(string attribute, bool attrValue)

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

setAttributeByteString
void setAttributeByteString(string attribute, string attrValue)

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

setAttributeFilePath
void setAttributeFilePath(string attribute, string attrValue)

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

setAttributeInt32
void setAttributeInt32(string attribute, int attrValue)

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

setAttributeInt64
void setAttributeInt64(string attribute, long attrValue)

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

setAttributeMask
void setAttributeMask(gio.file_attribute_matcher.FileAttributeMatcher mask)

Sets mask on info to match specific attribute types.

setAttributeObject
void setAttributeObject(string attribute, gobject.object.ObjectG attrValue)

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

setAttributeStatus
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.

setAttributeString
void setAttributeString(string attribute, string attrValue)

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

setAttributeStringv
void setAttributeStringv(string attribute, string[] attrValue)

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

setAttributeUint32
void setAttributeUint32(string attribute, uint attrValue)

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

setAttributeUint64
void setAttributeUint64(string attribute, ulong attrValue)

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

setContentType
void setContentType(string contentType)

Sets the content type attribute for a given #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.

setCreationDateTime
void setCreationDateTime(glib.date_time.DateTime creationTime)

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.

setDisplayName
void setDisplayName(string displayName)

Sets the display name for the current #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.

setEditName
void setEditName(string editName)

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

setFileType
void setFileType(gio.types.FileType type)

Sets the file type in a #GFileInfo to type. See G_FILE_ATTRIBUTE_STANDARD_TYPE.

setIcon
void setIcon(gio.icon.Icon icon)

Sets the icon for a given #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_ICON.

setIsHidden
void setIsHidden(bool isHidden)

Sets the "is_hidden" attribute in a #GFileInfo according to is_hidden. See G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN.

setIsSymlink
void setIsSymlink(bool isSymlink)

Sets the "is_symlink" attribute in a #GFileInfo according to is_symlink. See G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.

setModificationDateTime
void setModificationDateTime(glib.date_time.DateTime mtime)

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.

setModificationTime
void setModificationTime(glib.time_val.TimeVal mtime)

Sets the G_FILE_ATTRIBUTE_TIME_MODIFIED and G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC attributes in the file info to the given time value.

setName
void setName(string name)

Sets the name attribute for the current #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_NAME.

setSize
void setSize(long size)

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

setSortOrder
void setSortOrder(int sortOrder)

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

setSymbolicIcon
void setSymbolicIcon(gio.icon.Icon icon)

Sets the symbolic icon for a given #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON.

setSymlinkTarget
void setSymlinkTarget(string symlinkTarget)

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

unsetAttributeMask
void unsetAttributeMask()

Unsets a mask set by gio.file_info.FileInfo.setAttributeMask, if one is set.

Inherited Members

From ObjectG

setGObject
void setGObject(void* cObj, Flag!"Take" take)

Set the GObject of a D ObjectG wrapper.

cPtr
void* cPtr(Flag!"Dup" dup)

Get a pointer to the underlying C object.

ref_
void* ref_(void* gObj)

Calls g_object_ref() on a GObject.

unref
unref(void* gObj)

Calls g_object_unref() on a GObject.

getType
GType getType()

Get the GType of an object.

gType
GType gType [@property getter]

GObject GType property.

self
ObjectG self()

Convenience method to return this cast to a type. For use in D with statements.

getDObject
T getDObject(void* cptr, Flag!"Take" take)

Template to get the D object from a C GObject and cast it to the given D object type.

connectSignalClosure
ulong connectSignalClosure(string signalDetail, DClosure closure, Flag!"After" after)

Connect a D closure to an object signal.

setProperty
void setProperty(string propertyName, T val)

Template for setting a GObject property.

getProperty
T getProperty(string propertyName)

Template for getting a GObject property.

compatControl
size_t compatControl(size_t what, void* data)
bindProperty
gobject.binding.Binding bindProperty(string sourceProperty, gobject.object.ObjectG target, string targetProperty, gobject.types.BindingFlags flags)

Creates a binding between source_property on source and target_property on target.

bindPropertyFull
gobject.binding.Binding bindPropertyFull(string sourceProperty, gobject.object.ObjectG target, string targetProperty, gobject.types.BindingFlags flags, gobject.closure.Closure transformTo, gobject.closure.Closure transformFrom)

Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

forceFloating
void forceFloating()

This function is intended for #GObject implementations to re-enforce a floating[floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling gobject.object.ObjectG.refSink.

freezeNotify
void freezeNotify()

Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.

getData
void* getData(string key)

Gets a named field from the objects table of associations (see gobject.object.ObjectG.setData).

getProperty
void getProperty(string propertyName, gobject.value.Value value)

Gets a property of an object.

getQdata
void* getQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectG.setQdata.

getv
void getv(string[] names, gobject.value.Value[] values)

Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

isFloating
bool isFloating()

Checks whether object has a floating[floating-ref] reference.

notify
void notify(string propertyName)

Emits a "notify" signal for the property property_name on object.

notifyByPspec
void notifyByPspec(gobject.param_spec.ParamSpec pspec)

Emits a "notify" signal for the property specified by pspec on object.

refSink
gobject.object.ObjectG refSink()

Increase the reference count of object, and possibly remove the floating[floating-ref] reference, if object has a floating reference.

runDispose
void runDispose()

Releases all references to other objects. This can be used to break reference cycles.

setData
void setData(string key, void* data)

Each object carries around a table of associations from strings to pointers. This function lets you set an association.

setProperty
void setProperty(string propertyName, gobject.value.Value value)

Sets a property on an object.

stealData
void* stealData(string key)

Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

stealQdata
void* stealQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectG.setQdata and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

thawNotify
void thawNotify()

Reverts the effect of a previous call to gobject.object.ObjectG.freezeNotify. The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

watchClosure
void watchClosure(gobject.closure.Closure closure)

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling gobject.closure.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, gobject.object.ObjectG.ref_ and gobject.object.ObjectG.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

connectNotify
ulong connectNotify(string detail, T callback, Flag!"After" after)

Connect to Notify signal.