Gio::File Class Reference

File and directory handling. More...

`#include <giomm/file.h>`

Inheritance diagram for Gio::File:
[legend]

## Public Types

using | SlotFileProgress = sigc::slot< void, goffset, goffset >
| A signal handler would be, for instance: void on_file_progress(goffset current_num_bytes, goffset total_num_bytes);. More...
using | SlotFileMeasureProgress = sigc::slot< void, bool, guint64, guint64, guint64 >
| This slot type is used by measure_disk_usage() to make periodic progress reports when measuring the amount of disk spaced used by a directory. More...
using | SlotReadMore = sigc::slot< bool, const char*, goffset >
| A signal handler would be, for instance: bool on_read_more(const char* file_contents, goffset file_size);. More...
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## Public Member Functions

| File (File&& src) noexcept
File& | operator= (File&& src) noexcept
| ~File () noexcept override
GFile* | gobj ()
| Provides access to the underlying C GObject. More...
const GFile* | gobj () const
| Provides access to the underlying C GObject. More...
Glib::RefPtr< File > | dup () const
| Duplicates a File handle. More...
guint | hash () const
| Creates a hash value for a File. More...
bool | equal (const Glib::RefPtr< const File >& other) const
| Checks equality of two given Files. More...
std::string | get_basename () const
| Gets the base name (the last component of the path) for a given File. More...
std::string | get_path () const
| Gets the local pathname for File, if one exists. More...
std::string | get_uri () const
| Gets the URI for the file. More...
Glib::ustring | get_parse_name () const
| Gets the parse name of the file. More...
Glib::RefPtr< File > | get_parent () const
| Gets the parent directory for the file. More...
bool | has_parent (const Glib::RefPtr< File >& parent) const
| Checks if file has a parent, and optionally, if it is parent. More...
bool | has_parent () const
| Checks if the file has any parent at all. More...
Glib::RefPtr< File > | get_child (const std::string& name) const
| Gets a child of file with basename equal to name. More...
Glib::RefPtr< File > | get_child_for_display_name (const Glib::ustring& display_name) const
| Gets the child of file for a given display_name (i.e. a UTF-8 version of the name). More...
bool | has_prefix (const Glib::RefPtr< const File >& prefix) const
| Checks whether file has the prefix specified by prefix. More...
std::string | get_relative_path (const Glib::RefPtr< const File >& descendant) const
| Gets the path for descendant relative to parent. More...
Glib::RefPtr< File > | resolve_relative_path (const std::string& relative_path) const
| Resolves a relative path for file to an absolute path. More...
bool | is_native () const
| Checks to see if a file is native to the platform. More...
bool | has_uri_scheme (const std::string& uri_scheme) const
| Checks to see if a File has a given URI scheme. More...
std::string | get_uri_scheme () const
| Gets the URI scheme for a File. More...
Glib::RefPtr< FileInputStream > | read (const Glib::RefPtr< Cancellable >& cancellable)
| Opens a file for reading. More...
Glib::RefPtr< FileInputStream > | read ()
| A read() convenience overload. More...
void | read_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously opens the file for reading. More...
void | read_async (const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously opens the file for reading. More...
Glib::RefPtr< FileInputStream > | read_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous file read operation started with g_file_read_async(). More...
Glib::RefPtr< FileOutputStream > | append_to (const Glib::RefPtr< Cancellable >& cancellable, FileCreateFlags flags=FILE_CREATE_NONE)
| Gets an output stream for appending data to the file. More...
Glib::RefPtr< FileOutputStream > | append_to (FileCreateFlags flags=FILE_CREATE_NONE)
| Gets an output stream for appending data to the file. More...
Glib::RefPtr< FileOutputStream > | create_file (const Glib::RefPtr< Cancellable >& cancellable, FileCreateFlags flags=FILE_CREATE_NONE)
| Creates a new file and returns an output stream for writing to it. More...
Glib::RefPtr< FileOutputStream > | create_file (FileCreateFlags flags=FILE_CREATE_NONE)
| Creates a new file and returns an output stream for writing to it. More...
Glib::RefPtr< FileIOStream > | create_file_readwrite (const Glib::RefPtr< Cancellable >& cancellable, FileCreateFlags flags=FILE_CREATE_NONE)
| Creates a new file and returns a stream for reading and writing to it. More...
Glib::RefPtr< FileIOStream > | create_file_readwrite (FileCreateFlags flags=FILE_CREATE_NONE)
| Creates a new file and returns a stream for reading and writing to it. More...
Glib::RefPtr< FileOutputStream > | replace (const Glib::RefPtr< Cancellable >& cancellable, const std::string& etag=std::string(), bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Returns an output stream for overwriting the file, possibly creating a backup copy of the file first. More...
Glib::RefPtr< FileOutputStream > | replace (const std::string& etag=std::string(), bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Returns an output stream for overwriting the file, possibly creating a backup copy of the file first. More...
void | append_to_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously opens the file for appending. More...
void | append_to_async (const SlotAsyncReady& slot, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously opens the file for appending. More...
Glib::RefPtr< FileOutputStream > | append_to_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous file append operation started with g_file_append_to_async(). More...
void | create_file_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously creates a new file and returns an output stream for writing to it. More...
void | create_file_async (const SlotAsyncReady& slot, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously creates a new file and returns an output stream for writing to it. More...
Glib::RefPtr< FileOutputStream > | create_file_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous file create operation started with g_file_create_async(). More...
void | create_file_readwrite_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously creates a new file and returns a stream for reading and writing to it. More...
void | create_file_readwrite_async (const SlotAsyncReady& slot, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously creates a new file and returns a stream for reading and writing to it. More...
Glib::RefPtr< FileIOStream > | create_file_readwrite_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous file create operation started with g_file_create_readwrite_async(). More...
void | replace_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const std::string& etag=std::string(), bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first. More...
void | replace_async (const SlotAsyncReady& slot, const std::string& etag=std::string(), bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first. More...
Glib::RefPtr< FileOutputStream > | replace_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous file replace operation started with g_file_replace_async(). More...
Glib::RefPtr< FileIOStream > | open_readwrite (const Glib::RefPtr< Cancellable >& cancellable)
| Opens an existing file for reading and writing. More...
Glib::RefPtr< FileIOStream > | open_readwrite ()
| A open_readwrite() convenience overload. More...
void | open_readwrite_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Opens an existing file for reading and writing. More...
void | open_readwrite_async (const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Opens an existing file for reading and writing. More...
Glib::RefPtr< FileIOStream > | open_readwrite_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous file read operation started with g_file_open_readwrite_async(). More...
Glib::RefPtr< FileIOStream > | replace_readwrite (const Glib::RefPtr< Cancellable >& cancellable, const std::string& etag=std::string(), bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first. More...
Glib::RefPtr< FileIOStream > | replace_readwrite (const std::string& etag=std::string(), bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first. More...
void | replace_readwrite_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const std::string& etag=std::string(), bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asyncronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first. More...
void | replace_readwrite_async (const SlotAsyncReady& slot, const std::string& etag=std::string(), bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asyncronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first. More...
Glib::RefPtr< FileIOStream > | replace_readwrite_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous file replace operation started with g_file_replace_readwrite_async(). More...
Glib::RefPtr< FileInfo > | query_info (const Glib::RefPtr< Cancellable >& cancellable, const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE) const
| Gets the requested information about the file. More...
Glib::RefPtr< FileInfo > | query_info (const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE) const
| Gets the requested information about the file. More...
bool | query_exists (const Glib::RefPtr< Cancellable >& cancellable) const
| Utility function to check if a particular file exists. More...
bool | query_exists () const
| A query_exists() convenience overload. More...
FileType | query_file_type (FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable) const
| Utility function to inspect the FileType of a file. More...
FileType | query_file_type (FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE) const
| Utility function to inspect the FileType of a file. More...
void | query_info_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE, int io_priority=Glib::PRIORITY_DEFAULT) const
| Asynchronously gets the requested information about specified file. More...
void | query_info_async (const SlotAsyncReady& slot, const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE, int io_priority=Glib::PRIORITY_DEFAULT) const
| Asynchronously gets the requested information about specified file. More...
Glib::RefPtr< FileInfo > | query_info_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous file info query. More...
Glib::RefPtr< FileInfo > | query_filesystem_info (const Glib::RefPtr< Cancellable >& cancellable, const std::string& attributes="*")
| Similar to query_info(), but obtains information about the filesystem the file is on, rather than the file itself. More...
Glib::RefPtr< FileInfo > | query_filesystem_info (const std::string& attributes="*")
| Similar to query_info(), but obtains information about the filesystem the file is on, rather than the file itself. More...
Glib::RefPtr< Mount > | find_enclosing_mount (const Glib::RefPtr< Cancellable >& cancellable)
| Gets a Mount for the File. More...
Glib::RefPtr< Mount > | find_enclosing_mount ()
| A find_enclosing_mount() convenience overload. More...
void | query_filesystem_info_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const std::string& attributes="*", int io_priority=Glib::PRIORITY_DEFAULT) const
| Asynchronously gets the requested information about the filesystem that the file is on. More...
void | query_filesystem_info_async (const SlotAsyncReady& slot, const std::string& attributes="*", int io_priority=Glib::PRIORITY_DEFAULT) const
| Asynchronously gets the requested information about the filesystem that the file is on. More...
Glib::RefPtr< FileInfo > | query_filesystem_info_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous filesystem info query. More...
void | find_enclosing_mount_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously gets the mount for the file. More...
void | find_enclosing_mount_async (const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously gets the mount for the file. More...
Glib::RefPtr< Mount > | find_enclosing_mount_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an asynchronous find mount request. More...
Glib::RefPtr< FileEnumerator > | enumerate_children (const Glib::RefPtr< Cancellable >& cancellable, const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE)
| Gets the requested information about the files in a directory. More...
Glib::RefPtr< FileEnumerator > | enumerate_children (const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE)
| Gets the requested information about the files in a directory. More...
void | enumerate_children_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously gets the requested information about the files in a directory. More...
void | enumerate_children_async (const SlotAsyncReady& slot, const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously gets the requested information about the files in a directory. More...
Glib::RefPtr< FileEnumerator > | enumerate_children_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an async enumerate children operation. More...
Glib::RefPtr< File > | set_display_name (const Glib::ustring& display_name, const Glib::RefPtr< Cancellable >& cancellable)
| Renames file to the specified display name. More...
Glib::RefPtr< File > | set_display_name (const Glib::ustring& display_name)
| A set_display_name() convenience overload. More...
void | set_display_name_async (const Glib::ustring& display_name, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously sets the display name for a given Gio::File. More...
void | set_display_name_async (const Glib::ustring& display_name, const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously sets the display name for a given Gio::File. More...
Glib::RefPtr< File > | set_display_name_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes setting a display name started with g_file_set_display_name_async(). More...
bool | remove (const Glib::RefPtr< Cancellable >& cancellable)
| Deletes a file. More...
bool | remove ()
| A remove() convenience overload. More...
void | remove_async (const SlotAsyncReady& slot_ready, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously delete a file. More...
void | remove_async (const SlotAsyncReady& slot_ready, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously delete a file. More...
bool | remove_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes deleting a file started with g_file_delete_async(). More...
bool | trash (const Glib::RefPtr< Cancellable >& cancellable)
| Sends file to the "Trashcan", if possible. More...
bool | trash ()
| A trash() convenience overload. More...
void | trash_async (const SlotAsyncReady& slot_ready, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously sends the file to the Trash location, if possible. More...
void | trash_async (const SlotAsyncReady& slot_ready, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously sends the file to the Trash location, if possible. More...
bool | trash_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous file trashing operation, started with g_file_trash_async(). More...
bool | copy (const Glib::RefPtr< File >& destination, const SlotFileProgress& slot, const Glib::RefPtr< Cancellable >& cancellable, FileCopyFlags flags=FILE_COPY_NONE)
| Copies the file source to the location specified by destination. More...
bool | copy (const Glib::RefPtr< File >& destination, const SlotFileProgress& slot, FileCopyFlags flags=FILE_COPY_NONE)
| Copies the file source to the location specified by destination. More...
bool | copy (const Glib::RefPtr< File >& destination, FileCopyFlags flags=FILE_COPY_NONE)
| Copies the file source to the location specified by destination. More...
void | copy_async (const Glib::RefPtr< File >& destination, const SlotFileProgress& slot_progress, const SlotAsyncReady& slot_ready, const Glib::RefPtr< Cancellable >& cancellable, FileCopyFlags flags=FILE_COPY_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Copies the file to the location specified by destination asynchronously. More...
void | copy_async (const Glib::RefPtr< File >& destination, const SlotAsyncReady& slot_ready, const Glib::RefPtr< Cancellable >& cancellable, FileCopyFlags flags=FILE_COPY_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Copies the file to the location specified by destination asynchronously. More...
void | copy_async (const Glib::RefPtr< File >& destination, const SlotFileProgress& slot_progress, const SlotAsyncReady& slot_ready, FileCopyFlags flags=FILE_COPY_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Copies the file to the location specified by destination asynchronously. More...
void | copy_async (const Glib::RefPtr< File >& destination, const SlotAsyncReady& slot_ready, FileCopyFlags flags=FILE_COPY_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Copies the file to the location specified by destination asynchronously. More...
bool | copy_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes copying the file started with g_file_copy_async(). More...
bool | move (const Glib::RefPtr< File >& destination, const SlotFileProgress& slot, const Glib::RefPtr< Cancellable >& cancellable, FileCopyFlags flags=FILE_COPY_NONE)
| Tries to move the file or directory source to the location specified by destination. More...
bool | move (const Glib::RefPtr< File >& destination, const SlotFileProgress& slot, FileCopyFlags flags=FILE_COPY_NONE)
bool | move (const Glib::RefPtr< File >& destination, FileCopyFlags flags=FILE_COPY_NONE)
bool | make_directory (const Glib::RefPtr< Cancellable >& cancellable)
| Creates a directory. More...
bool | make_directory ()
| A make_directory() convenience overload. More...
void | make_directory_async (const SlotAsyncReady& slot_ready, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously creates a directory. More...
void | make_directory_async (const SlotAsyncReady& slot_ready, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously creates a directory. More...
bool | make_directory_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous directory creation, started with g_file_make_directory_async(). More...
bool | make_directory_with_parents (const Glib::RefPtr< Cancellable >& cancellable)
| Creates a directory and any parent directories that may not exist similar to 'mkdir -p'. More...
bool | make_directory_with_parents ()
| A make_directory_with_parents() convenience overload. More...
bool | make_symbolic_link (const std::string& symlink_value, const Glib::RefPtr< Cancellable >& cancellable)
| Creates a symbolic link. More...
bool | make_symbolic_link (const std::string& symlink_value)
| A make_symbolic_link() convenience overload. More...
Glib::RefPtr< FileAttributeInfoList > | query_settable_attributes (const Glib::RefPtr< Cancellable >& cancellable)
| Obtain the list of settable attributes for the file. More...
Glib::RefPtr< FileAttributeInfoList > | query_settable_attributes ()
| A query_settable_attributes() convenience overload. More...
Glib::RefPtr< FileAttributeInfoList > | query_writable_namespaces (const Glib::RefPtr< Cancellable >& cancellable)
| Obtain the list of attribute namespaces where new attributes can be created by a user. More...
Glib::RefPtr< FileAttributeInfoList > | query_writable_namespaces ()
| A query_writable_namespaces() convenience overload. More...
bool | set_attributes_from_info (const Glib::RefPtr< FileInfo >& info, const Glib::RefPtr< Cancellable >& cancellable, FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE)
| Tries to set all attributes in the FileInfo on the target values, not stopping on the first error. More...
bool | set_attributes_from_info (const Glib::RefPtr< FileInfo >& info, FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE)
| Tries to set all attributes in the FileInfo on the target values, not stopping on the first error. More...
void | set_attributes_async (const Glib::RefPtr< FileInfo >& info, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously sets the attributes of file with info. More...
void | set_attributes_async (const Glib::RefPtr< FileInfo >& info, const SlotAsyncReady& slot, FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously sets the attributes of file with info. More...
bool | set_attributes_finish (const Glib::RefPtr< AsyncResult >& result, const Glib::RefPtr< FileInfo >& info)
bool | set_attribute_string (const std::string& attribute, const std::string& value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type G_FILE_ATTRIBUTE_TYPE_STRING to value. More...
bool | set_attribute_string (const std::string& attribute, const std::string& value, FileQueryInfoFlags flags)
| A set_attribute_string() convenience overload. More...
bool | set_attribute_byte_string (const std::string& attribute, const std::string& value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to value. More...
bool | set_attribute_byte_string (const std::string& attribute, const std::string& value, FileQueryInfoFlags flags)
| A set_attribute_byte_string() convenience overload. More...
bool | set_attribute_uint32 (const std::string& attribute, guint32 value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type G_FILE_ATTRIBUTE_TYPE_UINT32 to value. More...
bool | set_attribute_uint32 (const std::string& attribute, guint32 value, FileQueryInfoFlags flags)
| A set_attribute_uint32() convenience overload. More...
bool | set_attribute_int32 (const std::string& attribute, gint32 value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type G_FILE_ATTRIBUTE_TYPE_INT32 to value. More...
bool | set_attribute_int32 (const std::string& attribute, gint32 value, FileQueryInfoFlags flags)
| A set_attribute_int32() convenience overload. More...
bool | set_attribute_uint64 (const std::string& attribute, guint64 value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type G_FILE_ATTRIBUTE_TYPE_UINT64 to value. More...
bool | set_attribute_uint64 (const std::string& attribute, guint64 value, FileQueryInfoFlags flags)
| A set_attribute_uint64() convenience overload. More...
bool | set_attribute_int64 (const std::string& attribute, gint64 value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type G_FILE_ATTRIBUTE_TYPE_INT64 to value. More...
bool | set_attribute_int64 (const std::string& attribute, gint64 value, FileQueryInfoFlags flags)
| A set_attribute_int64() convenience overload. More...
void | mount_enclosing_volume (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, MountMountFlags flags=MOUNT_MOUNT_NONE)
| Starts a mount_operation, mounting the volume that contains the file. More...
void | mount_enclosing_volume (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, MountMountFlags flags=MOUNT_MOUNT_NONE)
| Starts a mount_operation, mounting the volume that contains the file. More...
void | mount_enclosing_volume (const SlotAsyncReady& slot, MountMountFlags flags=MOUNT_MOUNT_NONE)
| Starts a mount_operation, mounting the volume that contains the file. More...
void | mount_enclosing_volume (MountMountFlags flags=MOUNT_MOUNT_NONE)
| Starts a mount_operation, mounting the volume that contains the file. More...
bool | mount_enclosing_volume_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes a mount operation started by g_file_mount_enclosing_volume(). More...
void | mount_mountable (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, MountMountFlags flags=MOUNT_MOUNT_NONE)
| Mounts a file of type FILE_TYPE_MOUNTABLE. More...
void | mount_mountable (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, MountMountFlags flags=MOUNT_MOUNT_NONE)
| Mounts a file of type FILE_TYPE_MOUNTABLE. More...
void | mount_mountable (const SlotAsyncReady& slot, MountMountFlags flags=MOUNT_MOUNT_NONE)
| Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction. More...
void | mount_mountable (MountMountFlags flags=MOUNT_MOUNT_NONE)
| Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction. More...
Glib::RefPtr< File > | mount_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes a mount operation. More...
void | unmount_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE. More...
void | unmount_mountable (const SlotAsyncReady& slot, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE. More...
void | unmount_mountable (MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE. More...
void | unmount_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const Glib::RefPtr< MountOperation >& mount_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE. More...
void | unmount_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< MountOperation >& mount_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE. More...
void | unmount_mountable (const Glib::RefPtr< MountOperation >& mount_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE. More...
bool | unmount_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an unmount operation, see g_file_unmount_mountable_with_operation() for details. More...
void | eject_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable. More...
void | eject_mountable (const SlotAsyncReady& slot, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable. More...
void | eject_mountable (MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable. More...
void | eject_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const Glib::RefPtr< MountOperation >& mount_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable. More...
void | eject_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< MountOperation >& mount_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable. More...
void | eject_mountable (const Glib::RefPtr< MountOperation >& mount_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable. More...
bool | eject_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous eject operation started by g_file_eject_mountable_with_operation(). More...
bool | copy_attributes (const Glib::RefPtr< File >& destination, const Glib::RefPtr< Cancellable >& cancellable, FileCopyFlags flags=FILE_COPY_NONE)
| Copies the file attributes from source to destination. More...
bool | copy_attributes (const Glib::RefPtr< File >& destination, FileCopyFlags flags=FILE_COPY_NONE)
| Copies the file attributes from source to destination. More...
Glib::RefPtr< FileMonitor > | monitor_directory (const Glib::RefPtr< Cancellable >& cancellable, FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a directory monitor for the given file. More...
Glib::RefPtr< FileMonitor > | monitor_directory (FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a directory monitor for the given file. More...
Glib::RefPtr< FileMonitor > | monitor_file (const Glib::RefPtr< Cancellable >& cancellable, FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a file monitor for the given file. More...
Glib::RefPtr< FileMonitor > | monitor_file (FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a file monitor for the given file. More...
Glib::RefPtr< FileMonitor > | monitor (const Glib::RefPtr< Cancellable >& cancellable, FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a file monitor for the given file. More...
Glib::RefPtr< FileMonitor > | monitor (FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a file monitor for the given file. More...
void | measure_disk_usage (const Glib::RefPtr< Cancellable >& cancellable, const SlotFileMeasureProgress& slot_progress, guint64& disk_usage, guint64& num_dirs, guint64& num_files, FileMeasureFlags flags=FILE_MEASURE_NONE)
| Recursively measures the disk usage of the file. More...
void | measure_disk_usage_async (const SlotAsyncReady& slot_ready, const Glib::RefPtr< Cancellable >& cancellable, const SlotFileMeasureProgress& slot_progress, FileMeasureFlags flags=FILE_MEASURE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Recursively measures the disk usage of the file. More...
bool | measure_disk_usage_finish (const Glib::RefPtr< AsyncResult >& result, guint64& disk_usage, guint64& num_dirs, guint64& num_files)
| Collects the results from an earlier call to g_file_measure_disk_usage_async(). More...
void | start_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const Glib::RefPtr< MountOperation >& start_operation, DriveStartFlags flags=DRIVE_START_NONE)
| Starts a file of type Mountable. More...
void | start_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< MountOperation >& start_operation, DriveStartFlags flags=DRIVE_START_NONE)
| Starts a file of type Mountable. More...
bool | start_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes a start operation. More...
void | stop_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const Glib::RefPtr< MountOperation >& start_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Stops a file of type Mountable. More...
void | stop_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< MountOperation >& start_operation, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Stops a file of type Mountable. More...
bool | stop_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an stop operation, see g_file_stop_mountable() for details. More...
void | poll_mountable (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Polls a file of type Mountable. More...
void | poll_mountable (const SlotAsyncReady& slot)
| Polls a file of type Mountable. More...
bool | poll_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes a poll operation. More...
Glib::RefPtr< AppInfo > | query_default_handler (const Glib::RefPtr< Cancellable >& cancellable)
| Returns the AppInfo that is registered as the default application to handle the file specified by file. More...
Glib::RefPtr< AppInfo > | query_default_handler ()
| A query_default_handler() convenience overload. More...
bool | load_contents (const Glib::RefPtr< Cancellable >& cancellable, char*& contents, gsize& length, std::string& etag_out)
| Loads the content of the file into memory, returning the size of the data. More...
bool | load_contents (const Glib::RefPtr< Cancellable >& cancellable, char*& contents, gsize& length)
| Loads the content of the file into memory, returning the size of the data. More...
bool | load_contents (char*& contents, gsize& length, std::string& etag_out)
| Loads the content of the file into memory, returning the size of the data. More...
bool | load_contents (char*& contents, gsize& length)
| Loads the content of the file into memory, returning the size of the data. More...
void | load_contents_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Starts an asynchronous load of the file's contents. More...
void | load_contents_async (const SlotAsyncReady& slot)
| Starts an asynchronous load of the file's contents. More...
bool | load_contents_finish (const Glib::RefPtr< AsyncResult >& result, char*& contents, gsize& length, std::string& etag_out)
| Finishes an asynchronous load of the file's contents. More...
bool | load_contents_finish (const Glib::RefPtr< AsyncResult >& result, char*& contents, gsize& length)
| Finishes an asynchronous load of the file's contents. More...
void | load_partial_contents_async (const SlotReadMore& slot_read_more, const SlotAsyncReady& slot_async_ready, const Glib::RefPtr< Cancellable >& cancellable)
| Reads the partial contents of a file. More...
void | load_partial_contents_async (const SlotReadMore& slot_read_more, const SlotAsyncReady& slot_async_ready)
| Reads the partial contents of a file. More...
bool | load_partial_contents_finish (const Glib::RefPtr< AsyncResult >& result, char*& contents, gsize& length, std::string& etag_out)
| Finishes an asynchronous partial load operation that was started with load_partial_contents_async(). More...
bool | load_partial_contents_finish (const Glib::RefPtr< AsyncResult >& result, char*& contents, gsize& length)
| Finishes an asynchronous partial load operation that was started with load_partial_contents_async(). More...
void | replace_contents (const char* contents, gsize length, const std::string& etag, std::string& new_etag, const Glib::RefPtr< Cancellable >& cancellable, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Replaces the contents of the file with contents of length bytes. More...
void | replace_contents (const char* contents, gsize length, const std::string& etag, std::string& new_etag, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Replaces the contents of the file with contents of length bytes. More...
void | replace_contents (const std::string& contents, const std::string& etag, std::string& new_etag, const Glib::RefPtr< Cancellable >& cancellable, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Replaces the contents of the file with contents. More...
void | replace_contents (const std::string& contents, const std::string& etag, std::string& new_etag, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Replaces the contents of the file with contents. More...
void | replace_contents_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const char* contents, gsize length, const std::string& etag, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Starts an asynchronous replacement of the file with the given contents of length bytes. More...
void | replace_contents_async (const SlotAsyncReady& slot, const char* contents, gsize length, const std::string& etag, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Starts an asynchronous replacement of the file with the given contents of length bytes. More...
void | replace_contents_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const std::string& contents, const std::string& etag, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Starts an asynchronous replacement of the file with the given contents of length bytes. More...
void | replace_contents_async (const SlotAsyncReady& slot, const std::string& contents, const std::string& etag, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Starts an asynchronous replacement of the file with the given contents. More...
void | replace_contents_finish (const Glib::RefPtr< AsyncResult >& result, std::string& new_etag)
| Finishes an asynchronous replace of the given file . More...
void | replace_contents_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous replace of the given file . More...
void | replace_contents_bytes_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const Glib::RefPtr< const Glib::Bytes >& contents, const std::string& etag, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Same as replace_contents_async() but takes a Gio::Bytes input instead. More...
void | replace_contents_bytes_async (const SlotAsyncReady& slot, const Glib::RefPtr< const Glib::Bytes >& contents, const std::string& etag, bool make_backup=false, FileCreateFlags flags=FILE_CREATE_NONE)
| Same as replace_contents_async() but takes a Gio::Bytes input instead. More...
bool | supports_thread_contexts () const
| Checks if file supports [thread-default contexts][g-main-context-push-thread-default-context]. More...
Public Member Functions inherited from Glib::Interface
| Interface ()
| A Default constructor. More...
| Interface (Interface&& src) noexcept
Interface& | operator= (Interface&& src) noexcept
| Interface (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes. More...
| Interface (GObject* castitem)
| Called by constructors of derived classes. More...
| ~Interface () noexcept override
| Interface (const Interface&)=delete
Interface& | operator= (const Interface&)=delete
GObject* | gobj ()
const GObject* | gobj () const
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase&)=delete
ObjectBase& | operator= (const ObjectBase&)=delete
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | connect_property_changed (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const

## Static Public Member Functions

static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr< File > | create_for_path (const std::string& path)
| Constructs a File for a given path. More...
static Glib::RefPtr< File > | create_for_uri (const std::string& uri)
| Constructs a File for a given URI. More...
static Glib::RefPtr< File > | create_for_commandline_arg (const std::string&arg)
| Constructs a File for a given argument from the command line. More...
static Glib::RefPtr< File > | create_for_parse_name (const Glib::ustring& parse_name)

## Protected Member Functions

| File ()
| You should derive from this class to use it. More...
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
| ObjectBase (ObjectBase&& src) noexcept
ObjectBase& | operator= (ObjectBase&& src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject* castitem)
void | initialize_move (GObject* castitem, Glib::ObjectBase* previous_wrapper)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gio::File > | wrap (GFile* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

File and directory handling.

Gio::File is a high level abstraction for manipulating files on a virtual file system. Gio::Files are lightweight, immutable objects that do no I/O upon creation. It is necessary to understand that a Gio::File object does not represent a file, merely a handle to a file. All file I/O is implemented as streaming operations (see Gio::InputStream and Gio::OutputStream).

A GioFile can be constructed from a path, URI, or a command line argument.

You can move through the filesystem with Gio::File handles with get_parent() to get a handle to the parent directory, get_child() to get a handle to a child within a directory, and resolve_relative_path() to resolve a relative path between two Gio::Files.

Many Gio::File operations have both synchronous and asynchronous versions to suit your application. Asynchronous versions of synchronous functions simply have _async() appended to their function names. The asynchronous I/O functions call a SlotAsyncReady callback slot which is then used to finalize the operation, producing a AsyncResult which is then passed to the function's matching _finish() operation.

Some Gio::File operations do not have synchronous analogs, as they may take a very long time to finish, and blocking may leave an application unusable. Notable cases include: mount_mountable() to mount a mountable file, unmount_mountable() to unmount a mountable file, and eject_mountable() to eject a mountable file.

One notable feature of Gio::Files are entity tags, or "etags" for short. Entity tags are somewhat like a more abstract version of the traditional mtime, and can be used to quickly determine if the file has been modified from the version on the file system. See the HTTP 1.1 specification for HTTP Etag headers, which are a very similar concept.

Since glibmm 2.16:

## Member Typedef Documentation

## SlotFileMeasureProgress

using Gio::File::SlotFileMeasureProgress = sigc::slot<void, bool, guint64, guint64, guint64>

This slot type is used by measure_disk_usage() to make periodic progress reports when measuring the amount of disk spaced used by a directory.

These calls are made on a best-effort basis and not all types of GFile will support them. At the minimum, however, one call will always be made immediately.

In the case that there is no support, reporting will be set to false (and the other values undefined) and no further calls will be made. Otherwise, the reporting will be true and the other values all-zeros during the first (immediate) call. In this way, you can know which type of progress UI to show without a delay.

For measure_disk_usage() the callback is made directly. For measure_disk_usage_async() the callback is made via the default main context of the calling thread (ie: the same way that the final async result would be reported).

current_size is in the same units as requested by the operation (see FILE_DISK_USAGE_APPARENT_SIZE).

The frequency of the updates is implementation defined, but is ideally about once every 200ms.

The last progress callback may or may not be equal to the final result. Always check the async result to get the final value.

For instance, void on_file_measure_progress(bool reporting, guint64 current_size, guint64 num_dirs, guint64 num_files);

Parameters

  reporting | true if more reports will come.
  current_size | The current cumulative size measurement.
  num_dirs | The number of directories visited so far.
  num_files | The number of non-directory files encountered.

Since glibmm 2.38:

## SlotFileProgress

using Gio::File::SlotFileProgress = sigc::slot<void, goffset, goffset>

A signal handler would be, for instance: void on_file_progress(goffset current_num_bytes, goffset total_num_bytes);.

## SlotReadMore

using Gio::File::SlotReadMore = sigc::slot<bool, const char*, goffset>

A signal handler would be, for instance: bool on_read_more(const char* file_contents, goffset file_size);.

## Constructor & Destructor Documentation

## File() [1/2]

Gio::File::File | ( |  | ) |

protected

You should derive from this class to use it.

## File() [2/2]

Gio::File::File | ( | File&& | src | ) |

noexcept

## ~File()

Gio::File::~File | ( |  | ) |

override noexcept

## Member Function Documentation

## add_interface()

static void Gio::File::add_interface | ( | GType | gtype_implementer | ) |

static

## append_to() [1/2]

Glib::RefPtr<FileOutputStream> Gio::File::append_to | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Gets an output stream for appending data to the file.

If the file doesn't already exist it is created.

By default files created are generally readable by everyone, but if you pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Some filesystems don't allow all filenames, and may throw a Gio::Error with INVALID_FILENAME. If the file is a directory a Gio::Error with IS_DIRECTORY will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  flags | A set of FileCreateFlags.
  cancellable | Optional Cancellable object.

Returns
  A FileOutputStream.

## append_to() [2/2]

Glib::RefPtr<FileOutputStream> Gio::File::append_to | ( | FileCreateFlags | flags = `FILE_CREATE_NONE` | ) |

Gets an output stream for appending data to the file.

If the file doesn't already exist it is created.

By default files created are generally readable by everyone, but if you pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

Some filesystems don't allow all filenames, and may throw a Gio::Error with INVALID_FILENAME. If the file is a directory a Gio::Error with IS_DIRECTORY will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  flags | A set of FileCreateFlags.

Returns
  A FileOutputStream.

## append_to_async() [1/2]

void Gio::File::append_to_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously opens the file for appending.

For more details, see append_to() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call append_to_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | a set of FileCreateFlags.
  io_priority | The I/O priority of the request.

## append_to_async() [2/2]

void Gio::File::append_to_async | ( | const SlotAsyncReady& | slot,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously opens the file for appending.

For more details, see append_to() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call append_to_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  flags | a set of FileCreateFlags.
  io_priority | The I/O priority of the request.

## append_to_finish()

Glib::RefPtr<FileOutputStream> Gio::File::append_to_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous file append operation started with g_file_append_to_async().

Parameters

  res | AsyncResult.

Returns
  A valid FileOutputStream or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## copy() [1/3]

bool Gio::File::copy | ( | const Glib::RefPtr< File >& | destination,
|  | const SlotFileProgress& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`
| ) |  |

Copies the file source to the location specified by destination.

Can not handle recursive copies of directories. If the flag FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten. If the flag FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

The operation can be monitored via the slot callback.

If the source file does not exist then a Gio::Error with NOT_FOUND will be thrown, independent on the status of the destination.

If FILE_COPY_OVERWRITE is not specified and the target exists, then a Gio::Error with EXISTS will be thrown.

If trying to overwrite a file over a directory a Gio::Error with IS_DIRECTORY will be thrown. If trying to overwrite a directory with a directory a Gio::Error with WOULD_MERGE will be thrown.

If the source is a directory and the target does not exist, or FILE_COPY_OVERWRITE is specified and the target is a file, then a Gio::Error with WOULD_RECURSE will be thrown.

If you are interested in copying the Gio::File object itself (not the on-disk file), see File::dup().

## copy() [2/3]

bool Gio::File::copy | ( | const Glib::RefPtr< File >& | destination,
|  | const SlotFileProgress& | slot,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`
| ) |  |

Copies the file source to the location specified by destination.

Can not handle recursive copies of directories. If the flag FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten. If the flag FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.

The operation can be monitored via the slot callback.

If the source file does not exist then a Gio::Error with NOT_FOUND will be thrown, independent on the status of the destination.

If FILE_COPY_OVERWRITE is not specified and the target exists, then a Gio::Error with EXISTS will be thrown.

If trying to overwrite a file over a directory a Gio::Error with IS_DIRECTORY will be thrown. If trying to overwrite a directory with a directory a Gio::Error with WOULD_MERGE will be thrown.

If the source is a directory and the target does not exist, or FILE_COPY_OVERWRITE is specified and the target is a file, then a Gio::Error with WOULD_RECURSE will be thrown.

If you are interested in copying the Gio::File object itself (not the on-disk file), see File::dup().

## copy() [3/3]

bool Gio::File::copy | ( | const Glib::RefPtr< File >& | destination,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`
| ) |  |

Copies the file source to the location specified by destination.

Can not handle recursive copies of directories. If the flag FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten. If the flag FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.

If the source file does not exist then a Gio::Error with NOT_FOUND will be thrown, independent on the status of the destination.

If FILE_COPY_OVERWRITE is not specified and the target exists, then a Gio::Error with EXISTS will be thrown.

If trying to overwrite a file over a directory a Gio::Error with IS_DIRECTORY will be thrown. If trying to overwrite a directory with a directory a Gio::Error with WOULD_MERGE will be thrown.

If the source is a directory and the target does not exist, or FILE_COPY_OVERWRITE is specified and the target is a file, then a Gio::Error with WOULD_RECURSE will be thrown.

If you are interested in copying the Gio::File object itself (not the on-disk file), see File::dup().

## copy_async() [1/4]

void Gio::File::copy_async | ( | const Glib::RefPtr< File >& | destination,
|  | const SlotFileProgress& | slot_progress,
|  | const SlotAsyncReady& | slot_ready,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Copies the file to the location specified by destination asynchronously.

For details of the behaviour, see copy().

When the operation is finished, slot_ready will be called. You can then call copy_finish() to get the result of the operation.

The function specified by slot_progress will be called just like in copy(), however the callback will run in the main loop, not in the thread that is doing the I/O operation.

Parameters

  destination | Destination File
  slot_progress | The callback slot to be called with progress information
  slot_ready | A SlotAsyncReady to call when the request is satisfied
  cancellable | A Cancellable object which can be used to cancel the operation
  flags | Set of FileCopyFlags
  io_priority | The I/O priority of the request

## copy_async() [2/4]

void Gio::File::copy_async | ( | const Glib::RefPtr< File >& | destination,
|  | const SlotAsyncReady& | slot_ready,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Copies the file to the location specified by destination asynchronously.

For details of the behaviour, see copy().

When the operation is finished, slot_ready will be called. You can then call copy_finish() to get the result of the operation.

Parameters

  destination | Destination File
  slot_ready | A SlotAsyncReady to call when the request is satisfied
  cancellable | A Cancellable object which can be used to cancel the operation
  flags | Set of FileCopyFlags
  io_priority | The I/O priority of the request

## copy_async() [3/4]

void Gio::File::copy_async | ( | const Glib::RefPtr< File >& | destination,
|  | const SlotFileProgress& | slot_progress,
|  | const SlotAsyncReady& | slot_ready,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Copies the file to the location specified by destination asynchronously.

For details of the behaviour, see copy().

When the operation is finished, slot_ready will be called. You can then call copy_finish() to get the result of the operation.

The function specified by slot_progress will be called just like in copy(), however the callback will run in the main loop, not in the thread that is doing the I/O operation.

Parameters

  destination | Destination File
  slot_progress | The callback slot to be called with progress information
  slot_ready | A SlotAsyncReady to call when the request is satisfied
  flags | Set of FileCopyFlags
  io_priority | The I/O priority of the request

## copy_async() [4/4]

void Gio::File::copy_async | ( | const Glib::RefPtr< File >& | destination,
|  | const SlotAsyncReady& | slot_ready,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Copies the file to the location specified by destination asynchronously.

For details of the behaviour, see copy().

When the operation is finished, slot_ready will be called. You can then call copy_finish() to get the result of the operation.

Parameters

  destination | Destination File
  slot_ready | A SlotAsyncReady to call when the request is satisfied
  flags | Set of FileCopyFlags
  io_priority | The I/O priority of the request

## copy_attributes() [1/2]

bool Gio::File::copy_attributes | ( | const Glib::RefPtr< File >& | destination,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`
| ) |  |

Copies the file attributes from source to destination.

Normally only a subset of the file attributes are copied, those that are copies in a normal file copy operation (which for instance does not include e.g. mtime). However if FILE_COPY_ALL_METADATA is specified in flags, then all the metadata that is possible to copy is copied.

Parameters

  destination | A File to copy attributes to.
  cancellable | A Cancellable object.
  flags | A set of FileMonitorFlags.

Returns
  true if the attributes were copied successfully, false otherwise.

## copy_attributes() [2/2]

bool Gio::File::copy_attributes | ( | const Glib::RefPtr< File >& | destination,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`
| ) |  |

Copies the file attributes from source to destination.

Normally only a subset of the file attributes are copied, those that are copies in a normal file copy operation (which for instance does not include e.g. mtime). However if FILE_COPY_ALL_METADATA is specified in flags, then all the metadata that is possible to copy is copied.

Parameters

  destination | A File to copy attributes to.
  flags | A set of FileMonitorFlags.

Returns
  true if the attributes were copied successfully, false otherwise.

## copy_finish()

bool Gio::File::copy_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes copying the file started with g_file_copy_async().

Parameters

  res | A AsyncResult.

Returns
  A `true` on success, `false` on error.

Exceptions

  Glib::Error |

## create_file() [1/2]

Glib::RefPtr<FileOutputStream> Gio::File::create_file | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Creates a new file and returns an output stream for writing to it.

The file must not already exist.

By default files created are generally readable by everyone, but if you pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If a file with this name already exists a Gio::Error with EXISTS will be thrown. If the file is a directory a Gio::Error with IS_DIRECTORY will be thrown.

Some filesystems don't allow all filenames, and may throw a Gio::Error with INVALID_FILENAME, and if the name is to longa Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | a set of FileCreateFlags.

Returns
  A FileOutputStream for the newly created file.

## create_file() [2/2]

Glib::RefPtr<FileOutputStream> Gio::File::create_file | ( | FileCreateFlags | flags = `FILE_CREATE_NONE` | ) |

Creates a new file and returns an output stream for writing to it.

The file must not already exist.

By default files created are generally readable by everyone, but if you pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If a file with this name already exists a Gio::Error with EXISTS will be thrown. If the file is a directory a Gio::Error with IS_DIRECTORY will be thrown.

Some filesystems don't allow all filenames, and may throw a Gio::Error with INVALID_FILENAME, and if the name is to longa Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  flags | a set of FileCreateFlags.

Returns
  A FileOutputStream for the newly created file.

## create_file_async() [1/2]

void Gio::File::create_file_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously creates a new file and returns an output stream for writing to it.

The file must not already exist. For more details, see create_file() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call create_file_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | a set of FileCreateFlags.
  io_priority | The I/O priority of the request.

## create_file_async() [2/2]

void Gio::File::create_file_async | ( | const SlotAsyncReady& | slot,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously creates a new file and returns an output stream for writing to it.

The file must not already exist. For more details, see create_file() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call create_file_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  flags | a set of FileCreateFlags.
  io_priority | The I/O priority of the request.

## create_file_finish()

Glib::RefPtr<FileOutputStream> Gio::File::create_file_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous file create operation started with g_file_create_async().

Parameters

  res | A AsyncResult.

Returns
  A FileOutputStream or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## create_file_readwrite() [1/2]

Glib::RefPtr<FileIOStream> Gio::File::create_file_readwrite | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Creates a new file and returns a stream for reading and writing to it.

The file must not already exist.

By default files created are generally readable by everyone, but if you pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If a file with this name already exists a Gio::Error with EXISTS will be thrown. If the file is a directory a Gio::Error with IS_DIRECTORY will be thrown.

Some filesystems don't allow all filenames, and may throw a Gio::Error with INVALID_FILENAME, and if the name is to longa Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

Parameters

  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | a set of FileCreateFlags.

Returns
  A FileOutputStream for the newly created file.

## create_file_readwrite() [2/2]

Glib::RefPtr<FileIOStream> Gio::File::create_file_readwrite | ( | FileCreateFlags | flags = `FILE_CREATE_NONE` | ) |

Creates a new file and returns a stream for reading and writing to it.

The file must not already exist.

By default files created are generally readable by everyone, but if you pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If a file with this name already exists a Gio::Error with EXISTS will be thrown. If the file is a directory a Gio::Error with IS_DIRECTORY will be thrown.

Some filesystems don't allow all filenames, and may throw a Gio::Error with INVALID_FILENAME, and if the name is to longa Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

Parameters

  flags | a set of FileCreateFlags.

Returns
  A FileOutputStream for the newly created file.

## create_file_readwrite_async() [1/2]

void Gio::File::create_file_readwrite_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously creates a new file and returns a stream for reading and writing to it.

The file must not already exist.

For more details, see create_file_readwrite() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call create_file_readwrite_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | a set of FileCreateFlags.
  io_priority | The I/O priority of the request.

Since glibmm 2.24:

## create_file_readwrite_async() [2/2]

void Gio::File::create_file_readwrite_async | ( | const SlotAsyncReady& | slot,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously creates a new file and returns a stream for reading and writing to it.

The file must not already exist.

For more details, see create_file_readwrite() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call create_file_readwrite_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  flags | a set of FileCreateFlags.
  io_priority | The I/O priority of the request.

Since glibmm 2.24:

## create_file_readwrite_finish()

Glib::RefPtr<FileIOStream> Gio::File::create_file_readwrite_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous file create operation started with g_file_create_readwrite_async().

Since glibmm 2.22:

Parameters

  res | A AsyncResult.

Returns
  A FileIOStream or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## create_for_commandline_arg()

static Glib::RefPtr<File> Gio::File::create_for_commandline_arg | ( | const std::string & | arg | ) |

static

Constructs a File for a given argument from the command line.

The value of arg can be either a URI, an absolute path or a relative path resolved relative to the current working directory. This operation never fails, but the returned object might not support any I/O operation if arg points to a malformed path.

Parameters

  arg | A string containing a relative or absolute path.

Returns
  A new instantiation of an appropriate Gio::File class.

## create_for_parse_name()

static Glib::RefPtr<File> Gio::File::create_for_parse_name | ( | const Glib::ustring& | parse_name | ) |

static

## create_for_path()

static Glib::RefPtr<File> Gio::File::create_for_path | ( | const std::string & | path | ) |

static

Constructs a File for a given path.

This operation never fails, but the returned object might not support any I/O operation if path is malformed.

Parameters

  path | A string containing a relative or absolute path.

Returns
  A new instantiation of an appropriate Gio::File class.

## create_for_uri()

static Glib::RefPtr<File> Gio::File::create_for_uri | ( | const std::string & | uri | ) |

static

Constructs a File for a given URI.

This operation never fails, but the returned object might not support any I/O operation if path is malformed.

Parameters

  uri | A string containing a URI.

Returns
  A new instantiation of an appropriate Gio::File class.

## dup()

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

Duplicates a File handle.

This operation does not duplicate the actual file or directory represented by the File; see g_file_copy() if attempting to copy a file.

This call does no blocking I/O.

Returns
  A new File that is a duplicate of the given File.

## eject_mountable() [1/6]

void Gio::File::eject_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Starts an asynchronous eject on a mountable.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

When the operation is finished, slot will be called. You can then call eject_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | Flags affecting the operation.

## eject_mountable() [2/6]

void Gio::File::eject_mountable | ( | const SlotAsyncReady& | slot,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Starts an asynchronous eject on a mountable.

When the operation is finished, slot will be called. You can then call eject_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  flags | Flags affecting the operation.

## eject_mountable() [3/6]

void Gio::File::eject_mountable | ( | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` | ) |

Starts an asynchronous eject on a mountable.

Parameters

  flags | Flags affecting the operation.

## eject_mountable() [4/6]

void Gio::File::eject_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Starts an asynchronous eject on a mountable.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

When the operation is finished, slot will be called. You can then call eject_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  mount_operation | A MountOperation
  flags | Flags affecting the operation.

Since glibmm 2.24:

## eject_mountable() [5/6]

void Gio::File::eject_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Starts an asynchronous eject on a mountable.

When the operation is finished, slot will be called. You can then call eject_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  mount_operation | A MountOperation
  flags | Flags affecting the operation.

Since glibmm 2.24:

## eject_mountable() [6/6]

void Gio::File::eject_mountable | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Starts an asynchronous eject on a mountable.

Parameters

  mount_operation | A MountOperation
  flags | Flags affecting the operation.

Since glibmm 2.24:

## eject_mountable_finish()

bool Gio::File::eject_mountable_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes an asynchronous eject operation started by g_file_eject_mountable_with_operation().

Since glibmm 2.22:

Parameters

  result | A AsyncResult.

Returns
  `true` if the file was ejected successfully. `false` otherwise.

Exceptions

  Glib::Error |

## enumerate_children() [1/2]

Glib::RefPtr<FileEnumerator> Gio::File::enumerate_children | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | attributes = `"*"`,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`
| ) |  |

Gets the requested information about the files in a directory.

The result is a FileEnumerator object that will give out FileInfo objects for all the files in the directory.

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if its not possible to read a particular requested attribute from a file, it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user". The standard attributes are availible as defines, like FILE_ATTRIBUTE_STANDARD_NAME.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. If the file is not a directory, a Glib::FileError with NOTDIR will be thrown. Other errors are possible too.

Parameters

  cancellable | A Cancellable object.
  attributes | An attribute query string.
  flags | A set of FileQueryInfoFlags.

Returns
  A FileEnumerator if successful.

## enumerate_children() [2/2]

Glib::RefPtr<FileEnumerator> Gio::File::enumerate_children | ( | const std::string & | attributes = `"*"`,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`
| ) |  |

Gets the requested information about the files in a directory.

The result is a FileEnumerator object that will give out FileInfo objects for all the files in the directory.

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if its not possible to read a particular requested attribute from a file, it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user". The standard attributes are availible as defines, like FILE_ATTRIBUTE_STANDARD_NAME.

If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. If the file is not a directory, a Glib::FileError with NOTDIR will be thrown. Other errors are possible too.

Parameters

  attributes | An attribute query string.
  flags | A set of FileQueryInfoFlags.

Returns
  A FileEnumerator if successful.

## enumerate_children_async() [1/2]

void Gio::File::enumerate_children_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | attributes = `"*"`,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously gets the requested information about the files in a directory.

The result is a GFileEnumerator object that will give out GFileInfo objects for all the files in the directory.

For more details, see enumerate_children() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call enumerate_children_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  attributes | An attribute query string.
  flags | A set of FileQueryInfoFlags.
  io_priority | The I/O priority of the request.

## enumerate_children_async() [2/2]

void Gio::File::enumerate_children_async | ( | const SlotAsyncReady& | slot,
|  | const std::string & | attributes = `"*"`,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously gets the requested information about the files in a directory.

The result is a GFileEnumerator object that will give out GFileInfo objects for all the files in the directory.

For more details, see enumerate_children() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call enumerate_children_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  attributes | An attribute query string.
  flags | A set of FileQueryInfoFlags.
  io_priority | The I/O priority of the request.

## enumerate_children_finish()

Glib::RefPtr<FileEnumerator> Gio::File::enumerate_children_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an async enumerate children operation.

See g_file_enumerate_children_async().

Parameters

  res | A AsyncResult.

Returns
  A FileEnumerator or `nullptr` if an error occurred. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## equal()

bool Gio::File::equal | ( | const Glib::RefPtr< const File >& | other | ) | const

Checks equality of two given Files.

Note that two Files that differ can still refer to the same file on the filesystem due to various forms of filename aliasing.

This call does no blocking I/O.

Parameters

  other | The other File.

Returns
  `true` if * this and other are equal. `false` if either is not a File.

## find_enclosing_mount() [1/2]

Glib::RefPtr<Mount> Gio::File::find_enclosing_mount | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Gets a Mount for the File.

If the FileIface for file does not have a mount (e.g. possibly a remote share), a Gio::Error will be thrown with NOT_FOUND and `nullptr` will be returned.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  cancellable | Cancellable object.

Returns
  A Mount where the file is located or `nullptr` on error.

Exceptions

  Glib::Error |

## find_enclosing_mount() [2/2]

Glib::RefPtr<Mount> Gio::File::find_enclosing_mount | ( |  | ) |

A find_enclosing_mount() convenience overload.

## find_enclosing_mount_async() [1/2]

void Gio::File::find_enclosing_mount_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously gets the mount for the file.

For more details, see find_enclosing_mount() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call find_enclosing_mount_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object.
  io_priority | The I/O priority of the request.

## find_enclosing_mount_async() [2/2]

void Gio::File::find_enclosing_mount_async | ( | const SlotAsyncReady& | slot,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously gets the mount for the file.

For more details, see find_enclosing_mount() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call find_enclosing_mount_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  io_priority | The I/O priority of the request.

## find_enclosing_mount_finish()

Glib::RefPtr<Mount> Gio::File::find_enclosing_mount_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous find mount request.

See g_file_find_enclosing_mount_async().

Parameters

  res | A AsyncResult.

Returns
  Mount for given file or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## get_basename()

std::string Gio::File::get_basename | ( |  | ) | const

Gets the base name (the last component of the path) for a given File.

If called for the top level of a system (such as the filesystem root or a uri like sftp://host/) it will return a single directory separator (and on Windows, possibly a drive letter).

The base name is a byte string (not UTF-8). It has no defined encoding or rules other than it may not contain zero bytes. If you want to use filenames in a user interface you should use the display name that you can get by requesting the G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().

This call does no blocking I/O.

Returns
  String containing the File's base name, or `nullptr` if given File is invalid.

## get_child()

Glib::RefPtr<File> Gio::File::get_child | ( | const std::string & | name | ) | const

Gets a child of file with basename equal to name.

Note that the file with that specific name might not exist, but you can still have a File that points to it. You can use this for instance to create that file.

This call does no blocking I/O.

Parameters

  name | String containing the child's basename.

Returns
  A File to a child specified by name. Free the returned object with Glib::object_unref().

## get_child_for_display_name()

Glib::RefPtr<File> Gio::File::get_child_for_display_name | ( | const Glib::ustring& | display_name | ) | const

Gets the child of file for a given display_name (i.e. a UTF-8 version of the name).

If this function fails, it returns `nullptr` and error will be set. This is very useful when constructing a File for a new file and the user entered the filename in the user interface, for instance when you select a directory and type a filename in the file selector.

This call does no blocking I/O.

Parameters

  display_name | String to a possible child.

Returns
  A File to the specified child, or `nullptr` if the display name couldn't be converted. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## get_parent()

Glib::RefPtr<File> Gio::File::get_parent | ( |  | ) | const

Gets the parent directory for the file.

If the file represents the root directory of the file system, then `nullptr` will be returned.

This call does no blocking I/O.

Returns
  A File structure to the parent of the given File or `nullptr` if there is no parent. Free the returned object with Glib::object_unref().

## get_parse_name()

Glib::ustring Gio::File::get_parse_name | ( |  | ) | const

Gets the parse name of the file.

A parse name is a UTF-8 string that describes the file such that one can get the File back using g_file_parse_name().

This is generally used to show the File as a nice full-pathname kind of string in a user interface, like in a location entry.

For local files with names that can safely be converted to UTF-8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF-8 characters unescaped).

This call does no blocking I/O.

Returns
  A string containing the File's parse name.

## get_path()

std::string Gio::File::get_path | ( |  | ) | const

Gets the local pathname for File, if one exists.

If non-`nullptr`, this is guaranteed to be an absolute, canonical path. It might contain symlinks.

This call does no blocking I/O.

Returns
  String containing the File's path, or `nullptr` if no such path exists.

## get_relative_path()

std::string Gio::File::get_relative_path | ( | const Glib::RefPtr< const File >& | descendant | ) | const

Gets the path for descendant relative to parent.

This call does no blocking I/O.

Parameters

  descendant | Input File.

Returns
  String with the relative path from descendant to parent, or `nullptr` if descendant doesn't have parent as prefix.

## get_type()

static GType Gio::File::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

## get_uri()

std::string Gio::File::get_uri | ( |  | ) | const

Gets the URI for the file.

This call does no blocking I/O.

Returns
  A string containing the File's URI.

## get_uri_scheme()

std::string Gio::File::get_uri_scheme | ( |  | ) | const

Gets the URI scheme for a File.

RFC 3986 decodes the scheme as:

[C example ellipted] Common schemes include "file", "http", "ftp", etc.

This call does no blocking I/O.

Returns
  A string containing the URI scheme for the given File.

## gobj() [1/2]

GFile* Gio::File::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

## gobj() [2/2]

const GFile* Gio::File::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

## has_parent() [1/2]

bool Gio::File::has_parent | ( | const Glib::RefPtr< File >& | parent | ) | const

Checks if file has a parent, and optionally, if it is parent.

If parent is `nullptr` then this function returns `true` if file has any parent at all. If parent is non-`nullptr` then `true` is only returned if file is an immediate child of parent.

Since glibmm 2.24:

Parameters

  parent | The parent to check for, or `nullptr`.

Returns
  `true` if file is an immediate child of parent (or any parent in the case that parent is `nullptr`).

## has_parent() [2/2]

bool Gio::File::has_parent | ( |  | ) | const

Checks if the file has any parent at all.

Returns
  true if the file is a child of any parent.

Since glibmm 2.24:

## has_prefix()

bool Gio::File::has_prefix | ( | const Glib::RefPtr< const File >& | prefix | ) | const

Checks whether file has the prefix specified by prefix.

In other words, if the names of initial elements of file's pathname match prefix. Only full pathname elements are matched, so a path like /foo is not considered a prefix of /foobar, only of /foo/bar.

A File is not a prefix of itself. If you want to check for equality, use g_file_equal().

This call does no I/O, as it works purely on names. As such it can sometimes return `false` even if file is inside a prefix (from a filesystem point of view), because the prefix of file is an alias of prefix.

Virtual: prefix_matches

Parameters

  prefix | Input File.

Returns
  `true` if the files's parent, grandparent, etc is prefix, `false` otherwise.

## has_uri_scheme()

bool Gio::File::has_uri_scheme | ( | const std::string & | uri_scheme | ) | const

Checks to see if a File has a given URI scheme.

This call does no blocking I/O.

Parameters

  uri_scheme | A string containing a URI scheme.

Returns
  `true` if File's backend supports the given URI scheme, `false` if URI scheme is `nullptr`, not supported, or File is invalid.

## hash()

guint Gio::File::hash | ( |  | ) | const

Creates a hash value for a File.

This call does no blocking I/O.

Virtual: hash

Returns
  0 if file is not a valid File, otherwise an integer that can be used as hash value for the File. This function is intended for easily hashing a File to add to a HashTable or similar data structure.

## is_native()

bool Gio::File::is_native | ( |  | ) | const

Checks to see if a file is native to the platform.

A native file s one expressed in the platform-native filename format, e.g. "C:\\Windows" or "/usr/bin/". This does not mean the file is local, as it might be on a locally mounted remote filesystem.

On some systems non-native files may be available using the native filesystem via a userspace filesystem (FUSE), in these cases this call will return `false`, but g_file_get_path() will still return a native path.

This call does no blocking I/O.

Returns
  `true` if file is native.

## load_contents() [1/4]

bool Gio::File::load_contents | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | char *& | contents,
|  | gsize & | length,
|  | std::string & | etag_out
| ) |  |

Loads the content of the file into memory, returning the size of the data.

The data is always zero terminated, but this is not included in the resultant length.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error exception with CANCELLED will be returned.

Parameters

  cancellable | A cancellable object.
  contents | A location to place the contents of the file.
  length | A location to place the length of the contents of the file.
  etag_out | A location to place the current entity tag for the file.

## load_contents() [2/4]

bool Gio::File::load_contents | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | char *& | contents,
|  | gsize & | length
| ) |  |

Loads the content of the file into memory, returning the size of the data.

The data is always zero terminated, but this is not included in the resultant length.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error exception with CANCELLED will be returned.

Parameters

  cancellable | A cancellable object.
  contents | A location to place the contents of the file.
  length | A location to place the length of the contents of the file.

Since glibmm 2.22:

## load_contents() [3/4]

bool Gio::File::load_contents | ( | char *& | contents,
|  | gsize & | length,
|  | std::string & | etag_out
| ) |  |

Loads the content of the file into memory, returning the size of the data.

The data is always zero terminated, but this is not included in the resultant length.

Parameters

  contents | A location to place the contents of the file.
  length | A location to place the length of the contents of the file.
  etag_out | A location to place the current entity tag for the file.

## load_contents() [4/4]

bool Gio::File::load_contents | ( | char *& | contents,
|  | gsize & | length
| ) |  |

Loads the content of the file into memory, returning the size of the data.

The data is always zero terminated, but this is not included in the resultant length.

Parameters

  contents | A location to place the contents of the file.
  length | A location to place the length of the contents of the file.

Since glibmm 2.22:

## load_contents_async() [1/2]

void Gio::File::load_contents_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Starts an asynchronous load of the file's contents.

For more details, see load_contents() which is the synchronous version of this call.

When the load operation has completed, the slot will be called. To finish the operation, call load_contents_finish() with the AsyncResult provided to the slot.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object.

## load_contents_async() [2/2]

void Gio::File::load_contents_async | ( | const SlotAsyncReady& | slot | ) |

Starts an asynchronous load of the file's contents.

For more details, see load_contents() which is the synchronous version of this call.

When the load operation has completed, the slot will be called. To finish the operation, call load_contents_finish() with the AsyncResult provided to the slot.

Parameters

  slot | A callback slot which will be called when the request is satisfied.

## load_contents_finish() [1/2]

bool Gio::File::load_contents_finish | ( | const Glib::RefPtr< AsyncResult >& | result,
|  | char *& | contents,
|  | gsize & | length,
|  | std::string & | etag_out
| ) |  |

Finishes an asynchronous load of the file's contents.

The contents are placed in contents, and length is set to the size of the contents string. If etag_out is present, it will be set to the new entity tag for the file.

Parameters

  result | A AsyncResult.
  contents | A location to place the contents of the file.
  length | A location to place the length of the contents of the file.
  etag_out | A location to place the current entity tag for the file.

Returns
  `true` if the load was successful. If `false` and error is present, it will be set appropriately.

## load_contents_finish() [2/2]

bool Gio::File::load_contents_finish | ( | const Glib::RefPtr< AsyncResult >& | result,
|  | char *& | contents,
|  | gsize & | length
| ) |  |

Finishes an asynchronous load of the file's contents.

The contents are placed in contents, and length is set to the size of the contents string. If etag_out is present, it will be set to the new entity tag for the file.

Parameters

  result | A AsyncResult.
  contents | A location to place the contents of the file.
  length | A location to place the length of the contents of the file.

Returns
  `true` if the load was successful. If `false` and error is present, it will be set appropriately.

Since glibmm 2.22:

## load_partial_contents_async() [1/2]

void Gio::File::load_partial_contents_async | ( | const SlotReadMore& | slot_read_more,
|  | const SlotAsyncReady& | slot_async_ready,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Reads the partial contents of a file.

The slot_read_more callback slot should be used to stop reading from the file when appropriate. This operation can be finished by load_partial_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

When the operation is finished, slot will be called. You can then call load_partial_contents_finish() to get the result of the operation.

Parameters

  slot_read_more | A callback to receive partial data and to specify whether further data should be read.
  slot_async_ready | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.

## load_partial_contents_async() [2/2]

void Gio::File::load_partial_contents_async | ( | const SlotReadMore& | slot_read_more,
|  | const SlotAsyncReady& | slot_async_ready
| ) |  |

Reads the partial contents of a file.

The slot_read_more callback slot should be used to stop reading from the file when appropriate. This operation can be finished by load_partial_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

When the operation is finished, slot will be called. You can then call load_partial_contents_finish() to get the result of the operation.

Parameters

  slot_read_more | A callback to receive partial data and to specify whether further data should be read.
  slot_async_ready | A callback slot which will be called when the request is satisfied.

## load_partial_contents_finish() [1/2]

bool Gio::File::load_partial_contents_finish | ( | const Glib::RefPtr< AsyncResult >& | result,
|  | char *& | contents,
|  | gsize & | length,
|  | std::string & | etag_out
| ) |  |

Finishes an asynchronous partial load operation that was started with load_partial_contents_async().

Parameters

  result | A AsyncResult.
  contents | A location to place the contents of the file.
  length | A location to place the length of the contents of the file.
  etag_out | A location to place the current entity tag for the file.

Returns
  `true` if the load was successful. If `false` and error is present, it will be set appropriately.

## load_partial_contents_finish() [2/2]

bool Gio::File::load_partial_contents_finish | ( | const Glib::RefPtr< AsyncResult >& | result,
|  | char *& | contents,
|  | gsize & | length
| ) |  |

Finishes an asynchronous partial load operation that was started with load_partial_contents_async().

Parameters

  result | A AsyncResult.
  contents | A location to place the contents of the file.
  length | A location to place the length of the contents of the file.

Returns
  `true` if the load was successful. If `false` and error is present, it will be set appropriately.

Since glibmm 2.22:

## make_directory() [1/2]

bool Gio::File::make_directory | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Creates a directory.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  cancellable | Cancellable object.

Returns
  `true` on successful creation, `false` otherwise.

Exceptions

  Glib::Error |

## make_directory() [2/2]

bool Gio::File::make_directory | ( |  | ) |

A make_directory() convenience overload.

## make_directory_async() [1/2]

void Gio::File::make_directory_async | ( | const SlotAsyncReady& | slot_ready,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously creates a directory.

Parameters

  slot_ready | A SlotAsyncReady to call when the request is satisfied
  cancellable | A Cancellable object which can be used to cancel the operation
  io_priority | The I/O priority of the request

Since glibmm 2.38:

## make_directory_async() [2/2]

void Gio::File::make_directory_async | ( | const SlotAsyncReady& | slot_ready,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously creates a directory.

Parameters

  slot_ready | A SlotAsyncReady to call when the request is satisfied
  io_priority | The I/O priority of the request

Since glibmm 2.38:

## make_directory_finish()

bool Gio::File::make_directory_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes an asynchronous directory creation, started with g_file_make_directory_async().

Virtual: make_directory_finish

Since glibmm 2.38:

Parameters

  result | A AsyncResult.

Returns
  `true` on successful directory creation, `false` otherwise.

Exceptions

  Glib::Error |

## make_directory_with_parents() [1/2]

bool Gio::File::make_directory_with_parents | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Creates a directory and any parent directories that may not exist similar to 'mkdir -p'.

If the file system does not support creating directories, this function will fail, setting error to IO_ERROR_NOT_SUPPORTED. If the directory itself already exists, this function will fail setting error to IO_ERROR_EXISTS, unlike the similar Glib::mkdir_with_parents().

For a local File the newly created directories will have the default (current) ownership and permissions of the current process.

If cancellable is not `nullptr`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

Since glibmm 2.18:

Parameters

  cancellable | Optional Cancellable object, `nullptr` to ignore.

Returns
  `true` if all directories have been successfully created, `false` otherwise.

Exceptions

  Glib::Error |

## make_directory_with_parents() [2/2]

bool Gio::File::make_directory_with_parents | ( |  | ) |

A make_directory_with_parents() convenience overload.

## make_symbolic_link() [1/2]

bool Gio::File::make_symbolic_link | ( | const std::string & | symlink_value,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Creates a symbolic link.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  symlink_value | A string with the value of the new symlink.
  cancellable | Cancellable object.

Returns
  `true` on the creation of a new symlink, `false` otherwise.

Exceptions

  Glib::Error |

## make_symbolic_link() [2/2]

bool Gio::File::make_symbolic_link | ( | const std::string & | symlink_value | ) |

A make_symbolic_link() convenience overload.

## measure_disk_usage()

void Gio::File::measure_disk_usage | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const SlotFileMeasureProgress& | slot_progress,
|  | guint64 & | disk_usage,
|  | guint64 & | num_dirs,
|  | guint64 & | num_files,
|  | FileMeasureFlags | flags = `FILE_MEASURE_NONE`
| ) |  |

Recursively measures the disk usage of the file.

This is essentially an analog of the '`du`' command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links).

By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless FILE_DISK_USAGE_REPORT_ALL_ERRORS is given in flags.

The returned size, disk_usage, is in bytes and should be formatted with g_format_size() in order to get something reasonable for showing in a user interface.

slot_progress can be given to request periodic progress updates while scanning. See the documentation for SlotFileMeasureProgress for information about when and how the callback will be invoked.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  cancellable | A Cancellable object which can be used to cancel the operation
  slot_progress | A SlotFileMeasureProgress to call periodically while scanning.
  disk_usage | The number of bytes of disk space used.
  num_dirs | The number of directories encountered.
  num_files | The number of non-directories encountered.
  flags | Set of FileMeasureFlags.

## measure_disk_usage_async()

void Gio::File::measure_disk_usage_async | ( | const SlotAsyncReady& | slot_ready,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const SlotFileMeasureProgress& | slot_progress,
|  | FileMeasureFlags | flags = `FILE_MEASURE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Recursively measures the disk usage of the file.

This is the asynchronous version of measure_disk_usage(). See there for more information.

When the operation is finished, slot_ready will be called. You can then call measure_disk_usage_finish() to get the result of the operation.

Parameters

  slot_ready | A SlotAsyncReady to call when the request is satisfied
  cancellable | A Cancellable object which can be used to cancel the operation
  slot_progress | The callback slot to be called with progress information
  flags | Set of FileMeasureFlags
  io_priority | The I/O priority of the request

## measure_disk_usage_finish()

bool Gio::File::measure_disk_usage_finish | ( | const Glib::RefPtr< AsyncResult >& | result,
|  | guint64 & | disk_usage,
|  | guint64 & | num_dirs,
|  | guint64 & | num_files
| ) |  |

Collects the results from an earlier call to g_file_measure_disk_usage_async().

See g_file_measure_disk_usage() for more information.

Since glibmm 2.38:

Parameters

  result | The AsyncResult passed to your SlotAsyncReady.
  disk_usage | The number of bytes of disk space used.
  num_dirs | The number of directories encountered.
  num_files | The number of non-directories encountered.

Returns
  `true` if successful, with the out parameters set. `false` otherwise, with error set.

Exceptions

  Glib::Error |

## monitor() [1/2]

Glib::RefPtr<FileMonitor> Gio::File::monitor | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileMonitorFlags | flags = `FILE_MONITOR_NONE`
| ) |  |

Obtains a file monitor for the given file.

If no file notification mechanism exists, then regular polling of the file is used.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  cancellable | A Cancellable object.
  flags | A set of FileMonitorFlags.

Returns
  A FileMonitor for the file.

Since glibmm 2.18:

## monitor() [2/2]

Glib::RefPtr<FileMonitor> Gio::File::monitor | ( | FileMonitorFlags | flags = `FILE_MONITOR_NONE` | ) |

Obtains a file monitor for the given file.

If no file notification mechanism exists, then regular polling of the file is used.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  flags | A set of FileMonitorFlags.

Returns
  A FileMonitor for the file.

Since glibmm 2.18:

## monitor_directory() [1/2]

Glib::RefPtr<FileMonitor> Gio::File::monitor_directory | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileMonitorFlags | flags = `FILE_MONITOR_NONE`
| ) |  |

Obtains a directory monitor for the given file.

This may fail if directory monitoring is not supported.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  cancellable | A Cancellable object.
  flags | A set of FileMonitorFlags.

Returns
  A FileMonitor for the file.

## monitor_directory() [2/2]

Glib::RefPtr<FileMonitor> Gio::File::monitor_directory | ( | FileMonitorFlags | flags = `FILE_MONITOR_NONE` | ) |

Obtains a directory monitor for the given file.

This may fail if directory monitoring is not supported.

Parameters

  flags | A set of FileMonitorFlags.

Returns
  A FileMonitor for the file.

## monitor_file() [1/2]

Glib::RefPtr<FileMonitor> Gio::File::monitor_file | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileMonitorFlags | flags = `FILE_MONITOR_NONE`
| ) |  |

Obtains a file monitor for the given file.

If no file notification mechanism exists, then regular polling of the file is used.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  cancellable | A Cancellable object.
  flags | A set of FileMonitorFlags.

Returns
  A FileMonitor for the file.

## monitor_file() [2/2]

Glib::RefPtr<FileMonitor> Gio::File::monitor_file | ( | FileMonitorFlags | flags = `FILE_MONITOR_NONE` | ) |

Obtains a file monitor for the given file.

If no file notification mechanism exists, then regular polling of the file is used.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  flags | A set of FileMonitorFlags.

Returns
  A FileMonitor for the file.

## mount_enclosing_volume() [1/4]

void Gio::File::mount_enclosing_volume | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | MountMountFlags | flags = `MOUNT_MOUNT_NONE`
| ) |  |

Starts a mount_operation, mounting the volume that contains the file.

When this operation has completed, slot will be called with, and the operation can be finalized with mount_enclosing_volume_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  mount_operation | A MountOperation.
  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object.
  flags | Flags affecting the operation.

## mount_enclosing_volume() [2/4]

void Gio::File::mount_enclosing_volume | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady& | slot,
|  | MountMountFlags | flags = `MOUNT_MOUNT_NONE`
| ) |  |

Starts a mount_operation, mounting the volume that contains the file.

When this operation has completed, slot will be called with, and the operation can be finalized with mount_enclosing_volume_finish().

Parameters

  mount_operation | A MountOperation.
  slot | A callback slot which will be called when the request is satisfied.
  flags | Flags affecting the operation.

## mount_enclosing_volume() [3/4]

void Gio::File::mount_enclosing_volume | ( | const SlotAsyncReady& | slot,
|  | MountMountFlags | flags = `MOUNT_MOUNT_NONE`
| ) |  |

Starts a mount_operation, mounting the volume that contains the file.

When this operation has completed, slot will be called with, and the operation can be finalized with mount_enclosing_volume_finish().

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  flags | Flags affecting the operation.

## mount_enclosing_volume() [4/4]

void Gio::File::mount_enclosing_volume | ( | MountMountFlags | flags = `MOUNT_MOUNT_NONE` | ) |

Starts a mount_operation, mounting the volume that contains the file.

Parameters

  flags | Flags affecting the operation.

## mount_enclosing_volume_finish()

bool Gio::File::mount_enclosing_volume_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes a mount operation started by g_file_mount_enclosing_volume().

Parameters

  result | A AsyncResult.

Returns
  `true` if successful. If an error has occurred, this function will return `false` and set error appropriately if present.

Exceptions

  Glib::Error |

## mount_mountable() [1/4]

void Gio::File::mount_mountable | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | MountMountFlags | flags = `MOUNT_MOUNT_NONE`
| ) |  |

Mounts a file of type FILE_TYPE_MOUNTABLE.

Using mount_operation, you can request callbacks when, for instance, passwords are needed during authentication.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

When the operation is finished, slot will be called. You can then call mount_mountable_finish() to get the result of the operation.

Parameters

  mount_operation | A MountOperation.
  cancellable | A Cancellable object which can be used to cancel the operation.
  slot | A callback slot which will be called when the request is satisfied.
  flags | Flags affecting the operation.

## mount_mountable() [2/4]

void Gio::File::mount_mountable | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady& | slot,
|  | MountMountFlags | flags = `MOUNT_MOUNT_NONE`
| ) |  |

Mounts a file of type FILE_TYPE_MOUNTABLE.

Using mount_operation, you can request callbacks when, for instance, passwords are needed during authentication.

When the operation is finished, slot will be called. You can then call mount_mountable_finish() to get the result of the operation.

Parameters

  mount_operation | A MountOperation.
  slot | A callback slot which will be called when the request is satisfied.
  flags | Flags affecting the operation.

## mount_mountable() [3/4]

void Gio::File::mount_mountable | ( | const SlotAsyncReady& | slot,
|  | MountMountFlags | flags = `MOUNT_MOUNT_NONE`
| ) |  |

Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction.

When the operation is finished, slot will be called. You can then call mount_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  flags | Flags affecting the operation.

## mount_mountable() [4/4]

void Gio::File::mount_mountable | ( | MountMountFlags | flags = `MOUNT_MOUNT_NONE` | ) |

Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction.

Parameters

  flags | Flags affecting the operation.

## mount_mountable_finish()

Glib::RefPtr<File> Gio::File::mount_mountable_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes a mount operation.

See g_file_mount_mountable() for details.

Finish an asynchronous mount operation that was started with g_file_mount_mountable().

Parameters

  result | A AsyncResult.

Returns
  A File or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## move() [1/3]

bool Gio::File::move | ( | const Glib::RefPtr< File >& | destination,
|  | const SlotFileProgress& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`
| ) |  |

Tries to move the file or directory source to the location specified by destination.

If native move operations are supported then this is used, otherwise a copy and delete fallback is used. The native implementation may support moving directories (for instance on moves inside the same filesystem), but the fallback code does not.

If the flag FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten.

If the flag FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

The operation can be monitored via the slot callback. If the source file does not exist then a Gio::Error with NOT_FOUND will be thrown, independent on the status of the destination.

If G_FILE_COPY_OVERWRITE is not specified and the target exists, then a Gio::Error with EXISTS will be thrown.

If trying to overwrite a file over a directory a Gio::Error with IS_DIRECTORY will be thrown. If trying to overwrite a directory with a directory a Gio::Error with WOULD_MERGE will be thrown.

If the source is a directory and the target does not exist, or FILE_COPY_OVERWRITE is specified and the target is a file, then a Gio::Error with WOULD_RECURSE may be thrown (if the native move operation isn't available).

## move() [2/3]

bool Gio::File::move | ( | const Glib::RefPtr< File >& | destination,
|  | const SlotFileProgress& | slot,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`
| ) |  |

## move() [3/3]

bool Gio::File::move | ( | const Glib::RefPtr< File >& | destination,
|  | FileCopyFlags | flags = `FILE_COPY_NONE`
| ) |  |

## open_readwrite() [1/2]

Glib::RefPtr<FileIOStream> Gio::File::open_readwrite | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Opens an existing file for reading and writing.

The result is a FileIOStream that can be used to read and write the contents of the file.

If cancellable is not `nullptr`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

If the file does not exist, the IO_ERROR_NOT_FOUND error will be returned. If the file is a directory, the IO_ERROR_IS_DIRECTORY error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

Since glibmm 2.22:

Parameters

  cancellable | A Cancellable.

Returns
  FileIOStream or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## open_readwrite() [2/2]

Glib::RefPtr<FileIOStream> Gio::File::open_readwrite | ( |  | ) |

A open_readwrite() convenience overload.

## open_readwrite_async() [1/2]

void Gio::File::open_readwrite_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Opens an existing file for reading and writing.

The result is a FileIOStream that can be used to read and write the contents of the file.

For more details, see open_readwrite() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call open_readwrite_finish() to get the result of the operation. If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. If the file is a directory, a Gio::Error with IS_DIRECTORY will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  io_priority | The I/O priority of the request.

Since glibmm 2.24:

## open_readwrite_async() [2/2]

void Gio::File::open_readwrite_async | ( | const SlotAsyncReady& | slot,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Opens an existing file for reading and writing.

The result is a FileIOStream that can be used to read and write the contents of the file.

For more details, see open_readwrite() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call open_readwrite_finish() to get the result of the operation. If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. If the file is a directory, a Gio::Error with IS_DIRECTORY will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  io_priority | The I/O priority of the request.

Since glibmm 2.24:

## open_readwrite_finish()

Glib::RefPtr<FileIOStream> Gio::File::open_readwrite_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous file read operation started with g_file_open_readwrite_async().

Since glibmm 2.22:

Parameters

  res | A AsyncResult.

Returns
  A FileIOStream or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## operator=()

File& Gio::File::operator= | ( | File&& | src | ) |

noexcept

## poll_mountable() [1/2]

void Gio::File::poll_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Polls a file of type Mountable.

Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.

When this operation has completed, slot will be called and the operation can be finalized with stop_mountable_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  slot | A callback to call when the request is satisfied.
  cancellable | A Cancellable object.

Since glibmm 2.24:

## poll_mountable() [2/2]

void Gio::File::poll_mountable | ( | const SlotAsyncReady& | slot | ) |

Polls a file of type Mountable.

Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.

When this operation has completed, slot will be called and the operation can be finalized with stop_mountable_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  slot | A callback to call when the request is satisfied.

Since glibmm 2.24:

## poll_mountable_finish()

bool Gio::File::poll_mountable_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes a poll operation.

See g_file_poll_mountable() for details.

Finish an asynchronous poll operation that was polled with g_file_poll_mountable().

Since glibmm 2.22:

Parameters

  result | A AsyncResult.

Returns
  `true` if the operation finished successfully. `false` otherwise.

Exceptions

  Glib::Error |

## query_default_handler() [1/2]

Glib::RefPtr<AppInfo> Gio::File::query_default_handler | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Returns the AppInfo that is registered as the default application to handle the file specified by file.

If cancellable is not `nullptr`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.

Parameters

  cancellable | Optional Cancellable object, `nullptr` to ignore.

Returns
  A AppInfo if the handle was found, `nullptr` if there were errors. When you are done with it, release it with Glib::object_unref().

Exceptions

  Glib::Error |

## query_default_handler() [2/2]

Glib::RefPtr<AppInfo> Gio::File::query_default_handler | ( |  | ) |

A query_default_handler() convenience overload.

## query_exists() [1/2]

bool Gio::File::query_exists | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) | const

Utility function to check if a particular file exists.

This is implemented using query_info() and as such does blocking I/O.

Note that in many cases it is racy to first check for file existence and then execute something based on the outcome of that, because the file might have been created or removed in between the operations. The general approach to handling that is to not check, but just do the operation and handle the errors as they come.

As an example of race-free checking, take the case of reading a file, and if it doesn't exist, creating it. There are two racy versions: read it, and on error create it; and: check if it exists, if not create it. These can both result in two processes creating the file (with perhaps a partially written file as the result). The correct approach is to always try to create the file with File::create() which will either atomically create the file or fail with a Gio::Error exception with EXISTS.

However, in many cases an existence check is useful in a user interface, for instance to make a menu item sensitive/insensitive, so that you don't have to fool users that something is possible and then just show and error dialog. If you do this, you should make sure to also handle the errors that can happen due to races when you execute the operation.

Parameters

  cancellable | Optional Cancellable object, `nullptr` to ignore.

Returns
  `true` if the file exists (and can be detected without error), `false` otherwise (or if cancelled).

## query_exists() [2/2]

bool Gio::File::query_exists | ( |  | ) | const

A query_exists() convenience overload.

## query_file_type() [1/2]

FileType Gio::File::query_file_type | ( | FileQueryInfoFlags | flags,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  | const

Utility function to inspect the FileType of a file.

This is implemented using g_file_query_info() and as such does blocking I/O.

The primary use case of this method is to check if a file is a regular file, directory, or symlink.

Since glibmm 2.18:

Parameters

  flags | A set of FileQueryInfoFlags passed to g_file_query_info().
  cancellable | Optional Cancellable object, `nullptr` to ignore.

Returns
  The FileType of the file and FILE_TYPE_UNKNOWN if the file does not exist.

## query_file_type() [2/2]

FileType Gio::File::query_file_type | ( | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE` | ) | const

Utility function to inspect the FileType of a file.

This is implemented using query_info() and as such does blocking I/O.

The primary use case of this method is to check if a file is a regular file, directory, or symlink.

Parameters

  flags | a set of FileQueryInfoFlags passed to query_info().

Returns
  The FileType of the file, or FILE_TYPE_UNKNOWN if the file does not exist.

Since glibmm 2.18:

## query_filesystem_info() [1/2]

Glib::RefPtr<FileInfo> Gio::File::query_filesystem_info | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | attributes = `"*"`
| ) |  |

Similar to query_info(), but obtains information about the filesystem the file is on, rather than the file itself.

For instance the amount of space availible and the type of the filesystem.

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if its not possible to read a particular requested attribute from a file, it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "fs:*" means all attributes in the fs namespace. The standard namespace for filesystem attributes is "fs". Common attributes of interest are FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem in bytes), FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes availible), and FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem).

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  cancellable | A Cancellable object.
  attributes | An attribute query string.

Returns
  A FileInfo or an empty RefPtr if there was an error.

## query_filesystem_info() [2/2]

Glib::RefPtr<FileInfo> Gio::File::query_filesystem_info | ( | const std::string & | attributes = `"*"` | ) |

Similar to query_info(), but obtains information about the filesystem the file is on, rather than the file itself.

For instance the amount of space availible and the type of the filesystem.

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if its not possible to read a particular requested attribute from a file, it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "fs:*" means all attributes in the fs namespace. The standard namespace for filesystem attributes is "fs". Common attributes of interest are FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem in bytes), FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes availible), and FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem).

If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  attributes | An attribute query string.

Returns
  A FileInfo or an empty RefPtr if there was an error.

## query_filesystem_info_async() [1/2]

void Gio::File::query_filesystem_info_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | attributes = `"*"`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  | const

Asynchronously gets the requested information about the filesystem that the file is on.

The result is a FileInfo object that contains key-value attributes (such as type or size for the file).

For more details, see query_filesystem_info() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call query_filesystem_info_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  attributes | An attribute query string.
  io_priority | The I/O priority of the request.

## query_filesystem_info_async() [2/2]

void Gio::File::query_filesystem_info_async | ( | const SlotAsyncReady& | slot,
|  | const std::string & | attributes = `"*"`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  | const

Asynchronously gets the requested information about the filesystem that the file is on.

The result is a FileInfo object that contains key-value attributes (such as type or size for the file).

For more details, see query_filesystem_info() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call query_filesystem_info_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  attributes | An attribute query string.
  io_priority | The I/O priority of the request.

## query_filesystem_info_finish()

Glib::RefPtr<FileInfo> Gio::File::query_filesystem_info_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous filesystem info query.

See g_file_query_filesystem_info_async().

Parameters

  res | A AsyncResult.

Returns
  FileInfo for given file or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## query_info() [1/2]

Glib::RefPtr<FileInfo> Gio::File::query_info | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | attributes = `"*"`,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`
| ) |  | const

Gets the requested information about the file.

The result is a FileInfo object that contains key-value attributes (such as the type or size of the file).

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user". The standard attributes are available as defines, like G_FILE_ATTRIBUTE_STANDARD_NAME.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass FILE_QUERY_INFO_NOFOLLOW_SYMLINKS in flags the information about the symlink itself will be returned. Also, for symlinks that point to non-existing files the information about the symlink itself will be returned.

If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  cancellable | A Cancellable object.
  attributes | An attribute query string.
  flags | A set of FileQueryInfoFlags.

Returns
  a FileInfo for the file, or an empty RefPtr on error.

## query_info() [2/2]

Glib::RefPtr<FileInfo> Gio::File::query_info | ( | const std::string & | attributes = `"*"`,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`
| ) |  | const

Gets the requested information about the file.

The result is a FileInfo object that contains key-value attributes (such as the type or size of the file).

The attribute value is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user". The standard attributes are available as defines, like G_FILE_ATTRIBUTE_STANDARD_NAME.

For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass FILE_QUERY_INFO_NOFOLLOW_SYMLINKS in flags the information about the symlink itself will be returned. Also, for symlinks that point to non-existing files the information about the symlink itself will be returned.

If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  attributes | An attribute query string.
  flags | A set of FileQueryInfoFlags.

Returns
  a FileInfo for the file, or an empty RefPtr on error.

## query_info_async() [1/2]

void Gio::File::query_info_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | attributes = `"*"`,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  | const

Asynchronously gets the requested information about specified file.

The result is a FileInfo object that contains key-value attributes (such as type or size for the file).

For more details, see query_info() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call query_info_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  attributes | An attribute query string.
  flags | A set of FileQueryInfoFlags.
  io_priority | The I/O priority of the request.

## query_info_async() [2/2]

void Gio::File::query_info_async | ( | const SlotAsyncReady& | slot,
|  | const std::string & | attributes = `"*"`,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  | const

Asynchronously gets the requested information about specified file.

The result is a FileInfo object that contains key-value attributes (such as type or size for the file).

For more details, see query_info() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call query_info_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  attributes | An attribute query string.
  flags | A set of FileQueryInfoFlags.
  io_priority | The I/O priority of the request.

## query_info_finish()

Glib::RefPtr<FileInfo> Gio::File::query_info_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous file info query.

See g_file_query_info_async().

Parameters

  res | A AsyncResult.

Returns
  FileInfo for given file or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## query_settable_attributes() [1/2]

Glib::RefPtr<FileAttributeInfoList> Gio::File::query_settable_attributes | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Obtain the list of settable attributes for the file.

Parameters

  cancellable | Optional Cancellable object, `nullptr` to ignore.

Returns
  A FileAttributeInfoList describing the settable attributes. When you are done with it, release it with g_file_attribute_info_list_unref().

Exceptions

  Glib::Error |

## query_settable_attributes() [2/2]

Glib::RefPtr<FileAttributeInfoList> Gio::File::query_settable_attributes | ( |  | ) |

A query_settable_attributes() convenience overload.

## query_writable_namespaces() [1/2]

Glib::RefPtr<FileAttributeInfoList> Gio::File::query_writable_namespaces | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Obtain the list of attribute namespaces where new attributes can be created by a user.

An example of this is extended attributes (in the "xattr" namespace).

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  cancellable | Cancellable object.

Returns
  A FileAttributeInfoList describing the writable namespaces. When you are done with it, release it with g_file_attribute_info_list_unref().

Exceptions

  Glib::Error |

## query_writable_namespaces() [2/2]

Glib::RefPtr<FileAttributeInfoList> Gio::File::query_writable_namespaces | ( |  | ) |

A query_writable_namespaces() convenience overload.

## read() [1/2]

Glib::RefPtr<FileInputStream> Gio::File::read | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Opens a file for reading.

The result is a FileInputStream that can be used to read the contents of the file.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. If the file is a directory, a Gio::Error with IS_DIRECTORY will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  cancellable | A Cancellable.

Returns
  FileInputStream or `nullptr` on error.

Exceptions

  Glib::Error |

## read() [2/2]

Glib::RefPtr<FileInputStream> Gio::File::read | ( |  | ) |

A read() convenience overload.

## read_async() [1/2]

void Gio::File::read_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously opens the file for reading.

For more details, see read() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call read_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  io_priority | The I/O priority of the request.

## read_async() [2/2]

void Gio::File::read_async | ( | const SlotAsyncReady& | slot,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously opens the file for reading.

For more details, see read() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call read_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  io_priority | The I/O priority of the request.

## read_finish()

Glib::RefPtr<FileInputStream> Gio::File::read_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous file read operation started with g_file_read_async().

Parameters

  res | A AsyncResult.

Returns
  A FileInputStream or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## remove() [1/2]

bool Gio::File::remove | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Deletes a file.

If the file is a directory, it will only be deleted if it is empty. The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Glib::FileError with ERROR_CANCELLED will be thrown.

Parameters

  cancellable | A Cancellable object which can be used to cancel the operation.

Returns
  `true` if the file was deleted. `false` otherwise.

## remove() [2/2]

bool Gio::File::remove | ( |  | ) |

A remove() convenience overload.

## remove_async() [1/2]

void Gio::File::remove_async | ( | const SlotAsyncReady& | slot_ready,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously delete a file.

If the file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().

Parameters

  slot_ready | A SlotAsyncReady to call when the request is satisfied
  cancellable | A Cancellable object which can be used to cancel the operation
  io_priority | The I/O priority of the request

Since glibmm 2.34:

## remove_async() [2/2]

void Gio::File::remove_async | ( | const SlotAsyncReady& | slot_ready,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously delete a file.

If the file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().

Parameters

  slot_ready | A SlotAsyncReady to call when the request is satisfied
  io_priority | The I/O priority of the request

Since glibmm 2.34:

## remove_finish()

bool Gio::File::remove_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes deleting a file started with g_file_delete_async().

Virtual: delete_file_finish

Since glibmm 2.34:

Parameters

  result | A AsyncResult.

Returns
  `true` if the file was deleted. `false` otherwise.

Exceptions

  Glib::Error |

## replace() [1/2]

Glib::RefPtr<FileOutputStream> Gio::File::replace | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | etag = `std::string()`,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Returns an output stream for overwriting the file, possibly creating a backup copy of the file first.

This will try to replace the file in the safest way possible so that any errors during the writing will not affect an already existing copy of the file. For instance, for local files it may write to a temporary file and then atomically rename over the destination when the stream is closed.

By default files created are generally readable by everyone, but if you pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If you pass in an etag value, then this value is compared to the current entity tag of the file, and if they differ a Gio::Error with WRONG_ETAG will be thrown. This generally means that the file has been changed since you last read it. You can get the new etag from FileOutputStream::get_etag() after you've finished writing and closed the FileOutputStream. When you load a new file you can use FileInputStream::query_info() to get the etag of the file.

If make_backup is true, this function will attempt to make a backup of the current file before overwriting it. If this fails aa Gio::Error with CANT_CREATE_BACKUP will be thrown. If you want to replace anyway, try again with make_backup set to false.

If the file is a directory a Gio::Error with IS_DIRECTORY will be thrown, and if the file is some other form of non-regular file then aa Gio::Error with NOT_REGULAR_FILE will be thrown. Some file systems don't allow all file names, and may throw a Gio::Error with INVALID_FILENAME, and if the name is to longa Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  cancellable | A Cancellable object which can be used to cancel the operation.
  etag | An optional entity tag for the current Glib::File.
  make_backup | `true` if a backup should be created.
  flags | A set of FileCreateFlags.

Returns
  A FileOutputStream.

## replace() [2/2]

Glib::RefPtr<FileOutputStream> Gio::File::replace | ( | const std::string & | etag = `std::string()`,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Returns an output stream for overwriting the file, possibly creating a backup copy of the file first.

This will try to replace the file in the safest way possible so that any errors during the writing will not affect an already existing copy of the file. For instance, for local files it may write to a temporary file and then atomically rename over the destination when the stream is closed.

By default files created are generally readable by everyone, but if you pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.

If you pass in an etag value, then this value is compared to the current entity tag of the file, and if they differ a Gio::Error with WRONG_ETAG will be thrown. This generally means that the file has been changed since you last read it. You can get the new etag from FileOutputStream::get_etag() after you've finished writing and closed the FileOutputStream. When you load a new file you can use FileInputStream::query_info() to get the etag of the file.

If make_backup is true, this function will attempt to make a backup of the current file before overwriting it. If this fails aa Gio::Error with CANT_CREATE_BACKUP will be thrown. If you want to replace anyway, try again with make_backup set to false.

If the file is a directory a Gio::Error with IS_DIRECTORY will be thrown, and if the file is some other form of non-regular file then aa Gio::Error with NOT_REGULAR_FILE will be thrown. Some file systems don't allow all file names, and may throw a Gio::Error with INVALID_FILENAME, and if the name is to longa Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.

Parameters

  etag | An optional entity tag for the current Glib::File.
  make_backup | `true` if a backup should be created.
  flags | A set of FileCreateFlags.

Returns
  A FileOutputStream.

## replace_async() [1/2]

void Gio::File::replace_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | etag = `std::string()`,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.

For more details, see replace() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call replace_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  etag | An entity tag for the current Gio::File.
  make_backup | true if a backup of the existing file should be made.
  flags | A set of FileCreateFlags.
  io_priority | The I/O priority of the request.

## replace_async() [2/2]

void Gio::File::replace_async | ( | const SlotAsyncReady& | slot,
|  | const std::string & | etag = `std::string()`,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.

For more details, see replace() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call replace_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  etag | An entity tag for the current Gio::File.
  make_backup | true if a backup of the existing file should be made.
  flags | A set of FileCreateFlags.
  io_priority | The I/O priority of the request.

## replace_contents() [1/4]

void Gio::File::replace_contents | ( | const char * | contents,
|  | gsize | length,
|  | const std::string & | etag,
|  | std::string & | new_etag,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Replaces the contents of the file with contents of length bytes.

If etag is specified (not an empty string) any existing file must have that etag, or a Gio::Error with WRONG_ETAG will be thrown.

If make_backup is `true`, this function will attempt to make a backup of the file.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

The returned new_etag can be used to verify that the file hasn't changed the next time it is saved over.

Parameters

  contents | A string containing the new contents for the file.
  length | The length of contents in bytes.
  etag | The old entity tag for the document.
  make_backup | `true` if a backup should be created.
  flags | A set of FileCreateFlags.
  new_etag | A location to a new entity tag for the document.
  cancellable | A Cancellable object.

## replace_contents() [2/4]

void Gio::File::replace_contents | ( | const char * | contents,
|  | gsize | length,
|  | const std::string & | etag,
|  | std::string & | new_etag,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Replaces the contents of the file with contents of length bytes.

If etag is specified (not an empty string) any existing file must have that etag, or a Gio::Error with WRONG_ETAG will be thrown.

If make_backup is `true`, this function will attempt to make a backup of the file.

The returned new_etag can be used to verify that the file hasn't changed the next time it is saved over.

Parameters

  contents | A string containing the new contents for the file.
  length | The length of contents in bytes.
  etag | The old entity tag for the document.
  make_backup | `true` if a backup should be created.
  flags | A set of FileCreateFlags.
  new_etag | A location to a new entity tag for the document.

## replace_contents() [3/4]

void Gio::File::replace_contents | ( | const std::string & | contents,
|  | const std::string & | etag,
|  | std::string & | new_etag,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Replaces the contents of the file with contents.

If etag is specified (not an empty string) any existing file must have that etag, or a Gio::Error with WRONG_ETAG will be thrown.

If make_backup is `true`, this function will attempt to make a backup of the file.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

The returned new_etag can be used to verify that the file hasn't changed the next time it is saved over.

Parameters

  contents | A string containing the new contents for the file.
  etag | The old entity tag for the document.
  make_backup | `true` if a backup should be created.
  flags | A set of FileCreateFlags.
  new_etag | A location to a new entity tag for the document.
  cancellable | A Cancellable object.

## replace_contents() [4/4]

void Gio::File::replace_contents | ( | const std::string & | contents,
|  | const std::string & | etag,
|  | std::string & | new_etag,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Replaces the contents of the file with contents.

If etag is specified (not an empty string) any existing file must have that etag, or a Gio::Error with WRONG_ETAG will be thrown.

If make_backup is `true`, this function will attempt to make a backup of the file.

The returned new_etag can be used to verify that the file hasn't changed the next time it is saved over.

Parameters

  contents | A string containing the new contents for the file.
  etag | The old entity tag for the document.
  make_backup | `true` if a backup should be created.
  flags | A set of FileCreateFlags.
  new_etag | A location to a new entity tag for the document.

## replace_contents_async() [1/4]

void Gio::File::replace_contents_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const char * | contents,
|  | gsize | length,
|  | const std::string & | etag,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Starts an asynchronous replacement of the file with the given contents of length bytes.

etag will replace the document's current entity tag.

When this operation has completed, slot will be called and the operation can be finalized with replace_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If make_backup is true, this function will attempt to make a backup of the file.

Parameters

  slot | A callback to call when the request is satisfied.
  cancellable | A Cancellable object.
  contents | String of contents to replace the file with.
  length | The length of contents in bytes.
  etag | a new entity tag for the file.
  make_backup | true if a backup should be created.
  flags | A set of FileCreateFlags.

## replace_contents_async() [2/4]

void Gio::File::replace_contents_async | ( | const SlotAsyncReady& | slot,
|  | const char * | contents,
|  | gsize | length,
|  | const std::string & | etag,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Starts an asynchronous replacement of the file with the given contents of length bytes.

etag will replace the document's current entity tag.

When this operation has completed, slot will be called and the operation can be finalized with replace_contents_finish().

If make_backup is true, this function will attempt to make a backup of the file.

Parameters

  slot | A callback to call when the request is satisfied.
  contents | String of contents to replace the file with.
  length | The length of contents in bytes.
  etag | a new entity tag for the file.
  make_backup | true if a backup should be created.
  flags | A set of FileCreateFlags.

## replace_contents_async() [3/4]

void Gio::File::replace_contents_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | contents,
|  | const std::string & | etag,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Starts an asynchronous replacement of the file with the given contents of length bytes.

etag will replace the document's current entity tag.

When this operation has completed, slot will be called and the operation can be finalized with replace_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If make_backup is true, this function will attempt to make a backup of the file.

Parameters

  slot | A callback to call when the request is satisfied.
  cancellable | A Cancellable object.
  contents | String of contents to replace the file with.
  etag | a new entity tag for the file.
  make_backup | true if a backup should be created.
  flags | A set of FileCreateFlags.

## replace_contents_async() [4/4]

void Gio::File::replace_contents_async | ( | const SlotAsyncReady& | slot,
|  | const std::string & | contents,
|  | const std::string & | etag,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Starts an asynchronous replacement of the file with the given contents.

etag will replace the document's current entity tag.

When this operation has completed, slot will be called and the operation can be finalized with replace_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If make_backup is true, this function will attempt to make a backup of the file.

Parameters

  slot | A callback to call when the request is satisfied.
  contents | String of contents to replace the file with.
  etag | a new entity tag for the file.
  make_backup | true if a backup should be created.
  flags | A set of FileCreateFlags.

## replace_contents_bytes_async() [1/2]

void Gio::File::replace_contents_bytes_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::RefPtr< const Glib::Bytes >& | contents,
|  | const std::string & | etag,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Same as replace_contents_async() but takes a Gio::Bytes input instead.

When this operation has completed, slot will be called and the operation can be finalized with replace_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If make_backup is true, this function will attempt to make a backup of the file.

Parameters

  slot | A callback to call when the request is satisfied.
  cancellable | A Cancellable object.
  contents | Bytes of contents to replace the file with.
  etag | a new entity tag for the file.
  make_backup | true if a backup should be created.
  flags | A set of FileCreateFlags.

## replace_contents_bytes_async() [2/2]

void Gio::File::replace_contents_bytes_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< const Glib::Bytes >& | contents,
|  | const std::string & | etag,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Same as replace_contents_async() but takes a Gio::Bytes input instead.

When this operation has completed, slot will be called and the operation can be finalized with replace_contents_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

If make_backup is true, this function will attempt to make a backup of the file.

Parameters

  slot | A callback to call when the request is satisfied.
  contents | Bytes of contents to replace the file with.
  etag | a new entity tag for the file.
  make_backup | true if a backup should be created.
  flags | A set of FileCreateFlags.

## replace_contents_finish() [1/2]

void Gio::File::replace_contents_finish | ( | const Glib::RefPtr< AsyncResult >& | result,
|  | std::string & | new_etag
| ) |  |

Finishes an asynchronous replace of the given file .

See replace_contents_async(). Sets new_etag to the new entity tag for the document.

Parameters

  result | A AsyncResult.
  new_etag | A location of a new entity tag for the document.

## replace_contents_finish() [2/2]

void Gio::File::replace_contents_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes an asynchronous replace of the given file .

See replace_contents_async(). Sets new_etag to the new entity tag for the document.

Parameters

  result | A AsyncResult. for the document.

## replace_finish()

Glib::RefPtr<FileOutputStream> Gio::File::replace_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous file replace operation started with g_file_replace_async().

Parameters

  res | A AsyncResult.

Returns
  A FileOutputStream, or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## replace_readwrite() [1/2]

Glib::RefPtr<FileIOStream> Gio::File::replace_readwrite | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | etag = `std::string()`,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first.

If the file doesn't exist, it will be created.

For details about the behaviour, see replace() which does the same thing but returns an output stream only.

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

Parameters

  cancellable | A Cancellable object which can be used to cancel the operation.
  etag | An optional entity tag for the current Glib::File.
  make_backup | `true` if a backup should be created.
  flags | A set of FileCreateFlags.

Returns
  A FileOutputStream.

Since glibmm 2.24:

## replace_readwrite() [2/2]

Glib::RefPtr<FileIOStream> Gio::File::replace_readwrite | ( | const std::string & | etag = `std::string()`,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`
| ) |  |

Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first.

If the file doesn't exist, it will be created.

For details about the behaviour, see replace() which does the same thing but returns an output stream only.

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

Parameters

  etag | An optional entity tag for the current Glib::File.
  make_backup | `true` if a backup should be created.
  flags | A set of FileCreateFlags.

Returns
  A FileOutputStream.

Since glibmm 2.24:

## replace_readwrite_async() [1/2]

void Gio::File::replace_readwrite_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | etag = `std::string()`,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asyncronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.

For more details, see replace_readwrite() which is the synchronous version of this call.

When the operation is finished, slot will be called. You can then call replace_readwrite_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  etag | An entity tag for the current Gio::File.
  make_backup | true if a backup of the existing file should be made.
  flags | A set of FileCreateFlags.
  io_priority | The I/O priority of the request.

Since glibmm 2.24:

## replace_readwrite_async() [2/2]

void Gio::File::replace_readwrite_async | ( | const SlotAsyncReady& | slot,
|  | const std::string & | etag = `std::string()`,
|  | bool | make_backup = `false`,
|  | FileCreateFlags | flags = `FILE_CREATE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asyncronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.

For more details, see replace_readwrite() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call replace_readwrite_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  etag | An entity tag for the current Gio::File.
  make_backup | true if a backup of the existing file should be made.
  flags | A set of FileCreateFlags.
  io_priority | The I/O priority of the request.

Since glibmm 2.24:

## replace_readwrite_finish()

Glib::RefPtr<FileIOStream> Gio::File::replace_readwrite_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an asynchronous file replace operation started with g_file_replace_readwrite_async().

Since glibmm 2.22:

Parameters

  res | A AsyncResult.

Returns
  A FileIOStream, or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## resolve_relative_path()

Glib::RefPtr<File> Gio::File::resolve_relative_path | ( | const std::string & | relative_path | ) | const

Resolves a relative path for file to an absolute path.

This call does no blocking I/O.

Parameters

  relative_path | A given relative path string.

Returns
  File to the resolved path. `nullptr` if relative_path is `nullptr` or if file is invalid. Free the returned object with Glib::object_unref().

## set_attribute_byte_string() [1/2]

bool Gio::File::set_attribute_byte_string | ( | const std::string & | attribute,
|  | const std::string & | value,
|  | FileQueryInfoFlags | flags,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Sets attribute of type G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to value.

If attribute is of a different type, this operation will fail, returning `false`.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  attribute | A string containing the attribute's name.
  value | A string containing the attribute's new value.
  flags | A FileQueryInfoFlags.
  cancellable | Cancellable object.

Returns
  `true` if the attribute was successfully set to value in the file, `false` otherwise.

Exceptions

  Glib::Error |

## set_attribute_byte_string() [2/2]

bool Gio::File::set_attribute_byte_string | ( | const std::string & | attribute,
|  | const std::string & | value,
|  | FileQueryInfoFlags | flags
| ) |  |

A set_attribute_byte_string() convenience overload.

## set_attribute_int32() [1/2]

bool Gio::File::set_attribute_int32 | ( | const std::string & | attribute,
|  | gint32 | value,
|  | FileQueryInfoFlags | flags,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Sets attribute of type G_FILE_ATTRIBUTE_TYPE_INT32 to value.

If attribute is of a different type, this operation will fail.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  attribute | A string containing the attribute's name.
  value | A #gint32 containing the attribute's new value.
  flags | A FileQueryInfoFlags.
  cancellable | Cancellable object.

Returns
  `true` if the attribute was successfully set to value in the file, `false` otherwise.

Exceptions

  Glib::Error |

## set_attribute_int32() [2/2]

bool Gio::File::set_attribute_int32 | ( | const std::string & | attribute,
|  | gint32 | value,
|  | FileQueryInfoFlags | flags
| ) |  |

A set_attribute_int32() convenience overload.

## set_attribute_int64() [1/2]

bool Gio::File::set_attribute_int64 | ( | const std::string & | attribute,
|  | gint64 | value,
|  | FileQueryInfoFlags | flags,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Sets attribute of type G_FILE_ATTRIBUTE_TYPE_INT64 to value.

If attribute is of a different type, this operation will fail.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  attribute | A string containing the attribute's name.
  value | A #guint64 containing the attribute's new value.
  flags | A FileQueryInfoFlags.
  cancellable | Cancellable object.

Returns
  `true` if the attribute was successfully set, `false` otherwise.

Exceptions

  Glib::Error |

## set_attribute_int64() [2/2]

bool Gio::File::set_attribute_int64 | ( | const std::string & | attribute,
|  | gint64 | value,
|  | FileQueryInfoFlags | flags
| ) |  |

A set_attribute_int64() convenience overload.

## set_attribute_string() [1/2]

bool Gio::File::set_attribute_string | ( | const std::string & | attribute,
|  | const std::string & | value,
|  | FileQueryInfoFlags | flags,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Sets attribute of type G_FILE_ATTRIBUTE_TYPE_STRING to value.

If attribute is of a different type, this operation will fail.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  attribute | A string containing the attribute's name.
  value | A string containing the attribute's value.
  flags | FileQueryInfoFlags.
  cancellable | Cancellable object.

Returns
  `true` if the attribute was successfully set, `false` otherwise.

Exceptions

  Glib::Error |

## set_attribute_string() [2/2]

bool Gio::File::set_attribute_string | ( | const std::string & | attribute,
|  | const std::string & | value,
|  | FileQueryInfoFlags | flags
| ) |  |

A set_attribute_string() convenience overload.

## set_attribute_uint32() [1/2]

bool Gio::File::set_attribute_uint32 | ( | const std::string & | attribute,
|  | guint32 | value,
|  | FileQueryInfoFlags | flags,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Sets attribute of type G_FILE_ATTRIBUTE_TYPE_UINT32 to value.

If attribute is of a different type, this operation will fail.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  attribute | A string containing the attribute's name.
  value | A #guint32 containing the attribute's new value.
  flags | A FileQueryInfoFlags.
  cancellable | Cancellable object.

Returns
  `true` if the attribute was successfully set to value in the file, `false` otherwise.

Exceptions

  Glib::Error |

## set_attribute_uint32() [2/2]

bool Gio::File::set_attribute_uint32 | ( | const std::string & | attribute,
|  | guint32 | value,
|  | FileQueryInfoFlags | flags
| ) |  |

A set_attribute_uint32() convenience overload.

## set_attribute_uint64() [1/2]

bool Gio::File::set_attribute_uint64 | ( | const std::string & | attribute,
|  | guint64 | value,
|  | FileQueryInfoFlags | flags,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Sets attribute of type G_FILE_ATTRIBUTE_TYPE_UINT64 to value.

If attribute is of a different type, this operation will fail.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  attribute | A string containing the attribute's name.
  value | A #guint64 containing the attribute's new value.
  flags | A FileQueryInfoFlags.
  cancellable | Cancellable object.

Returns
  `true` if the attribute was successfully set to value in the file, `false` otherwise.

Exceptions

  Glib::Error |

## set_attribute_uint64() [2/2]

bool Gio::File::set_attribute_uint64 | ( | const std::string & | attribute,
|  | guint64 | value,
|  | FileQueryInfoFlags | flags
| ) |  |

A set_attribute_uint64() convenience overload.

## set_attributes_async() [1/2]

void Gio::File::set_attributes_async | ( | const Glib::RefPtr< FileInfo >& | info,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously sets the attributes of file with info.

For more details, see set_attributes_from_info() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call set_attributes_finish() to get the result of the operation.

Parameters

  info | A FileInfo.
  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | A set of FileQueryInfoFlags.
  io_priority | The I/O priority of the request.

## set_attributes_async() [2/2]

void Gio::File::set_attributes_async | ( | const Glib::RefPtr< FileInfo >& | info,
|  | const SlotAsyncReady& | slot,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously sets the attributes of file with info.

For more details, see set_attributes_from_info() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call set_attributes_finish() to get the result of the operation.

Parameters

  info | A FileInfo.
  slot | A callback slot which will be called when the request is satisfied.
  flags | A set of FileQueryInfoFlags.
  io_priority | The I/O priority of the request.

## set_attributes_finish()

bool Gio::File::set_attributes_finish | ( | const Glib::RefPtr< AsyncResult >& | result,
|  | const Glib::RefPtr< FileInfo >& | info
| ) |  |

## set_attributes_from_info() [1/2]

bool Gio::File::set_attributes_from_info | ( | const Glib::RefPtr< FileInfo >& | info,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`
| ) |  |

Tries to set all attributes in the FileInfo on the target values, not stopping on the first error.

If there is any error during this operation then a Gio::Error will be thrown. Error on particular fields are flagged by setting the "status" field in the attribute value to FILE_ATTRIBUTE_STATUS_ERROR_SETTING, which means you can also detect further errors.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  info | A FileInfo.
  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | A set of FileQueryInfoFlags.

Returns
  `true` if there was any error, `false` otherwise.

## set_attributes_from_info() [2/2]

bool Gio::File::set_attributes_from_info | ( | const Glib::RefPtr< FileInfo >& | info,
|  | FileQueryInfoFlags | flags = `FILE_QUERY_INFO_NONE`
| ) |  |

Tries to set all attributes in the FileInfo on the target values, not stopping on the first error.

If there is any error during this operation then a Gio::Error will be thrown. Error on particular fields are flagged by setting the "status" field in the attribute value to FILE_ATTRIBUTE_STATUS_ERROR_SETTING, which means you can also detect further errors.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  info | A FileInfo.
  flags | A set of FileQueryInfoFlags.

Returns
  `true` if there was any error, `false` otherwise.

## set_display_name() [1/2]

Glib::RefPtr<File> Gio::File::set_display_name | ( | const Glib::ustring& | display_name,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Renames file to the specified display name.

The display name is converted from UTF8 to the correct encoding for the target filesystem if possible and the file is renamed to this.

If you want to implement a rename operation in the user interface the edit name (G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) should be used as the initial value in the rename widget, and then the result after editing should be passed to g_file_set_display_name().

On success the resulting converted filename is returned.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  display_name | A string.
  cancellable | Cancellable object.

Returns
  A File specifying what file was renamed to, or `nullptr` if there was an error.

Exceptions

  Glib::Error |

## set_display_name() [2/2]

Glib::RefPtr<File> Gio::File::set_display_name | ( | const Glib::ustring& | display_name | ) |

A set_display_name() convenience overload.

## set_display_name_async() [1/2]

void Gio::File::set_display_name_async | ( | const Glib::ustring& | display_name,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously sets the display name for a given Gio::File.

For the synchronous version of this function, see set_display_name(). When the operation is finished, slot will be called. You can then call set_display_name_finish() to get the result of the operation.

Parameters

  display_name | A string.
  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  io_priority | The I/O priority of the request.

## set_display_name_async() [2/2]

void Gio::File::set_display_name_async | ( | const Glib::ustring& | display_name,
|  | const SlotAsyncReady& | slot,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously sets the display name for a given Gio::File.

For the synchronous version of this function, see set_display_name(). When the operation is finished, slot will be called. You can then call set_display_name_finish() to get the result of the operation.

Parameters

  display_name | A string.
  slot | A callback slot which will be called when the request is satisfied.
  io_priority | The I/O priority of the request.

## set_display_name_finish()

Glib::RefPtr<File> Gio::File::set_display_name_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes setting a display name started with g_file_set_display_name_async().

Parameters

  res | A AsyncResult.

Returns
  A File or `nullptr` on error. Free the returned object with Glib::object_unref().

Exceptions

  Glib::Error |

## start_mountable() [1/2]

void Gio::File::start_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::RefPtr< MountOperation >& | start_operation,
|  | DriveStartFlags | flags = `DRIVE_START_NONE`
| ) |  |

Starts a file of type Mountable.

Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.

When this operation has completed, slot will be called and the operation can be finalized with start_mountable_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  slot | A callback to call when the request is satisfied.
  cancellable | A Cancellable object.
  start_operation | A MountOperation, or `nullptr` to avoid user interaction.
  flags | Flags affecting the operation

Since glibmm 2.24:

## start_mountable() [2/2]

void Gio::File::start_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< MountOperation >& | start_operation,
|  | DriveStartFlags | flags = `DRIVE_START_NONE`
| ) |  |

Starts a file of type Mountable.

Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.

When this operation has completed, slot will be called and the operation can be finalized with start_mountable_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  slot | A callback to call when the request is satisfied.
  start_operation | A MountOperation, or `nullptr` to avoid user interaction.
  flags | Flags affecting the operation

Since glibmm 2.24:

## start_mountable_finish()

bool Gio::File::start_mountable_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes a start operation.

See g_file_start_mountable() for details.

Finish an asynchronous start operation that was started with g_file_start_mountable().

Since glibmm 2.22:

Parameters

  result | A AsyncResult.

Returns
  `true` if the operation finished successfully. `false` otherwise.

Exceptions

  Glib::Error |

## stop_mountable() [1/2]

void Gio::File::stop_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::RefPtr< MountOperation >& | start_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Stops a file of type Mountable.

Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.

When this operation has completed, slot will be called and the operation can be finalized with stop_mountable_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  slot | A callback to call when the request is satisfied.
  cancellable | A Cancellable object.
  start_operation | A MountOperation, or `nullptr` to avoid user interaction.
  flags | Flags affecting the operation

Since glibmm 2.24:

## stop_mountable() [2/2]

void Gio::File::stop_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< MountOperation >& | start_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Stops a file of type Mountable.

Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.

When this operation has completed, slot will be called and the operation can be finalized with stop_mountable_finish().

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

Parameters

  slot | A callback to call when the request is satisfied.
  start_operation | A MountOperation, or `nullptr` to avoid user interaction.
  flags | Flags affecting the operation

Since glibmm 2.24:

## stop_mountable_finish()

bool Gio::File::stop_mountable_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes an stop operation, see g_file_stop_mountable() for details.

Finish an asynchronous stop operation that was started with g_file_stop_mountable().

Since glibmm 2.22:

Parameters

  result | A AsyncResult.

Returns
  `true` if the operation finished successfully. `false` otherwise.

Exceptions

  Glib::Error |

## supports_thread_contexts()

bool Gio::File::supports_thread_contexts | ( |  | ) | const

Checks if file supports [thread-default contexts][g-main-context-push-thread-default-context].

If this returns `false`, you cannot perform asynchronous operations on file in a thread that has a thread-default context.

Since glibmm 2.22:

Returns
  Whether or not file supports thread-default contexts.

## trash() [1/2]

bool Gio::File::trash | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Sends file to the "Trashcan", if possible.

This is similar to deleting it, but the user can recover it before emptying the trashcan. Not all file systems support trashing, so this call can throw a Gio::Error with NOT_SUPPORTED.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  cancellable | Cancellable object.

Returns
  `true` on successful trash, `false` otherwise.

Exceptions

  Glib::Error |

## trash() [2/2]

bool Gio::File::trash | ( |  | ) |

A trash() convenience overload.

## trash_async() [1/2]

void Gio::File::trash_async | ( | const SlotAsyncReady& | slot_ready,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously sends the file to the Trash location, if possible.

Parameters

  slot_ready | A SlotAsyncReady to call when the request is satisfied
  cancellable | A Cancellable object which can be used to cancel the operation
  io_priority | The I/O priority of the request

Since glibmm 2.38:

## trash_async() [2/2]

void Gio::File::trash_async | ( | const SlotAsyncReady& | slot_ready,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Asynchronously sends the file to the Trash location, if possible.

Parameters

  slot_ready | A SlotAsyncReady to call when the request is satisfied
  io_priority | The I/O priority of the request

Since glibmm 2.38:

## trash_finish()

bool Gio::File::trash_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes an asynchronous file trashing operation, started with g_file_trash_async().

Virtual: trash_finish

Since glibmm 2.38:

Parameters

  result | A AsyncResult.

Returns
  `true` on successful trash, `false` otherwise.

Exceptions

  Glib::Error |

## unmount_mountable() [1/6]

void Gio::File::unmount_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Unmounts a file of type FILE_TYPE_MOUNTABLE.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

When the operation is finished, slot will be called. You can then call unmount_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  flags | Flags affecting the operation.

## unmount_mountable() [2/6]

void Gio::File::unmount_mountable | ( | const SlotAsyncReady& | slot,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Unmounts a file of type FILE_TYPE_MOUNTABLE.

When the operation is finished, slot will be called. You can then call unmount_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  flags | Flags affecting the operation.

## unmount_mountable() [3/6]

void Gio::File::unmount_mountable | ( | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE` | ) |

Unmounts a file of type FILE_TYPE_MOUNTABLE.

Parameters

  flags | Flags affecting the operation.

## unmount_mountable() [4/6]

void Gio::File::unmount_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Unmounts a file of type FILE_TYPE_MOUNTABLE.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.

When the operation is finished, slot will be called. You can then call unmount_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  cancellable | A Cancellable object which can be used to cancel the operation.
  mount_operation | A MountOperation
  flags | Flags affecting the operation.

Since glibmm 2.24:

## unmount_mountable() [5/6]

void Gio::File::unmount_mountable | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Unmounts a file of type FILE_TYPE_MOUNTABLE.

When the operation is finished, slot will be called. You can then call unmount_mountable_finish() to get the result of the operation.

Parameters

  slot | A callback slot which will be called when the request is satisfied.
  mount_operation | A MountOperation
  flags | Flags affecting the operation.

Since glibmm 2.24:

## unmount_mountable() [6/6]

void Gio::File::unmount_mountable | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | MountUnmountFlags | flags = `MOUNT_UNMOUNT_NONE`
| ) |  |

Unmounts a file of type FILE_TYPE_MOUNTABLE.

Parameters

  mount_operation | A MountOperation
  flags | Flags affecting the operation.

Since glibmm 2.24:

## unmount_mountable_finish()

bool Gio::File::unmount_mountable_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes an unmount operation, see g_file_unmount_mountable_with_operation() for details.

Finish an asynchronous unmount operation that was started with g_file_unmount_mountable_with_operation().

Since glibmm 2.22:

Parameters

  result | A AsyncResult.

Returns
  `true` if the operation finished successfully. `false` otherwise.

Exceptions

  Glib::Error |

## Friends And Related Function Documentation

## wrap()

Glib::RefPtr< Gio::File > wrap | ( | GFile * | 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.