# Gio::FileInfo Class Reference

FileInfo implements methods for getting information that all files should contain, and allows for manipulation of extended attributes. More...

`#include <giomm/fileinfo.h>`

Inheritance diagram for Gio::FileInfo:
[legend]

List of all members.

## Public Member Functions
virtual | ~FileInfo ()
GFileInfo* | gobj ()
| Provides access to the underlying C GObject.
const GFileInfo* | gobj () const
| Provides access to the underlying C GObject.
GFileInfo* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
| FileInfo ()
Glib::RefPtr< FileInfo > | dup () const
| Duplicates a file info structure.
void | copy_into (Glib::RefPtr< FileInfo >& dest) const
| Copies all of the FileAttributes from src_info to dest_info.
bool | has_attribute (const std::string& attribute) const
| Checks if a file info structure has an attribute named attribute.
Glib::StringArrayHandle | list_attributes (const std::string& name_space) const
| Lists the file info structure's attributes.
FileAttributeType | get_attribute_type (const std::string& attribute) const
| Gets the attribute type for an attribute key.
void | remove_attribute (const std::string& attribute)
| Removes all cases of attribute from info if it exists.
std::string | get_attribute_string (const std::string& attribute) const
| Gets the value of a string attribute.
Glib::ustring | get_attribute_as_string (const std::string& attribute) const
| Gets the value of a attribute, formated as a string.
std::string | get_attribute_byte_string (const std::string& attribute) const
| Gets the value of a byte string attribute.
bool | get_attribute_boolean (const std::string& attribute) const
| Gets the value of a boolean attribute.
guint32 | get_attribute_uint32 (const std::string& attribute) const
| Gets an unsigned 32-bit integer contained within the attribute.
gint32 | get_attribute_int32 (const std::string& attribute) const
| Gets a signed 32-bit integer contained within the attribute.
guint64 | get_attribute_uint64 (const std::string& attribute) const
| Gets a unsigned 64-bit integer contained within the attribute.
gint64 | get_attribute_int64 (const std::string& attribute) const
| Gets a signed 64-bit integer contained within the attribute.
Glib::RefPtr< Glib::Object > | get_attribute_object (const std::string& attribute) const
| Gets the value of a Object attribute.
void | set_attribute_string (const std::string& attribute, const std::string&value)
| Sets the attribute to contain the given attr_value, if possible.
void | set_attribute_byte_string (const std::string& attribute, const std::string&value)
| Sets the attribute to contain the given attr_value, if possible.
void | set_attribute_boolean (const std::string& attribute, bool value)
| Sets the attribute to contain the given attr_value, if possible.
void | set_attribute_uint32 (const std::string& attribute, guint32 value)
| Sets the attribute to contain the given attr_value, if possible.
void | set_attribute_int32 (const std::string& attribute, gint32 value)
| Sets the attribute to contain the given attr_value, if possible.
void | set_attribute_uint64 (const std::string& attribute, guint64 value)
| Sets the attribute to contain the given attr_value, if possible.
void | set_attribute_int64 (const std::string& attribute, gint64 value)
| Sets the attribute to contain the given attr_value, if possible.
void | set_attribute_object (const std::string& attribute, const Glib::RefPtr< Glib::Object >& object)
| Sets the attribute to contain the given attr_value, if possible.
void | clear_status ()
| Clears the status information from info.
FileType | get_file_type () const
| Gets a file's type (whether it is a regular file, symlink, etc).
bool | is_hidden () const
| Checks if a file is hidden.
bool | is_backup () const
| Checks if a file is a backup file.
bool | is_symlink () const
| Checks if a file is a symlink.
std::string | get_name () const
| Gets the name for a file.
std::string | get_display_name () const
| Gets a display name for a file.
std::string | get_edit_name () const
| Gets the edit name for a file.
Glib::RefPtr< Icon > | get_icon ()
| Gets the icon for a file.
Glib::RefPtr< const Icon > | get_icon () const
| Gets the icon for a file.
std::string | get_content_type () const
| Gets the file's content type.
goffset | get_size () const
| Gets the file's size.
Glib::TimeVal | modification_time () const
std::string | get_symlink_target () const
| Gets the symlink target for a given FileInfo.
std::string | get_etag () const
| Gets the <link linkend="gfile-etag">entity tag</link> for a given FileInfo.
gint32 | get_sort_order () const
| Gets the value of the sort_order attribute from the FileInfo.
void | set_attribute_mask (const Glib::RefPtr< FileAttributeMatcher >& mask)
| Sets mask on info to match specific attribute types.
void | unset_attribute_mask ()
| Unsets a mask set by g_file_info_set_attribute_mask(), if one is set.
void | set_file_type (FileType type)
| Sets the file type in a FileInfo to type.
void | set_is_hidden (bool is_hidden=true)
| Sets the "is_hidden" attribute in a FileInfo according to is_symlink.
void | set_is_symlink (bool is_symlink=true)
| Sets the "is_symlink" attribute in a FileInfo according to is_symlink.
void | set_name (const std::string& name)
| Sets the name attribute for the current FileInfo.
void | set_display_name (const std::string& display_name)
| Sets the display name for the current FileInfo.
void | set_edit_name (const std::string& edit_name)
| Sets the edit name for the current file.
void | set_icon (const Glib::RefPtr< Icon >& icon)
| Sets the icon for a given FileInfo.
void | set_content_type (const std::string& content_type)
| Sets the content type attribute for a given FileInfo.
void | set_size (goffset size)
| Sets the FILE_ATTRIBUTE_STANDARD_SIZE attribute in the file info to the given size.
void | set_modification_time (const Glib::TimeVal& mtime)
| Sets the FILE_ATTRIBUTE_TIME_MODIFIED attribute in the file info to the given time value.
void | set_symlink_target (const std::string& symlink_target)
| Sets the FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in the file info to the given symlink target.
void | set_sort_order (gint32 sort_order)
| Sets the sort order attribute in the file info structure.
## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::FileInfo > | wrap (GFileInfo* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

FileInfo implements methods for getting information that all files should contain, and allows for manipulation of extended attributes.

See FileAttribute for more information on how GIO handles file attributes.

To obtain a FileInfo for a File, use File::query_info() (or its async variant). To obtain a FileInfo for a file input or output stream, use FileInput::stream_query_info() or FileOutput::stream_query_info() (or their async variants).

FileAttributeMatcher allows for searching through a FileInfo for attributes.

## Constructor & Destructor Documentation

virtual Gio::FileInfo::~FileInfo | ( |  | ) | `[virtual]`

Gio::FileInfo::FileInfo | ( |  | ) |

## Member Function Documentation

void Gio::FileInfo::clear_status | ( |  | ) |

Clears the status information from info.

void Gio::FileInfo::copy_into | ( | Glib::RefPtr< FileInfo >& | dest | ) | const

Copies all of the FileAttributes from src_info to dest_info.

Parameters:

  | dest_info | Destination to copy attributes to.

Glib::RefPtr<FileInfo> Gio::FileInfo::dup | ( |  | ) | const

Duplicates a file info structure.

Returns:
  A duplicate FileInfo of other.

Glib::ustring Gio::FileInfo::get_attribute_as_string | ( | const std::string & | attribute | ) | const

Gets the value of a attribute, formated as a string.

This escapes things as needed to make the string valid utf8.

Parameters:

  | attribute | A file attribute key.

Returns:
  A UTF-8 string associated with the given attribute. When you're done with the string it must be freed with Glib::free().

bool Gio::FileInfo::get_attribute_boolean | ( | const std::string & | attribute | ) | const

Gets the value of a boolean attribute.

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

Parameters:

  | attribute | A file attribute key.

Returns:
  The boolean value contained within the attribute.

std::string Gio::FileInfo::get_attribute_byte_string | ( | const std::string & | attribute | ) | const

Gets the value of a byte string attribute.

If the attribute does not contain a byte string, `0` will be returned.

Parameters:

  | attribute | A file attribute key.

Returns:
  The contents of the attribute value as a byte string, or `0` otherwise.

gint32 Gio::FileInfo::get_attribute_int32 | ( | const std::string & | attribute | ) | const

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.

Parameters:

  | attribute | A file attribute key.

Returns:
  A signed 32-bit integer from the attribute.

gint64 Gio::FileInfo::get_attribute_int64 | ( | const std::string & | attribute | ) | const

Gets a signed 64-bit integer contained within the attribute.

If the attribute does not contain an signed 64-bit integer, or is invalid, 0 will be returned.

Parameters:

  | attribute | A file attribute key.

Returns:
  A signed 64-bit integer from the attribute.

Glib::RefPtr<Glib::Object> Gio::FileInfo::get_attribute_object | ( | const std::string & | attribute | ) | const

Gets the value of a Object attribute.

If the attribute does not contain a Object, `0` will be returned.

Parameters:

  | attribute | A file attribute key.

Returns:
  A Object associated with the given attribute, or `0` otherwise.

std::string Gio::FileInfo::get_attribute_string | ( | const std::string & | attribute | ) | const

Gets the value of a string attribute.

If the attribute does not contain a string, `0` will be returned.

Parameters:

  | attribute | A file attribute key.

Returns:
  The contents of the attribute value as a string, or `0` otherwise.

FileAttributeType Gio::FileInfo::get_attribute_type | ( | const std::string & | attribute | ) | const

Gets the attribute type for an attribute key.

Parameters:

  | attribute | A file attribute key.

Returns:
  A FileAttributeType for the given attribute, or FILE_ATTRIBUTE_TYPE_INVALID if the key is not set.

guint32 Gio::FileInfo::get_attribute_uint32 | ( | const std::string & | attribute | ) | const

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.

Parameters:

  | attribute | A file attribute key.

Returns:
  An unsigned 32-bit integer from the attribute.

guint64 Gio::FileInfo::get_attribute_uint64 | ( | const std::string & | attribute | ) | const

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.

Parameters:

  | attribute | A file attribute key.

Returns:
  A unsigned 64-bit integer from the attribute.

std::string Gio::FileInfo::get_content_type | ( |  | ) | const

Gets the file's content type.

Returns:
  A string containing the file's content type.

std::string Gio::FileInfo::get_display_name | ( |  | ) | const

Gets a display name for a file.

Returns:
  A string containing the display name.

std::string Gio::FileInfo::get_edit_name | ( |  | ) | const

Gets the edit name for a file.

Returns:
  A string containing the edit name.

std::string Gio::FileInfo::get_etag | ( |  | ) | const

Gets the <link linkend="gfile-etag">entity tag</link> for a given FileInfo.

See FILE_ATTRIBUTE_ETAG_VALUE.

Returns:
  A string containing the value of the "etag:value" attribute.

FileType Gio::FileInfo::get_file_type | ( |  | ) | const

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

Returns:
  A FileType for the given file.

Glib::RefPtr<const Icon> Gio::FileInfo::get_icon | ( |  | ) | const

Gets the icon for a file.

Returns:
  Icon for the given info.

Glib::RefPtr<Icon> Gio::FileInfo::get_icon | ( |  | ) |

Gets the icon for a file.

Returns:
  Icon for the given info.

std::string Gio::FileInfo::get_name | ( |  | ) | const

Gets the name for a file.

Returns:
  A string containing the file name.

goffset Gio::FileInfo::get_size | ( |  | ) | const

Gets the file's size.

Returns:
  A goffset containing the file's size.

gint32 Gio::FileInfo::get_sort_order | ( |  | ) | const

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.

std::string Gio::FileInfo::get_symlink_target | ( |  | ) | const

Gets the symlink target for a given FileInfo.

Returns:
  A string containing the symlink target.

const GFileInfo* Gio::FileInfo::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GFileInfo* Gio::FileInfo::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GFileInfo* Gio::FileInfo::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gio::FileInfo::has_attribute | ( | const std::string & | attribute | ) | const

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

Parameters:

  | attribute | A file attribute key.

Returns:
  `true` if Ginfo has an attribute named attribute, `false` otherwise.

bool Gio::FileInfo::is_backup | ( |  | ) | const

Checks if a file is a backup file.

Returns:
  `true` if file is a backup file, `false` otherwise.

bool Gio::FileInfo::is_hidden | ( |  | ) | const

Checks if a file is hidden.

Returns:
  `true` if the file is a hidden file, `false` otherwise.

bool Gio::FileInfo::is_symlink | ( |  | ) | const

Checks if a file is a symlink.

Returns:
  `true` if the given info is a symlink.

Glib::StringArrayHandle Gio::FileInfo::list_attributes | ( | const std::string & | name_space | ) | const

Lists the file info structure's attributes.

Parameters:

  | name_space | A file attribute key's namespace.

Returns:
  A null-terminated array of strings of all of the possible attribute types for the given name_space, or `0` on error.

Glib::TimeVal Gio::FileInfo::modification_time | ( |  | ) | const

void Gio::FileInfo::remove_attribute | ( | const std::string & | attribute | ) |

Removes all cases of attribute from info if it exists.

Parameters:

  | attribute | A file attribute key.

void Gio::FileInfo::set_attribute_boolean | ( | const std::string & | attribute,
|  | bool | value |
| ) |  |  |

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

Parameters:

  | attribute | A file attribute key.
  | attr_value | A boolean value.

void Gio::FileInfo::set_attribute_byte_string | ( | const std::string & | attribute,
|  | const std::string & | value |
| ) |  |  |

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

Parameters:

  | attribute | A file attribute key.
  | attr_value | A byte string.

void Gio::FileInfo::set_attribute_int32 | ( | const std::string & | attribute,
|  | gint32 | value |
| ) |  |  |

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

Parameters:

  | attribute | A file attribute key.
  | attr_value | A signed 32-bit integer.

void Gio::FileInfo::set_attribute_int64 | ( | const std::string & | attribute,
|  | gint64 | value |
| ) |  |  |

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

Parameters:

  | attribute | Attribute name to set.
  | attr_value | Int64 value to set attribute to.

void Gio::FileInfo::set_attribute_mask | ( | const Glib::RefPtr< FileAttributeMatcher >& | mask | ) |

Sets mask on info to match specific attribute types.

Parameters:

  | mask | A FileAttributeMatcher.

void Gio::FileInfo::set_attribute_object | ( | const std::string & | attribute,
|  | const Glib::RefPtr< Glib::Object >& | object |
| ) |  |  |

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

Parameters:

  | attribute | A file attribute key.
  | attr_value | A Object.

void Gio::FileInfo::set_attribute_string | ( | const std::string & | attribute,
|  | const std::string & | value |
| ) |  |  |

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

Parameters:

  | attribute | A file attribute key.
  | attr_value | A string.

void Gio::FileInfo::set_attribute_uint32 | ( | const std::string & | attribute,
|  | guint32 | value |
| ) |  |  |

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

Parameters:

  | attribute | A file attribute key.
  | attr_value | An unsigned 32-bit integer.

void Gio::FileInfo::set_attribute_uint64 | ( | const std::string & | attribute,
|  | guint64 | value |
| ) |  |  |

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

Parameters:

  | attribute | A file attribute key.
  | attr_value | An unsigned 64-bit integer.

void Gio::FileInfo::set_content_type | ( | const std::string & | content_type | ) |

Sets the content type attribute for a given FileInfo.

See FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.

Parameters:

  | content_type | A content type. See ContentType.

void Gio::FileInfo::set_display_name | ( | const std::string & | display_name | ) |

Sets the display name for the current FileInfo.

See FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.

Parameters:

  | display_name | A string containing a display name.

void Gio::FileInfo::set_edit_name | ( | const std::string & | edit_name | ) |

Sets the edit name for the current file.

See FILE_ATTRIBUTE_STANDARD_EDIT_NAME.

Parameters:

  | edit_name | A string containing an edit name.

void Gio::FileInfo::set_file_type | ( | FileType | type | ) |

Sets the file type in a FileInfo to type.

See FILE_ATTRIBUTE_STANDARD_TYPE.

Parameters:

  | type | A FileType.

void Gio::FileInfo::set_icon | ( | const Glib::RefPtr< Icon >& | icon | ) |

Sets the icon for a given FileInfo.

See FILE_ATTRIBUTE_STANDARD_ICON.

Parameters:

  | icon | A Icon.

void Gio::FileInfo::set_is_hidden | ( | bool | is_hidden = `true` | ) |

Sets the "is_hidden" attribute in a FileInfo according to is_symlink.

See FILE_ATTRIBUTE_STANDARD_IS_HIDDEN.

Parameters:

  | is_hidden | A `bool`.

void Gio::FileInfo::set_is_symlink | ( | bool | is_symlink = `true` | ) |

Sets the "is_symlink" attribute in a FileInfo according to is_symlink.

See FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.

Parameters:

  | is_symlink | A `bool`.

void Gio::FileInfo::set_modification_time | ( | const Glib::TimeVal& | mtime | ) |

Sets the FILE_ATTRIBUTE_TIME_MODIFIED attribute in the file info to the given time value.

Parameters:

  | mtime | A TimeVal.

void Gio::FileInfo::set_name | ( | const std::string & | name | ) |

Sets the name attribute for the current FileInfo.

See FILE_ATTRIBUTE_STANDARD_NAME.

Parameters:

  | name | A string containing a name.

void Gio::FileInfo::set_size | ( | goffset | size | ) |

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

Parameters:

  | size | A goffset containing the file's size.

void Gio::FileInfo::set_sort_order | ( | gint32 | sort_order | ) |

Sets the sort order attribute in the file info structure.

See FILE_ATTRIBUTE_STANDARD_SORT_ORDER.

Parameters:

  | sort_order | A sort order integer.

void Gio::FileInfo::set_symlink_target | ( | const std::string & | symlink_target | ) |

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

Parameters:

  | symlink_target | A static string containing a path to a symlink target.

void Gio::FileInfo::unset_attribute_mask | ( |  | ) |

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

## Friends And Related Function Documentation

Glib::RefPtr< Gio::FileInfo > wrap | ( | GFileInfo * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.