# Gio::File Class Reference

File and directory handling. More...

Inherits Glib::Interface.

Collaboration diagram for Gio::File:
[legend]

List of all members.

## Public Types

typedef sigc::slot< void, goffset, goffset > | SlotFileProgress
| A signal handler would be, for instance: void on_file_progress(goffset current_num_bytes, goffset total_num_bytes);.
typedef sigc::slot< bool, const char*, goffset > | SlotReadMore
| A signal handler would be, for instance: bool on_read_more(const char* file_contents, goffset file_size);.

## Public Member Functions

virtual | ~File ()
GFile* | gobj ()
| Provides access to the underlying C GObject.
const GFile* | gobj () const
| Provides access to the underlying C GObject.
Glib::RefPtr< File > | dup () const
| Duplicates a File handle.
guint | hash () const
| Creates a hash value for a File.
bool | equal (const Glib::RefPtr< const File >& other) const
| Checks equality of two given Files.
std::string | get_basename () const
| Gets the base name (the last component of the path) for a given File.
std::string | get_path () const
| Gets the local pathname for File, if one exists.
std::string | get_uri () const
| Gets the URI for the file.
Glib::ustring | get_parse_name () const
| Gets the parse name of the file.
Glib::RefPtr< File > | get_parent () const
| Gets the parent directory for the file.
Glib::RefPtr< File > | get_child (const std::string& name) const
| Gets a child of file with basename equal to name.
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 UTF8 version of the name).
bool | has_prefix (const Glib::RefPtr< const File >& prefix) const
| Checks whether file has the prefix specified by prefix.
std::string | get_relative_path (const Glib::RefPtr< const File >& descendant) const
| Gets the path for descendant relative to parent.
Glib::RefPtr< File > | resolve_relative_path (const std::string& relative_path) const
| Resolves a relative path for file to an absolute path.
bool | is_native () const
| Checks to see if a file is native to the platform.
bool | has_uri_scheme (const std::string& uri_scheme) const
| Checks to see if a File has a given URI scheme.
std::string | get_uri_scheme () const
| Gets the URI scheme for a File.
Glib::RefPtr< FileInputStream > | read (const Glib::RefPtr< Cancellable >& cancellable)
| Opens a file for reading.
Glib::RefPtr< FileInputStream > | read ()
| Opens a file for reading.
void | read_async (const SlotAsyncReady&slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously opens the file for reading.
void | read_async (const SlotAsyncReady&slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously opens the file for reading.
Glib::RefPtr< FileInputStream > | read_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous file read operation started with g_file_read_async().
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.
Glib::RefPtr< FileOutputStream > | append_to (FileCreateFlags flags=FILE_CREATE_NONE)
| Gets an output stream for appending data to the file.
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.
Glib::RefPtr< FileOutputStream > | create_file (FileCreateFlags flags=FILE_CREATE_NONE)
| Creates a new file and returns an output stream for writing to it.
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.
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.
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.
void | append_to_async (const SlotAsyncReady&slot, FileCreateFlags flags=FILE_CREATE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously opens the file for appending.
Glib::RefPtr< FileOutputStream > | append_to_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous file append operation started with g_file_append_to_async().
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.
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.
Glib::RefPtr< FileOutputStream > | create_file_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous file create operation started with g_file_create_async().
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.
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.
Glib::RefPtr< FileOutputStream > | replace_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous file replace operation started with g_file_replace_async().
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.
Glib::RefPtr< FileInfo > | query_info (const std::string& attributes="*", FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE) const
| Gets the requested information about the file.
bool | query_exists (const Glib::RefPtr< Cancellable >& cancellable) const
| Utility function to check if a particular file exists.
bool | query_exists () const
| Utility function to check if a particular file exists.
FileType | query_file_type (FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable) const
| Utility function to inspect the FileType of a file.
FileType | query_file_type (FileQueryInfoFlags flags=FILE_QUERY_INFO_NONE) const
| Utility function to inspect the GFileType of a file.
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.
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.
Glib::RefPtr< FileInfo > | query_info_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous file info query.
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.
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.
Glib::RefPtr< Mount > | find_enclosing_mount (const Glib::RefPtr< Cancellable >& cancellable)
| Gets a Mount for the File.
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.
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.
Glib::RefPtr< FileInfo > | query_filesystem_info_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous filesystem info query.
Glib::RefPtr< Mount > | find_enclosing_mount ()
| Gets a Mount for the File.
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.
void | find_enclosing_mount_async (const SlotAsyncReady&slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Asynchronously gets the mount for the file.
Glib::RefPtr< Mount > | find_enclosing_mount_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous find mount request.
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.
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.
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.
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.
Glib::RefPtr< FileEnumerator > | enumerate_children_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an async enumerate children operation.
Glib::RefPtr< File > | set_display_name (const Glib::ustring& display_name, const Glib::RefPtr< Cancellable >& cancellable)
| Renames file to the specified display name.
Glib::RefPtr< File > | set_display_name (const Glib::ustring& display_name)
| Renames the file to the specified display name.
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.
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.
Glib::RefPtr< File > | set_display_name_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes setting a display name started with g_file_set_display_name_async().
bool | remove (const Glib::RefPtr< Cancellable >& cancellable)
| Deletes a file.
bool | remove ()
| Deletes a file.
bool | trash (const Glib::RefPtr< Cancellable >& cancellable)
| Sends file to the "Trashcan", if possible.
bool | trash ()
| Sends the file to the "Trashcan", if possible.
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.
bool | copy (const Glib::RefPtr< File >& destination, const SlotFileProgress&slot, FileCopyFlags flags=FILE_COPY_NONE)
bool | copy (const Glib::RefPtr< File >& destination, FileCopyFlags flags=FILE_COPY_NONE)
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.
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.
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.
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.
bool | copy_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes copying the file started with g_file_copy_async().
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.
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.
bool | make_directory ()
| Creates a directory.
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'.
bool | make_directory_with_parents ()
| Creates a directory and any parent directories that may not exist, similar to 'mkdir -p'.
bool | make_symbolic_link (const std::string& symlink_value, const Glib::RefPtr< Cancellable >& cancellable)
| Creates a symbolic link.
bool | make_symbolic_link (const std::string& symlink_value)
| Creates a symbolic link.
Glib::RefPtr < FileAttributeInfoList > | query_settable_attributes (const Glib::RefPtr< Cancellable >& cancellable)
| Obtain the list of settable attributes for the file.
Glib::RefPtr < FileAttributeInfoList > | query_settable_attributes ()
| Obtain the list of settable attributes for the file.
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.
Glib::RefPtr < FileAttributeInfoList > | query_writable_namespaces ()
| Obtain the list of attribute namespaces where new attributes can be created by a user.
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.
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.
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.
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.
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 FILE_ATTRIBUTE_TYPE_STRING to value.
bool | set_attribute_string (const std::string& attribute, const std::string&value, FileQueryInfoFlags flags)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_STRING to value.
bool | set_attribute_byte_string (const std::string& attribute, const std::string&value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_BYTE_STRING to value.
bool | set_attribute_byte_string (const std::string& attribute, const std::string&value, FileQueryInfoFlags flags)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_BYTE_STRING to value.
bool | set_attribute_uint32 (const std::string& attribute, guint32 value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_UINT32 to value.
bool | set_attribute_uint32 (const std::string& attribute, guint32 value, FileQueryInfoFlags flags)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_UINT32 to value.
bool | set_attribute_int32 (const std::string& attribute, gint32 value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_INT32 to value.
bool | set_attribute_int32 (const std::string& attribute, gint32 value, FileQueryInfoFlags flags)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_INT32 to value.
bool | set_attribute_uint64 (const std::string& attribute, guint64 value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_UINT64 to value.
bool | set_attribute_uint64 (const std::string& attribute, guint64 value, FileQueryInfoFlags flags)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_UINT64 to value.
bool | set_attribute_int64 (const std::string& attribute, gint64 value, FileQueryInfoFlags flags, const Glib::RefPtr< Cancellable >& cancellable)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_INT64 to value.
bool | set_attribute_int64 (const std::string& attribute, gint64 value, FileQueryInfoFlags flags)
| Sets attribute of type FILE_ATTRIBUTE_TYPE_INT64 to value.
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.
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.
void | mount_enclosing_volume (const SlotAsyncReady&slot, MountMountFlags flags=MOUNT_MOUNT_NONE)
| Starts a mount_operation, mounting the volume that contains the file.
void | mount_enclosing_volume (MountMountFlags flags=MOUNT_MOUNT_NONE)
| Starts a mount_operation, mounting the volume that contains the file.
bool | mount_enclosing_volume_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes a mount operation started by g_file_mount_enclosing_volume().
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.
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.
void | mount_mountable (const SlotAsyncReady&slot, MountMountFlags flags=MOUNT_MOUNT_NONE)
| Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction.
void | mount_mountable (MountMountFlags flags=MOUNT_MOUNT_NONE)
| Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction.
Glib::RefPtr< File > | mount_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes a mount operation.
void | unmount_mountable (const SlotAsyncReady&slot, const Glib::RefPtr< Cancellable >& cancellable, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE.
void | unmount_mountable (const SlotAsyncReady&slot, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE.
void | unmount_mountable (MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Unmounts a file of type FILE_TYPE_MOUNTABLE.
bool | unmount_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an unmount operation, see g_file_unmount_mountable() for details.
void | eject_mountable (const SlotAsyncReady&slot, const Glib::RefPtr< Cancellable >& cancellable, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable.
void | eject_mountable (const SlotAsyncReady&slot, MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable.
void | eject_mountable (MountUnmountFlags flags=MOUNT_UNMOUNT_NONE)
| Starts an asynchronous eject on a mountable.
bool | eject_mountable_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous eject operation started by g_file_eject_mountable().
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.
bool | copy_attributes (const Glib::RefPtr< File >& destination, FileCopyFlags flags=FILE_COPY_NONE)
| Copies the file attributes from source to destination.
Glib::RefPtr< FileMonitor > | monitor_directory (const Glib::RefPtr< Cancellable >& cancellable, FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a directory monitor for the given file.
Glib::RefPtr< FileMonitor > | monitor_directory (FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a directory monitor for the given file.
Glib::RefPtr< FileMonitor > | monitor_file (const Glib::RefPtr< Cancellable >& cancellable, FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a file monitor for the given file.
Glib::RefPtr< FileMonitor > | monitor_file (FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a file monitor for the given file.
Glib::RefPtr< FileMonitor > | monitor (const Glib::RefPtr< Cancellable >& cancellable, FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a file monitor for the given file.
Glib::RefPtr< FileMonitor > | monitor (FileMonitorFlags flags=FILE_MONITOR_NONE)
| Obtains a file monitor for the given file.
Glib::RefPtr< AppInfo > | query_default_handler (const Glib::RefPtr< Cancellable >& cancellable)
| Returns: a AppInfo if the handle was found, `0` if there were errors.
Glib::RefPtr< AppInfo > | query_default_handler ()
| Returns the AppInfo that is registered as the default application to handle the file specified by the file.
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.
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.
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.
bool | load_contents (char*& contents, gsize& length)
| Loads the content of the file into memory, returning the size of the data.
void | load_contents_async (const SlotAsyncReady&slot, const Glib::RefPtr< Cancellable >& cancellable)
| Starts an asynchronous load of the file's contents.
void | load_contents_async (const SlotAsyncReady&slot)
| Starts an asynchronous load of the file's contents.
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.
bool | load_contents_finish (const Glib::RefPtr< AsyncResult >& result, char*& contents, gsize& length)
| Finishes an asynchronous load of the file's contents.
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.
void | load_partial_contents_async (const SlotReadMore& slot_read_more, const SlotAsyncReady& slot_async_ready)
| Reads the partial contents of a file.
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().
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().
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.
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.
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.
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.
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.
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.
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.
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.
void | replace_contents_finish (const Glib::RefPtr< AsyncResult >& result, std::string& etag)
| Finishes an asynchronous replace of the given file .
void | replace_contents_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous replace of the given file .

## Static Public Member Functions

static void | add_interface (GType gtype_implementer)
static Glib::RefPtr< File > | create_for_path (const std::string& path)
| Constructs a File for a given path.
static Glib::RefPtr< File > | create_for_uri (const std::string& uri)
| Constructs a File for a given URI.
static Glib::RefPtr< File > | create_for_commandline_arg (const std::string&arg)
| Constructs a File for a given argument from the command line.
static Glib::RefPtr< File > | create_for_parse_name (const Glib::ustring& parse_name)

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

## 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

typedef sigc::slot<void, goffset, goffset> Gio::File::SlotFileProgress

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

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

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

## Constructor & Destructor Documentation

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

## Member Function Documentation

static void Gio::File::add_interface | ( | GType | gtype_implementer | ) | `[static]`

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.

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.

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.

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.

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

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

Parameters:

  | res | AsyncResult.

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

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

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

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

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

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

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

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

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.

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.

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

Finishes copying the file started with g_file_copy_async().

Parameters:

  | res | A AsyncResult.

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

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

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.

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

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.

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:

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

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:

  | flags | a set of FileCreateFlags.
  | io_priority | The I/O priority of the request.
  | 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.

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

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

Parameters:

  | res | A AsyncResult.

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

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.

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

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.

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.

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.

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

Starts an asynchronous eject on a mountable.

Parameters:

  | flags | Flags affecting the operation.

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.

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:

  | flags | Flags affecting the operation.
  | 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.

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

Finishes an asynchronous eject operation started by g_file_eject_mountable().

Parameters:

  | result | A AsyncResult.

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

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.

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.

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.

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.

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

Finishes an async enumerate children operation.

See g_file_enumerate_children_async().

Parameters:

  | res | A AsyncResult.

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

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:

  | file2 | The second File.

Returns:
  `true` if file1 and file2 are equal. `false` if either is not a File.

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

Gets a Mount for the File.

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

Parameters:

  | cancellable | Cancellable object.

Returns:
  A Mount where the file is located.

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 `0` 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 `0` on error.

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.

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.

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

Finishes an asynchronous find mount request.

See g_file_find_enclosing_mount_async().

Parameters:

  | res | A AsyncResult.

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

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 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 `0` if given File is invalid. The returned string should be freed with Glib::free() when no longer needed.

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

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 UTF8 version of the name).

If this function fails, it returns `0` and error will be set. This is very useful when constructing a GFile 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 `0` if the display name couldn't be converted. Free the returned object with Glib::object_unref().

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 `0` will be returned.

This call does no blocking i/o.

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

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 UTF8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF8 characters unescaped).

This call does no blocking i/o.

Returns:
  A string containing the File's parse name. The returned string should be freed with Glib::free() when no longer needed.

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

Gets the local pathname for File, if one exists.

This call does no blocking i/o.

Returns:
  String containing the File's path, or `0` if no such path exists. The returned string should be freed with Glib::free() when no longer needed.

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 `0` if descendant doesn't have parent as prefix. The returned string should be freed with Glib::free() when no longer needed.

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. The returned string should be freed with Glib::free() when no longer needed.

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

Gets the URI scheme for a File.

RFC 3986 decodes the scheme as: <programlisting> URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] </programlisting> 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. The returned string should be freed with Glib::free() when no longer needed.

const GFile* Gio::File::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

GFile* Gio::File::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

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

Checks whether file has the prefix specified by prefix.

In other word, if the names of inital elements of files 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.

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.

Parameters:

  | prefix | Input File.

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

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 `0`, not supported, or File is invalid.

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

Creates a hash value for a File.

This call does no blocking i/o.

Parameters:

  | file | gconstpointer to a File.

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.

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.

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:

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.

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:

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.

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.

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.

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:

  | res | 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:

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:

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

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.

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.

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:

  | res | 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:

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:

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

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

Creates a directory.

Note that this will only create a child directory of the immediate parent directory of the path or URI given by the File. To recursively create directories, see make_directory_with_parents(). This function will fail if the parent directory does not exist, throwing an exception with IO_ERROR_NOT_FOUND. If the file system doesn't support creating directories, this function will fail, throwing an exception with IO_ERROR_NOT_SUPPORTED.

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

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.

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

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, throwing an exception with IO_ERROR_NOT_SUPPORTED.

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

Since glibmm 2.18:

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.

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

If cancellable is not `0`, 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, `0` to ignore.

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

Since glibmm 2.18:

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

Creates a symbolic link.

Parameters:

  | symlink_value | A string with the value of the new symlink.

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

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.

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.
  | A | Cancellable object.

Returns:
  A FileMonitor for the file.

Since glibmm 2.18:

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:

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

Returns:
  A FileMonitor for the file.

Since glibmm 2.18:

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.

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.

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.
  | A | Cancellable object.

Returns:
  A FileMonitor for the file.

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:

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

Returns:
  A FileMonitor for the file.

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

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

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.

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.

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.

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.

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

Mounts a file of type FILE_TYPE_MOUNTABLE without user interaction.

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.

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.

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.

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 `0` on error. Free the returned object with Glib::object_unref().

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

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

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

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

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

Returns:
  A AppInfo if the handle was found, or an empty RefPtr if there were errors.

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

Returns: a AppInfo if the handle was found, `0` if there were errors.

Parameters:

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

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

bool Gio::File::query_exists | ( |  | ) | 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 existance and then execute something based on the outcome of that, because the file might have been created or removed inbetween 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 g_file_create() which will either atomically create the file or throw a Gio::Error with EXISTS.

However, in many cases an existance 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.

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

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, `0` to ignore.

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

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

Utility function to inspect the GFileType 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(). The FileType of the file, or FILE_TYPE_UNKNOWN if the file does not exist.

Since glibmm 2.18:

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.

Parameters:

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

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

Since glibmm 2.18:

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.

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.

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.

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.

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

Finishes an asynchronous filesystem info query.

See g_file_query_filesystem_info_async().

Parameters:

  | res | A AsyncResult.

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

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.

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.

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.

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.

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

Finishes an asynchronous file info query.

See g_file_query_info_async().

Parameters:

  | res | A AsyncResult.

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

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

Obtain the list of settable attributes for the file.

Returns: a FileAttributeInfoList describing the settable attributes.

Returns:
  A FileAttributeInfoList describing the settable attributes.

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

Obtain the list of settable attributes for the file.

Returns: a FileAttributeInfoList describing the settable attributes.

Parameters:

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

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

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

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

Returns:
  A FileAttributeInfoList describing the writable namespaces.

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

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

Opens a file for reading.

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

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.

Returns:
  FileInputStream or an empty RefPtr on error.

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 `0` on error.

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.

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.

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

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

Parameters:

  | res | A AsyncResult.

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

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

Deletes a file.

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

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

Deletes a 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.

Parameters:

  | cancellable | Cancellable object.

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

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.

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:

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

void Gio::File::replace_contents_finish | ( | const Glib::RefPtr< AsyncResult >& | result,
|  | std::string & | 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.

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

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

Parameters:

  | res | A AsyncResult.

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

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. `0` if relative_path is `0` or if file is invalid. Free the returned object with Glib::object_unref().

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

Sets attribute of type FILE_ATTRIBUTE_TYPE_BYTE_STRING to value.

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

Parameters:

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

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

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

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

Sets attribute of type FILE_ATTRIBUTE_TYPE_INT32 to value.

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

Parameters:

  | attribute | A string containing the attribute's name.
  | value | A gint32 containing the attribute's new value.
  | flags | A FileQueryInfoFlags.

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

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

Sets attribute of type 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.

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

Sets attribute of type FILE_ATTRIBUTE_TYPE_INT64 to value.

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

Parameters:

  | attribute | A string containing the attribute's name.
  | value | A guint64 containing the attribute's new value.
  | flags | A FileQueryInfoFlags.

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

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

Sets attribute of type 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.

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

Sets attribute of type FILE_ATTRIBUTE_TYPE_STRING to value.

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

Parameters:

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

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

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

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

Sets attribute of type FILE_ATTRIBUTE_TYPE_UINT32 to value.

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

Parameters:

  | attribute | A string containing the attribute's name.
  | value | A guint32 containing the attribute's new value.
  | flags | A FileQueryInfoFlags.

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

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

Sets attribute of type 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.

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

Sets attribute of type FILE_ATTRIBUTE_TYPE_UINT64 to value.

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

Parameters:

  | attribute | A string containing the attribute's name.
  | value | A guint64 containing the attribute's new value.
  | flags | A FileQueryInfoFlags.

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

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

Sets attribute of type 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.

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.

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.

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

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.

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.

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

Renames the 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 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 with CANCELLED will be thrown.

Parameters:

  | display_name | A string.

Returns:
  A Glib::File specifying what the file was renamed to, or an empty RefPtr if there was an error.

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 (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 `0` if there was an error.

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.

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.

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

Finishes setting a display name started with g_file_set_display_name_async().

Parameters:

  | res | A AsyncResult.

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

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

Sends the file to the "Trashcan", if possible.

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

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

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.

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

Unmounts a file of type FILE_TYPE_MOUNTABLE.

Parameters:

  | flags | Flags affecting the operation.

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.

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.

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

Finishes an unmount operation, see g_file_unmount_mountable() for details.

Finish an asynchronous unmount operation that was started with g_file_unmount_mountable().

Parameters:

  | result | A AsyncResult.

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

## Friends And Related Function Documentation

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.

The documentation for this class was generated from the following file:

- giomm/file.h