glibmm 2.80.0
|
File and directory handling. More...
#include <giomm/file.h>
Public Types | |
enum class | CreateFlags { NONE = 0x0 , PRIVATE = (1 << 0) , REPLACE_DESTINATION = (1 << 1) } |
enum class | CopyFlags { NONE = 0x0 , OVERWRITE = (1 << 0) , BACKUP = (1 << 1) , NOFOLLOW_SYMLINKS = (1 << 2) , ALL_METADATA = (1 << 3) , NO_FALLBACK_FOR_MOVE = (1 << 4) , TARGET_DEFAULT_PERMS = (1 << 5) , TARGET_DEFAULT_MODIFIED_TIME = (1 << 6) } |
enum class | MeasureFlags { NONE = 0x0 , REPORT_ANY_ERROR = (1 << 1) , APPARENT_SIZE = (1 << 2) , NO_XDEV = (1 << 3) } |
using | SlotFileProgress = sigc::slot< void(goffset, goffset)> |
A signal handler would be, for instance: void on_file_progress(goffset current_num_bytes, goffset total_num_bytes);. | |
using | SlotFileMeasureProgress = sigc::slot< void(bool, guint64, guint64, guint64)> |
This slot type is used by measure_disk_usage() to make periodic progress reports when measuring the amount of disk spaced used by a directory. | |
using | SlotReadMore = sigc::slot< bool(const char *, goffset)> |
A signal handler would be, for instance: bool on_read_more(const char* file_contents, goffset file_size);. | |
Static Public Member Functions | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
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 std::pair< Glib::RefPtr< File >, Glib::RefPtr< FileIOStream > > | create_tmp (const std::string &tmpl={}) |
Constructs a file in the preferred directory for temporary files. | |
static Glib::RefPtr< File > | create_for_parse_name (const Glib::ustring &parse_name) |
Constructs a File with the given parse_name. | |
Protected Member Functions | |
File () | |
You should derive from this class to use it. | |
Protected Member Functions inherited from Glib::ObjectBase | |
ObjectBase () | |
This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. | |
ObjectBase (const char *custom_type_name) | |
A derived constructor always overrides this choice. | |
ObjectBase (const std::type_info &custom_type_info) | |
This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. | |
ObjectBase (ObjectBase &&src) noexcept | |
ObjectBase & | operator= (ObjectBase &&src) noexcept |
virtual | ~ObjectBase () noexcept=0 |
void | initialize (GObject *castitem) |
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper) |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gio::File > | wrap (GFile *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
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 Gio::File 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.
This slot type is used by measure_disk_usage() to make periodic progress reports when measuring the amount of disk spaced used by a directory.
These calls are made on a best-effort basis and not all types of GFile will support them. At the minimum, however, one call will always be made immediately.
In the case that there is no support, reporting will be set to false (and the other values undefined) and no further calls will be made. Otherwise, the reporting will be true and the other values all-zeros during the first (immediate) call. In this way, you can know which type of progress UI to show without a delay.
For measure_disk_usage() the callback is made directly. For measure_disk_usage_async() the callback is made via the default main context of the calling thread (ie: the same way that the final async result would be reported).
current_size is in the same units as requested by the operation (see FILE_DISK_USAGE_APPARENT_SIZE).
The frequency of the updates is implementation defined, but is ideally about once every 200ms.
The last progress callback may or may not be equal to the final result. Always check the async result to get the final value.
For instance, void on_file_measure_progress(bool reporting, guint64 current_size, guint64 num_dirs, guint64 num_files);
reporting | true if more reports will come. |
current_size | The current cumulative size measurement. |
num_dirs | The number of directories visited so far. |
num_files | The number of non-directory files encountered. |
using Gio::File::SlotFileProgress = sigc::slot<void(goffset, goffset)> |
A signal handler would be, for instance: void on_file_progress(goffset current_num_bytes, goffset total_num_bytes);.
using Gio::File::SlotReadMore = sigc::slot<bool(const char*, goffset)> |
A signal handler would be, for instance: bool on_read_more(const char* file_contents, goffset file_size);.
|
strong |
Enumerator | |
---|---|
NONE | |
OVERWRITE | Overwrite any existing files. |
BACKUP | Make a backup of any existing files. |
NOFOLLOW_SYMLINKS | Don't follow symlinks. |
ALL_METADATA | Copy all file metadata instead of just default set used for copy (see FileInfo). |
NO_FALLBACK_FOR_MOVE | Don't use copy and delete fallback if native move not supported. |
TARGET_DEFAULT_PERMS | Leaves target file with default perms, instead of setting the source file perms. |
TARGET_DEFAULT_MODIFIED_TIME | Use default modification timestamps instead of copying them from the source file. |
|
strong |
Enumerator | |
---|---|
NONE | No flags set. |
PRIVATE | Create a file that can only be accessed by the current user. |
REPLACE_DESTINATION | Replace the destination as if it didn't exist before. Don't try to keep any old permissions, replace instead of following links. This is generally useful if you're doing a "copy over" rather than a "save new version of" replace operation. You can think of it as "unlink destination" before writing to it, although the implementation may not be exactly like that. This flag can only be used with g_file_replace() and its variants, including g_file_replace_contents(). |
|
strong |
|
protected |
You should derive from this class to use it.
|
noexcept |
|
overridenoexcept |
Glib::RefPtr< FileOutputStream > Gio::File::append_to | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
CreateFlags | flags = CreateFlags::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 CreateFlags::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.
flags | A set of CreateFlags. |
cancellable | Optional Cancellable object. |
Gio::Error |
Glib::RefPtr< FileOutputStream > Gio::File::append_to | ( | CreateFlags | flags = CreateFlags::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 CreateFlags::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.
flags | A set of CreateFlags. |
Gio::Error |
void Gio::File::append_to_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
io_priority | The I/O priority of the request. |
void Gio::File::append_to_async | ( | const SlotAsyncReady & | slot, |
CreateFlags | flags = CreateFlags::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.
slot | A callback slot which will be called when the request is satisfied. |
flags | a set of CreateFlags. |
io_priority | The I/O priority of the request. |
Glib::RefPtr< FileOutputStream > Gio::File::append_to_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file append operation started with g_file_append_to_async().
res | AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
bool Gio::File::copy | ( | const Glib::RefPtr< File > & | destination, |
const SlotFileProgress & | slot, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CopyFlags | flags = CopyFlags::NONE |
||
) |
Copies the file source to the location specified by destination.
Can not handle recursive copies of directories. If the flag CopyFlags::OVERWRITE is specified an already existing destination file is overwritten. If the flag CopyFlags::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 CopyFlags::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 CopyFlags::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().
Gio::Error |
bool Gio::File::copy | ( | const Glib::RefPtr< File > & | destination, |
const SlotFileProgress & | slot, | ||
CopyFlags | flags = CopyFlags::NONE |
||
) |
Copies the file source to the location specified by destination.
Can not handle recursive copies of directories. If the flag CopyFlags::OVERWRITE is specified an already existing destination file is overwritten. If the flag CopyFlags::NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.
The operation can be monitored via the slot callback.
If the source file does not exist then a Gio::Error with NOT_FOUND will be thrown, independent on the status of the destination.
If CopyFlags::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 CopyFlags::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().
Gio::Error |
bool Gio::File::copy | ( | const Glib::RefPtr< File > & | destination, |
CopyFlags | flags = CopyFlags::NONE |
||
) |
Copies the file source to the location specified by destination.
Can not handle recursive copies of directories. If the flag CopyFlags::OVERWRITE is specified an already existing destination file is overwritten. If the flag CopyFlags::NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.
If the source file does not exist then a Gio::Error with NOT_FOUND will be thrown, independent on the status of the destination.
If CopyFlags::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 CopyFlags::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().
Gio::Error |
void Gio::File::copy_async | ( | const Glib::RefPtr< File > & | destination, |
const SlotAsyncReady & | slot_ready, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CopyFlags | flags = CopyFlags::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.
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 CopyFlags |
io_priority | The I/O priority of the request |
void Gio::File::copy_async | ( | const Glib::RefPtr< File > & | destination, |
const SlotAsyncReady & | slot_ready, | ||
CopyFlags | flags = CopyFlags::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.
destination | Destination File |
slot_ready | A SlotAsyncReady to call when the request is satisfied |
flags | Set of CopyFlags |
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, | ||
CopyFlags | flags = CopyFlags::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.
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 CopyFlags |
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, | ||
CopyFlags | flags = CopyFlags::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.
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 CopyFlags |
io_priority | The I/O priority of the request |
bool Gio::File::copy_attributes | ( | const Glib::RefPtr< File > & | destination, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CopyFlags | flags = CopyFlags::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 CopyFlags::ALL_METADATA is specified in flags, then all the metadata that is possible to copy is copied.
destination | A File to copy attributes to. |
cancellable | A Cancellable object. |
flags | A set of FileMonitorFlags. |
Gio::Error |
bool Gio::File::copy_attributes | ( | const Glib::RefPtr< File > & | destination, |
CopyFlags | flags = CopyFlags::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 CopyFlags::ALL_METADATA is specified in flags, then all the metadata that is possible to copy is copied.
destination | A File to copy attributes to. |
flags | A set of FileMonitorFlags. |
Gio::Error |
bool Gio::File::copy_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes copying the file started with g_file_copy_async().
res | A AsyncResult. |
true
on success, false
on error.Glib::Error |
Glib::RefPtr< FileOutputStream > Gio::File::create_file | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
CreateFlags | flags = CreateFlags::NONE |
||
) |
Creates a new file and returns an output stream for writing to it.
The file must not already exist.
By default files created are generally readable by everyone, but if you pass CreateFlags::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 too long a 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.
cancellable | A Cancellable object which can be used to cancel the operation. |
flags | a set of CreateFlags. |
Gio::Error |
Glib::RefPtr< FileOutputStream > Gio::File::create_file | ( | CreateFlags | flags = CreateFlags::NONE | ) |
Creates a new file and returns an output stream for writing to it.
The file must not already exist.
By default files created are generally readable by everyone, but if you pass CreateFlags::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 too long a 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.
flags | a set of CreateFlags. |
Gio::Error |
void Gio::File::create_file_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
io_priority | The I/O priority of the request. |
void Gio::File::create_file_async | ( | const SlotAsyncReady & | slot, |
CreateFlags | flags = CreateFlags::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.
slot | A callback slot which will be called when the request is satisfied. |
flags | a set of CreateFlags. |
io_priority | The I/O priority of the request. |
Glib::RefPtr< FileOutputStream > Gio::File::create_file_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file create operation started with g_file_create_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
Glib::RefPtr< FileIOStream > Gio::File::create_file_readwrite | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
CreateFlags | flags = CreateFlags::NONE |
||
) |
Creates a new file and returns a stream for reading and writing to it.
The file must not already exist.
By default files created are generally readable by everyone, but if you pass CreateFlags::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 too long a Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
cancellable | A Cancellable object which can be used to cancel the operation. |
flags | a set of CreateFlags. |
Gio::Error |
Glib::RefPtr< FileIOStream > Gio::File::create_file_readwrite | ( | CreateFlags | flags = CreateFlags::NONE | ) |
Creates a new file and returns a stream for reading and writing to it.
The file must not already exist.
By default files created are generally readable by everyone, but if you pass CreateFlags::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 too long a Gio::Error with FILENAME_TOO_LONG will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
flags | a set of CreateFlags. |
Gio::Error |
void Gio::File::create_file_readwrite_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CreateFlags | flags = CreateFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously creates a new file and returns a stream for reading and writing to it.
The file must not already exist.
For more details, see create_file_readwrite() which is the synchronous version of this call.
When the operation is finished, slot will be called. You can then call create_file_readwrite_finish() to get the result of the operation.
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 CreateFlags. |
io_priority | The I/O priority of the request. |
void Gio::File::create_file_readwrite_async | ( | const SlotAsyncReady & | slot, |
CreateFlags | flags = CreateFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously creates a new file and returns a stream for reading and writing to it.
The file must not already exist.
For more details, see create_file_readwrite() which is the synchronous version of this call.
When the operation is finished, slot will be called. You can then call create_file_readwrite_finish() to get the result of the operation.
slot | A callback slot which will be called when the request is satisfied. |
flags | a set of CreateFlags. |
io_priority | The I/O priority of the request. |
Glib::RefPtr< FileIOStream > Gio::File::create_file_readwrite_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file create operation started with g_file_create_readwrite_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
|
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.
arg | A string containing a relative or absolute path. |
|
static |
Constructs a File with the given parse_name.
The parse_name is something given by get_parse_name(). This operation never fails, but the returned object might not support any I/O operation if the parse_name cannot be parsed.
parse_name | A UTF-8 encoded file name or path to be parsed. |
|
static |
|
static |
|
static |
Constructs a file in the preferred directory for temporary files.
The file is created in the directory returned by Glib::get_tmp_dir(). A FileIOStream pointing to the file is also created.
tmpl should be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it is an empty string, a default template is used.
Unlike the other File constructors, this will throw an exception if a temporary file could not be created.
tmpl | Template for the file name, as in Glib::file_open_tmp(), or an empty string for a default template. |
Glib::FileError |
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.
g_file_dup() is useful when a second handle is needed to the same underlying file, for use in a separate thread (File is not thread-safe). For use within the same thread, use Glib::object_ref() to increment the existing object’s reference count.
This call does no blocking I/O.
void Gio::File::eject_mountable | ( | const Glib::RefPtr< MountOperation > & | mount_operation, |
Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE |
||
) |
Starts an asynchronous eject on a mountable.
mount_operation | A MountOperation |
flags | Flags affecting the operation. |
void Gio::File::eject_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const Glib::RefPtr< MountOperation > & | mount_operation, | ||
Mount::UnmountFlags | flags = Mount::UnmountFlags::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.
slot | A callback slot which will be called when the request is satisfied. |
cancellable | A Cancellable object which can be used to cancel the operation. |
mount_operation | A MountOperation |
flags | Flags affecting the operation. |
void Gio::File::eject_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
Mount::UnmountFlags | flags = Mount::UnmountFlags::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.
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. |
void Gio::File::eject_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< MountOperation > & | mount_operation, | ||
Mount::UnmountFlags | flags = Mount::UnmountFlags::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.
slot | A callback slot which will be called when the request is satisfied. |
mount_operation | A MountOperation |
flags | Flags affecting the operation. |
void Gio::File::eject_mountable | ( | const SlotAsyncReady & | slot, |
Mount::UnmountFlags | flags = Mount::UnmountFlags::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.
slot | A callback slot which will be called when the request is satisfied. |
flags | Flags affecting the operation. |
void Gio::File::eject_mountable | ( | Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE | ) |
Starts an asynchronous eject on a mountable.
flags | Flags affecting the operation. |
bool Gio::File::eject_mountable_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes an asynchronous eject operation started by g_file_eject_mountable_with_operation().
result | A AsyncResult. |
true
if the file was ejected successfully. false
otherwise.Glib::Error |
Glib::RefPtr< FileEnumerator > Gio::File::enumerate_children | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
const std::string & | attributes = "*" , |
||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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 Gio::Error with NOT_DIRECTORY will be thrown. Other errors are possible too.
cancellable | A Cancellable object. |
attributes | An attribute query string. |
flags | A set of FileQueryInfoFlags. |
Gio::Error |
Glib::RefPtr< FileEnumerator > Gio::File::enumerate_children | ( | const std::string & | attributes = "*" , |
FileQueryInfoFlags | flags = FileQueryInfoFlags::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 Gio::Error with NOT_DIRECTORY will be thrown. Other errors are possible too.
attributes | An attribute query string. |
flags | A set of FileQueryInfoFlags. |
Gio::Error |
void Gio::File::enumerate_children_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const std::string & | attributes = "*" , |
||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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.
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. |
void Gio::File::enumerate_children_async | ( | const SlotAsyncReady & | slot, |
const std::string & | attributes = "*" , |
||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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.
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. |
Glib::RefPtr< FileEnumerator > Gio::File::enumerate_children_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an async enumerate children operation.
See g_file_enumerate_children_async().
res | A AsyncResult. |
nullptr
if an error occurred. Free the returned object with Glib::object_unref().Glib::Error |
bool Gio::File::equal | ( | const Glib::RefPtr< const File > & | other | ) | const |
Glib::RefPtr< Mount > Gio::File::find_enclosing_mount | ( | ) |
A find_enclosing_mount() convenience overload.
Glib::RefPtr< Mount > Gio::File::find_enclosing_mount | ( | const Glib::RefPtr< Cancellable > & | cancellable | ) |
If the FileIface for file does not have a mount (e.g. possibly a remote share), a Gio::Error will be thrown with NOT_FOUND and nullptr
will be returned.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.
cancellable | Cancellable object. |
nullptr
on error.Glib::Error |
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.
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. |
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.
slot | A callback slot which will be called when the request is satisfied. |
io_priority | The I/O priority of the request. |
Glib::RefPtr< Mount > Gio::File::find_enclosing_mount_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous find mount request.
See g_file_find_enclosing_mount_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
std::string Gio::File::get_basename | ( | ) | const |
Gets the base name (the last component of the path) for a given File.
If called for the top level of a system (such as the filesystem root or a uri like sftp://host/) it will return a single directory separator (and on Windows, possibly a drive letter).
The base name is a byte string (not UTF-8). It has no defined encoding or rules other than it may not contain zero bytes. If you want to use filenames in a user interface you should use the display name that you can get by requesting the G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().
This call does no blocking I/O.
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.
name | String containing the child's basename. |
Glib::RefPtr< File > Gio::File::get_child_for_display_name | ( | const Glib::ustring & | display_name | ) | const |
Gets the child of file for a given display_name (i.e. a UTF-8 version of the name).
If this function fails, it returns nullptr
and error will be set. This is very useful when constructing a File for a new file and the user entered the filename in the user interface, for instance when you select a directory and type a filename in the file selector.
This call does no blocking I/O.
display_name | String to a possible child. |
nullptr
if the display name couldn't be converted. Free the returned object with Glib::object_unref().Glib::Error |
Glib::RefPtr< File > Gio::File::get_parent | ( | ) | const |
Gets the parent directory for the file.
If the file represents the root directory of the file system, then nullptr
will be returned.
This call does no blocking I/O.
Glib::ustring Gio::File::get_parse_name | ( | ) | const |
Gets the parse name of the file.
A parse name is a UTF-8 string that describes the file such that one can get the File back using g_file_parse_name().
This is generally used to show the File as a nice full-pathname kind of string in a user interface, like in a location entry.
For local files with names that can safely be converted to UTF-8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF-8 characters unescaped).
This call does no blocking I/O.
std::string Gio::File::get_path | ( | ) | const |
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.
descendant | Input File. |
nullptr
if descendant doesn't have parent as prefix. Get the GType for this class, for use with the underlying GObject type system.
std::string Gio::File::get_uri | ( | ) | const |
std::string Gio::File::get_uri_scheme | ( | ) | const |
Gets the URI scheme for a File.
RFC 3986 decodes the scheme as:
[C example ellipted] Common schemes include "file", "http", "ftp", etc.
The scheme can be different from the one used to construct the File, in that it might be replaced with one that is logically equivalent to the File.
This call does no blocking I/O.
|
inline |
Provides access to the underlying C GObject.
bool Gio::File::has_parent | ( | ) | const |
Checks if the file has any parent at all.
bool Gio::File::has_parent | ( | const Glib::RefPtr< File > & | parent | ) | const |
Checks if file has a parent, and optionally, if it is parent.
If parent is nullptr
then this function returns true
if file has any parent at all. If parent is non-nullptr
then true
is only returned if file is an immediate child of parent.
parent | The parent to check for, or nullptr . |
true
if file is an immediate child of parent (or any parent in the case that parent is nullptr
). bool Gio::File::has_prefix | ( | const Glib::RefPtr< const File > & | prefix | ) | const |
Checks whether file has the prefix specified by prefix.
In other words, if the names of initial elements of file's pathname match prefix. Only full pathname elements are matched, so a path like /foo is not considered a prefix of /foobar, only of /foo/bar.
A File is not a prefix of itself. If you want to check for equality, use g_file_equal().
This call does no I/O, as it works purely on names. As such it can sometimes return false
even if file is inside a prefix (from a filesystem point of view), because the prefix of file is an alias of prefix.
prefix | Input File. |
true
if the file's parent, grandparent, etc is prefix, false
otherwise. bool Gio::File::has_uri_scheme | ( | const std::string & | uri_scheme | ) | const |
guint Gio::File::hash | ( | ) | const |
bool Gio::File::is_native | ( | ) | const |
Checks to see if a file is native to the platform.
A native file is 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.
true
if file is native. 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.
contents | A location to place the contents of the file. |
length | A location to place the length of the contents of the file. |
Gio::Error |
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.
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. |
Gio::Error |
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.
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. |
Gio::Error |
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.
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. |
Gio::Error |
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.
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.
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.
result | A AsyncResult. |
contents | A location to place the contents of the file. |
length | A location to place the length of the contents of the file. |
true
if the load was successful. If false
and error is present, it will be set appropriately. Gio::Error |
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.
result | A AsyncResult. |
contents | A location to place the contents of the file. |
length | A location to place the length of the contents of the file. |
etag_out | A location to place the current entity tag for the file. |
true
if the load was successful. If false
and error is present, it will be set appropriately.Gio::Error |
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.
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.
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().
result | A AsyncResult. |
contents | A location to place the contents of the file. |
length | A location to place the length of the contents of the file. |
true
if the load was successful. If false
and error is present, it will be set appropriately. Gio::Error |
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().
result | A AsyncResult. |
contents | A location to place the contents of the file. |
length | A location to place the length of the contents of the file. |
etag_out | A location to place the current entity tag for the file. |
true
if the load was successful. If false
and error is present, it will be set appropriately.Gio::Error |
bool Gio::File::make_directory | ( | ) |
A make_directory() convenience overload.
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.
cancellable | Cancellable object. |
true
on successful creation, false
otherwise.Glib::Error |
void Gio::File::make_directory_async | ( | const SlotAsyncReady & | slot_ready, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously creates a directory.
slot_ready | A SlotAsyncReady to call when the request is satisfied |
cancellable | A Cancellable object which can be used to cancel the operation |
io_priority | The I/O priority of the request |
void Gio::File::make_directory_async | ( | const SlotAsyncReady & | slot_ready, |
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously creates a directory.
slot_ready | A SlotAsyncReady to call when the request is satisfied |
io_priority | The I/O priority of the request |
bool Gio::File::make_directory_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes an asynchronous directory creation, started with g_file_make_directory_async().
result | A AsyncResult. |
true
on successful directory creation, false
otherwise.Glib::Error |
bool Gio::File::make_directory_with_parents | ( | ) |
A make_directory_with_parents() convenience overload.
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 Gio::Error::NOT_SUPPORTED. If the directory itself already exists, this function will fail setting error to Gio::Error::EXISTS, unlike the similar Glib::mkdir_with_parents().
For a local File the newly created directories will have the default (current) ownership and permissions of the current process.
If cancellable is not nullptr
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio::Error::CANCELLED will be returned.
cancellable | Optional Cancellable object, nullptr to ignore. |
true
if all directories have been successfully created, false
otherwise.Glib::Error |
bool Gio::File::make_symbolic_link | ( | const std::string & | symlink_value | ) |
A make_symbolic_link() convenience overload.
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.
symlink_value | A string with the value of the new symlink. |
cancellable | Cancellable object. |
true
on the creation of a new symlink, false
otherwise.Glib::Error |
void Gio::File::make_symbolic_link_async | ( | const std::string & | symlink_value, |
const SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Cancellable > & | cancellable = {} , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously creates a symbolic link named file which contains the string symlink_value.
symlink_value | A string with the path for the target of the new symlink. |
io_priority | The [I/O priority][io-priority] of the request. |
cancellable | Optional Cancellable object, nullptr to ignore. |
slot | A SlotAsyncReady to call when the request is satisfied. |
bool Gio::File::make_symbolic_link_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes an asynchronous symbolic link creation, started with g_file_make_symbolic_link_async().
result | A AsyncResult. |
true
on successful directory creation, false
otherwise.Glib::Error |
void Gio::File::measure_disk_usage | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
const SlotFileMeasureProgress & | slot_progress, | ||
guint64 & | disk_usage, | ||
guint64 & | num_dirs, | ||
guint64 & | num_files, | ||
MeasureFlags | flags = MeasureFlags::NONE |
||
) |
Recursively measures the disk usage of the file.
This is essentially an analog of the 'du
' command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links).
By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless MeasureFlags::REPORT_ANY_ERROR is given in flags.
The returned size, disk_usage, is in bytes and should be formatted with g_format_size() in order to get something reasonable for showing in a user interface.
slot_progress can be given to request periodic progress updates while scanning. See the documentation for SlotFileMeasureProgress for information about when and how the callback will be invoked.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
cancellable | A Cancellable object which can be used to cancel the operation |
slot_progress | A SlotFileMeasureProgress to call periodically while scanning. |
disk_usage | The number of bytes of disk space used. |
num_dirs | The number of directories encountered. |
num_files | The number of non-directories encountered. |
flags | Set of MeasureFlags. |
Gio::Error |
void Gio::File::measure_disk_usage_async | ( | const SlotAsyncReady & | slot_ready, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const SlotFileMeasureProgress & | slot_progress, | ||
MeasureFlags | flags = MeasureFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Recursively measures the disk usage of the file.
This is the asynchronous version of measure_disk_usage(). See there for more information.
When the operation is finished, slot_ready will be called. You can then call measure_disk_usage_finish() to get the result of the operation.
slot_ready | A SlotAsyncReady to call when the request is satisfied |
cancellable | A Cancellable object which can be used to cancel the operation |
slot_progress | The callback slot to be called with progress information |
flags | Set of MeasureFlags |
io_priority | The I/O priority of the request |
bool Gio::File::measure_disk_usage_finish | ( | const Glib::RefPtr< AsyncResult > & | result, |
guint64 & | disk_usage, | ||
guint64 & | num_dirs, | ||
guint64 & | num_files | ||
) |
Collects the results from an earlier call to g_file_measure_disk_usage_async().
See g_file_measure_disk_usage() for more information.
result | The AsyncResult passed to your SlotAsyncReady. |
disk_usage | The number of bytes of disk space used. |
num_dirs | The number of directories encountered. |
num_files | The number of non-directories encountered. |
true
if successful, with the out parameters set. false
otherwise, with error set.Glib::Error |
Glib::RefPtr< FileMonitor > Gio::File::monitor | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
FileMonitorFlags | flags = FileMonitorFlags::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.
cancellable | A Cancellable object. |
flags | A set of FileMonitorFlags. |
Gio::Error |
Glib::RefPtr< FileMonitor > Gio::File::monitor | ( | FileMonitorFlags | flags = FileMonitorFlags::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.
flags | A set of FileMonitorFlags. |
Gio::Error |
Glib::RefPtr< FileMonitor > Gio::File::monitor_directory | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
FileMonitorFlags | flags = FileMonitorFlags::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.
cancellable | A Cancellable object. |
flags | A set of FileMonitorFlags. |
Gio::Error |
Glib::RefPtr< FileMonitor > Gio::File::monitor_directory | ( | FileMonitorFlags | flags = FileMonitorFlags::NONE | ) |
Obtains a directory monitor for the given file.
This may fail if directory monitoring is not supported.
flags | A set of FileMonitorFlags. |
Gio::Error |
Glib::RefPtr< FileMonitor > Gio::File::monitor_file | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
FileMonitorFlags | flags = FileMonitorFlags::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.
cancellable | A Cancellable object. |
flags | A set of FileMonitorFlags. |
Gio::Error |
Glib::RefPtr< FileMonitor > Gio::File::monitor_file | ( | FileMonitorFlags | flags = FileMonitorFlags::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.
flags | A set of FileMonitorFlags. |
Gio::Error |
void Gio::File::mount_enclosing_volume | ( | const Glib::RefPtr< MountOperation > & | mount_operation, |
const SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
Mount::MountFlags | flags = Mount::MountFlags::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.
mount_operation | A MountOperation. |
slot | A callback slot which will be called when the request is satisfied. |
cancellable | A Cancellable object. |
flags | Flags affecting the operation. |
void Gio::File::mount_enclosing_volume | ( | const Glib::RefPtr< MountOperation > & | mount_operation, |
const SlotAsyncReady & | slot, | ||
Mount::MountFlags | flags = Mount::MountFlags::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().
mount_operation | A MountOperation. |
slot | A callback slot which will be called when the request is satisfied. |
flags | Flags affecting the operation. |
void Gio::File::mount_enclosing_volume | ( | const SlotAsyncReady & | slot, |
Mount::MountFlags | flags = Mount::MountFlags::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().
slot | A callback slot which will be called when the request is satisfied. |
flags | Flags affecting the operation. |
void Gio::File::mount_enclosing_volume | ( | Mount::MountFlags | flags = Mount::MountFlags::NONE | ) |
Starts a mount_operation, mounting the volume that contains the file.
flags | Flags affecting the operation. |
bool Gio::File::mount_enclosing_volume_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes a mount operation started by g_file_mount_enclosing_volume().
result | A AsyncResult. |
true
if successful. If an error has occurred, this function will return false
and set error appropriately if present.Glib::Error |
void Gio::File::mount_mountable | ( | const Glib::RefPtr< MountOperation > & | mount_operation, |
const SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
Mount::MountFlags | flags = Mount::MountFlags::NONE |
||
) |
Mounts a file of type FileType::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.
mount_operation | A MountOperation. |
cancellable | A Cancellable object which can be used to cancel the operation. |
slot | A callback slot which will be called when the request is satisfied. |
flags | Flags affecting the operation. |
void Gio::File::mount_mountable | ( | const Glib::RefPtr< MountOperation > & | mount_operation, |
const SlotAsyncReady & | slot, | ||
Mount::MountFlags | flags = Mount::MountFlags::NONE |
||
) |
Mounts a file of type FileType::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.
mount_operation | A MountOperation. |
slot | A callback slot which will be called when the request is satisfied. |
flags | Flags affecting the operation. |
void Gio::File::mount_mountable | ( | const SlotAsyncReady & | slot, |
Mount::MountFlags | flags = Mount::MountFlags::NONE |
||
) |
Mounts a file of type FileType::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.
slot | A callback slot which will be called when the request is satisfied. |
flags | Flags affecting the operation. |
void Gio::File::mount_mountable | ( | Mount::MountFlags | flags = Mount::MountFlags::NONE | ) |
Mounts a file of type FileType::MOUNTABLE without user interaction.
flags | Flags affecting the operation. |
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().
result | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
bool Gio::File::move | ( | const Glib::RefPtr< File > & | destination, |
const SlotFileProgress & | slot, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CopyFlags | flags = CopyFlags::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 CopyFlags::OVERWRITE is specified an already existing destination file is overwritten.
If the flag CopyFlags::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_CopyFlags::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 CopyFlags::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).
Gio::Error |
bool Gio::File::move | ( | const Glib::RefPtr< File > & | destination, |
const SlotFileProgress & | slot, | ||
CopyFlags | flags = CopyFlags::NONE |
||
) |
bool Gio::File::move | ( | const Glib::RefPtr< File > & | destination, |
CopyFlags | flags = CopyFlags::NONE |
||
) |
void Gio::File::move_async | ( | const Glib::RefPtr< File > & | destination, |
const SlotAsyncReady & | slot_ready, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CopyFlags | flags = CopyFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
void Gio::File::move_async | ( | const Glib::RefPtr< File > & | destination, |
const SlotAsyncReady & | slot_ready, | ||
CopyFlags | flags = CopyFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
void Gio::File::move_async | ( | const Glib::RefPtr< File > & | destination, |
const SlotFileProgress & | slot_progress, | ||
const SlotAsyncReady & | slot_ready, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
CopyFlags | flags = CopyFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously moves a file source to the location of destination.
For details of the behaviour, see move().
If slot_progress is not empty, then that slot will be called just like in move(). The callback will run in the default main context of the thread calling move_async() — the same context as slot_ready is run in.
When the operation is finished, slot_ready will be called. You can then call move_finish() to get the result of the operation.
destination | File pointing to the destination location. |
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 Gio::File::CopyFlags. |
io_priority | The I/O priority of the request. |
void Gio::File::move_async | ( | const Glib::RefPtr< File > & | destination, |
const SlotFileProgress & | slot_progress, | ||
const SlotAsyncReady & | slot_ready, | ||
CopyFlags | flags = CopyFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
bool Gio::File::move_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file movement, started with g_file_move_async().
res | A AsyncResult. |
true
on successful file move, false
otherwise.Glib::Error |
Glib::RefPtr< FileIOStream > Gio::File::open_readwrite | ( | ) |
A open_readwrite() convenience overload.
Glib::RefPtr< FileIOStream > Gio::File::open_readwrite | ( | const Glib::RefPtr< Cancellable > & | cancellable | ) |
Opens an existing file for reading and writing.
The result is a FileIOStream that can be used to read and write the contents of the file.
If cancellable is not nullptr
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio::Error::CANCELLED will be returned.
If the file does not exist, the Gio::Error::NOT_FOUND error will be returned. If the file is a directory, the Gio::Error::IS_DIRECTORY error will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
cancellable | A Cancellable. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
void Gio::File::open_readwrite_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Opens an existing file for reading and writing.
The result is a FileIOStream that can be used to read and write the contents of the file.
For more details, see open_readwrite() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call open_readwrite_finish() to get the result of the operation. If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. If the file is a directory, a Gio::Error with IS_DIRECTORY will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
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. |
void Gio::File::open_readwrite_async | ( | const SlotAsyncReady & | slot, |
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Opens an existing file for reading and writing.
The result is a FileIOStream that can be used to read and write the contents of the file.
For more details, see open_readwrite() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call open_readwrite_finish() to get the result of the operation. If the file does not exist, a Gio::Error with NOT_FOUND will be thrown. If the file is a directory, a Gio::Error with IS_DIRECTORY will be thrown. Other errors are possible too, and depend on what kind of filesystem the file is on.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
slot | A callback slot which will be called when the request is satisfied. |
io_priority | The I/O priority of the request. |
Glib::RefPtr< FileIOStream > Gio::File::open_readwrite_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file read operation started with g_file_open_readwrite_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
Polls a file of type Mountable.
Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.
When this operation has completed, slot will be called and the operation can be finalized with stop_mountable_finish().
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
slot | A callback to call when the request is satisfied. |
void Gio::File::poll_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
Polls a file of type Mountable.
Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.
When this operation has completed, slot will be called and the operation can be finalized with stop_mountable_finish().
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
slot | A callback to call when the request is satisfied. |
cancellable | A Cancellable object. |
bool Gio::File::poll_mountable_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes a poll operation.
See g_file_poll_mountable() for details.
Finish an asynchronous poll operation that was polled with g_file_poll_mountable().
result | A AsyncResult. |
true
if the operation finished successfully. false
otherwise.Glib::Error |
Glib::RefPtr< AppInfo > Gio::File::query_default_handler | ( | ) |
A query_default_handler() convenience overload.
Glib::RefPtr< AppInfo > Gio::File::query_default_handler | ( | const Glib::RefPtr< Cancellable > & | cancellable | ) |
Returns the AppInfo that is registered as the default application to handle the file specified by file.
If cancellable is not nullptr
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio::Error::CANCELLED will be returned.
cancellable | Optional Cancellable object, nullptr to ignore. |
nullptr
if there were errors. When you are done with it, release it with Glib::object_unref().Glib::Error |
bool Gio::File::query_exists | ( | ) | const |
A query_exists() convenience overload.
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.
cancellable | Optional Cancellable object, nullptr to ignore. |
true
if the file exists (and can be detected without error), false
otherwise (or if cancelled). 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.
flags | A set of FileQueryInfoFlags passed to g_file_query_info(). |
cancellable | Optional Cancellable object, nullptr to ignore. |
FileType Gio::File::query_file_type | ( | FileQueryInfoFlags | flags = FileQueryInfoFlags::NONE | ) | const |
Utility function to inspect the FileType of a file.
This is implemented using query_info() and as such does blocking I/O.
The primary use case of this method is to check if a file is a regular file, directory, or symlink.
flags | a set of FileQueryInfoFlags passed to query_info(). |
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.
cancellable | A Cancellable object. |
attributes | An attribute query string. |
Gio::Error |
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.
attributes | An attribute query string. |
Gio::Error |
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.
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. |
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.
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. |
Glib::RefPtr< FileInfo > Gio::File::query_filesystem_info_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous filesystem info query.
See g_file_query_filesystem_info_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
Glib::RefPtr< FileInfo > Gio::File::query_info | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
const std::string & | attributes = "*" , |
||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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 FileQueryInfoFlags::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.
cancellable | A Cancellable object. |
attributes | An attribute query string. |
flags | A set of FileQueryInfoFlags. |
Gio::Error |
Glib::RefPtr< FileInfo > Gio::File::query_info | ( | const std::string & | attributes = "*" , |
FileQueryInfoFlags | flags = FileQueryInfoFlags::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 FileQueryInfoFlags::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.
attributes | An attribute query string. |
flags | A set of FileQueryInfoFlags. |
Gio::Error |
void Gio::File::query_info_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const std::string & | attributes = "*" , |
||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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.
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. |
void Gio::File::query_info_async | ( | const SlotAsyncReady & | slot, |
const std::string & | attributes = "*" , |
||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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.
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. |
Glib::RefPtr< FileInfo > Gio::File::query_info_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file info query.
See g_file_query_info_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
Glib::RefPtr< FileAttributeInfoList > Gio::File::query_settable_attributes | ( | ) |
A query_settable_attributes() convenience overload.
Glib::RefPtr< FileAttributeInfoList > Gio::File::query_settable_attributes | ( | const Glib::RefPtr< Cancellable > & | cancellable | ) |
Obtain the list of settable attributes for the file.
cancellable | Optional Cancellable object, nullptr to ignore. |
Glib::Error |
Glib::RefPtr< FileAttributeInfoList > Gio::File::query_writable_namespaces | ( | ) |
A query_writable_namespaces() convenience overload.
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.
cancellable | Cancellable object. |
Glib::Error |
Glib::RefPtr< FileInputStream > Gio::File::read | ( | ) |
A read() convenience overload.
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.
cancellable | A Cancellable. |
nullptr
on error.Glib::Error |
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.
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. |
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.
slot | A callback slot which will be called when the request is satisfied. |
io_priority | The I/O priority of the request. |
Glib::RefPtr< FileInputStream > Gio::File::read_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file read operation started with g_file_read_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
bool Gio::File::remove | ( | ) |
A remove() convenience overload.
bool Gio::File::remove | ( | const Glib::RefPtr< Cancellable > & | cancellable | ) |
Deletes a file.
If the file is a directory, it will only be deleted if it is empty. The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
cancellable | A Cancellable object which can be used to cancel the operation. |
true
if the file was deleted. false
otherwise. void Gio::File::remove_async | ( | const SlotAsyncReady & | slot_ready, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously delete a file.
If the file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().
slot_ready | A SlotAsyncReady to call when the request is satisfied |
cancellable | A Cancellable object which can be used to cancel the operation |
io_priority | The I/O priority of the request |
void Gio::File::remove_async | ( | const SlotAsyncReady & | slot_ready, |
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously delete a file.
If the file is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().
slot_ready | A SlotAsyncReady to call when the request is satisfied |
io_priority | The I/O priority of the request |
bool Gio::File::remove_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes deleting a file started with g_file_delete_async().
result | A AsyncResult. |
true
if the file was deleted. false
otherwise.Glib::Error |
Glib::RefPtr< FileOutputStream > Gio::File::replace | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
const std::string & | etag = {} , |
||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::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 CreateFlags::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 a 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 a 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 too long a 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.
cancellable | A Cancellable object which can be used to cancel the operation. |
etag | An optional entity tag for the current Glib::File. |
make_backup | true if a backup should be created. |
flags | A set of CreateFlags. |
Gio::Error |
Glib::RefPtr< FileOutputStream > Gio::File::replace | ( | const std::string & | etag = {} , |
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::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 CreateFlags::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 a 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 a 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 too long a 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.
etag | An optional entity tag for the current Glib::File. |
make_backup | true if a backup should be created. |
flags | A set of CreateFlags. |
Gio::Error |
void Gio::File::replace_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const std::string & | etag = {} , |
||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
io_priority | The I/O priority of the request. |
void Gio::File::replace_async | ( | const SlotAsyncReady & | slot, |
const std::string & | etag = {} , |
||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
io_priority | The I/O priority of the request. |
void Gio::File::replace_contents | ( | const char * | contents, |
gsize | length, | ||
const std::string & | etag, | ||
std::string & | new_etag, | ||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
new_etag | A location to a new entity tag for the document. |
Gio::Error |
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 , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
new_etag | A location to a new entity tag for the document. |
cancellable | A Cancellable object. |
Gio::Error |
void Gio::File::replace_contents | ( | const std::string & | contents, |
const std::string & | etag, | ||
std::string & | new_etag, | ||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
new_etag | A location to a new entity tag for the document. |
Gio::Error |
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 , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
new_etag | A location to a new entity tag for the document. |
cancellable | A Cancellable object. |
Gio::Error |
void Gio::File::replace_contents_async | ( | const SlotAsyncReady & | slot, |
const char * | contents, | ||
gsize | length, | ||
const std::string & | etag, | ||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
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 , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
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 , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
void Gio::File::replace_contents_async | ( | const SlotAsyncReady & | slot, |
const std::string & | contents, | ||
const std::string & | etag, | ||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::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.
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 CreateFlags. |
void Gio::File::replace_contents_bytes_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const Glib::RefPtr< const Glib::Bytes > & | contents, | ||
const std::string & | etag, | ||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::NONE |
||
) |
Same as replace_contents_async() but takes a Gio::Bytes input instead.
When this operation has completed, slot will be called and the operation can be finalized with replace_contents_finish().
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
If make_backup is true, this function will attempt to make a backup of the file.
slot | A callback to call when the request is satisfied. |
cancellable | A Cancellable object. |
contents | Bytes of contents to replace the file with. |
etag | a new entity tag for the file. |
make_backup | true if a backup should be created. |
flags | A set of CreateFlags. |
void Gio::File::replace_contents_bytes_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< const Glib::Bytes > & | contents, | ||
const std::string & | etag, | ||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::NONE |
||
) |
Same as replace_contents_async() but takes a Gio::Bytes input instead.
When this operation has completed, slot will be called and the operation can be finalized with replace_contents_finish().
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
If make_backup is true, this function will attempt to make a backup of the file.
slot | A callback to call when the request is satisfied. |
contents | Bytes of contents to replace the file with. |
etag | a new entity tag for the file. |
make_backup | true if a backup should be created. |
flags | A set of CreateFlags. |
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.
result | A AsyncResult. |
Gio::Error |
void Gio::File::replace_contents_finish | ( | const Glib::RefPtr< AsyncResult > & | result, |
std::string & | new_etag | ||
) |
Finishes an asynchronous replace of the given file .
See replace_contents_async(). Sets new_etag to the new entity tag for the document.
result | A AsyncResult. |
new_etag | A location of a new entity tag for the document. |
Gio::Error |
Glib::RefPtr< FileOutputStream > Gio::File::replace_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file replace operation started with g_file_replace_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
Glib::RefPtr< FileIOStream > Gio::File::replace_readwrite | ( | const Glib::RefPtr< Cancellable > & | cancellable, |
const std::string & | etag = {} , |
||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::NONE |
||
) |
Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first.
If the file doesn't exist, it will be created.
For details about the behaviour, see replace() which does the same thing but returns an output stream only.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
cancellable | A Cancellable object which can be used to cancel the operation. |
etag | An optional entity tag for the current Glib::File. |
make_backup | true if a backup should be created. |
flags | A set of CreateFlags. |
Gio::Error |
Glib::RefPtr< FileIOStream > Gio::File::replace_readwrite | ( | const std::string & | etag = {} , |
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::NONE |
||
) |
Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first.
If the file doesn't exist, it will be created.
For details about the behaviour, see replace() which does the same thing but returns an output stream only.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
etag | An optional entity tag for the current Glib::File. |
make_backup | true if a backup should be created. |
flags | A set of CreateFlags. |
Gio::Error |
void Gio::File::replace_readwrite_async | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const std::string & | etag = {} , |
||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asyncronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.
For more details, see replace_readwrite() which is the synchronous version of this call.
When the operation is finished, slot will be called. You can then call replace_readwrite_finish() to get the result of the operation.
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 CreateFlags. |
io_priority | The I/O priority of the request. |
void Gio::File::replace_readwrite_async | ( | const SlotAsyncReady & | slot, |
const std::string & | etag = {} , |
||
bool | make_backup = false , |
||
CreateFlags | flags = CreateFlags::NONE , |
||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asyncronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.
For more details, see replace_readwrite() which is the synchronous version of this call. When the operation is finished, slot will be called. You can then call replace_readwrite_finish() to get the result of the operation.
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 CreateFlags. |
io_priority | The I/O priority of the request. |
Glib::RefPtr< FileIOStream > Gio::File::replace_readwrite_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes an asynchronous file replace operation started with g_file_replace_readwrite_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
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.
If the relative_path is an absolute path name, the resolution is done absolutely (without taking file path as base).
relative_path | A given relative path string. |
bool Gio::File::set_attribute_byte_string | ( | const std::string & | attribute, |
const std::string & | value, | ||
FileQueryInfoFlags | flags | ||
) |
A set_attribute_byte_string() convenience overload.
bool Gio::File::set_attribute_byte_string | ( | const std::string & | attribute, |
const std::string & | value, | ||
FileQueryInfoFlags | flags, | ||
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
Sets attribute of type G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to value.
If attribute is of a different type, this operation will fail, returning false
.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.
attribute | A string containing the attribute's name. |
value | A string containing the attribute's new value. |
flags | A FileQueryInfoFlags. |
cancellable | Cancellable object. |
true
if the attribute was successfully set to value in the file, false
otherwise.Glib::Error |
bool Gio::File::set_attribute_int32 | ( | const std::string & | attribute, |
gint32 | value, | ||
FileQueryInfoFlags | flags | ||
) |
A set_attribute_int32() convenience overload.
bool Gio::File::set_attribute_int32 | ( | const std::string & | attribute, |
gint32 | value, | ||
FileQueryInfoFlags | flags, | ||
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
Sets attribute of type G_FILE_ATTRIBUTE_TYPE_INT32 to value.
If attribute is of a different type, this operation will fail.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.
attribute | A string containing the attribute's name. |
value | A #gint32 containing the attribute's new value. |
flags | A FileQueryInfoFlags. |
cancellable | Cancellable object. |
true
if the attribute was successfully set to value in the file, false
otherwise.Glib::Error |
bool Gio::File::set_attribute_int64 | ( | const std::string & | attribute, |
gint64 | value, | ||
FileQueryInfoFlags | flags | ||
) |
A set_attribute_int64() convenience overload.
bool Gio::File::set_attribute_int64 | ( | const std::string & | attribute, |
gint64 | value, | ||
FileQueryInfoFlags | flags, | ||
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
Sets attribute of type G_FILE_ATTRIBUTE_TYPE_INT64 to value.
If attribute is of a different type, this operation will fail.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.
attribute | A string containing the attribute's name. |
value | A guint64 containing the attribute's new value. |
flags | A FileQueryInfoFlags. |
cancellable | Cancellable object. |
true
if the attribute was successfully set, false
otherwise.Glib::Error |
bool Gio::File::set_attribute_string | ( | const std::string & | attribute, |
const Glib::ustring & | value, | ||
FileQueryInfoFlags | flags | ||
) |
A set_attribute_string() convenience overload.
bool Gio::File::set_attribute_string | ( | const std::string & | attribute, |
const Glib::ustring & | value, | ||
FileQueryInfoFlags | flags, | ||
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
Sets attribute of type G_FILE_ATTRIBUTE_TYPE_STRING to value.
If attribute is of a different type, this operation will fail.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.
attribute | A string containing the attribute's name. |
value | A string containing the attribute's value. |
flags | FileQueryInfoFlags. |
cancellable | Cancellable object. |
true
if the attribute was successfully set, false
otherwise.Glib::Error |
bool Gio::File::set_attribute_uint32 | ( | const std::string & | attribute, |
guint32 | value, | ||
FileQueryInfoFlags | flags | ||
) |
A set_attribute_uint32() convenience overload.
bool Gio::File::set_attribute_uint32 | ( | const std::string & | attribute, |
guint32 | value, | ||
FileQueryInfoFlags | flags, | ||
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
Sets attribute of type G_FILE_ATTRIBUTE_TYPE_UINT32 to value.
If attribute is of a different type, this operation will fail.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.
attribute | A string containing the attribute's name. |
value | A guint32 containing the attribute's new value. |
flags | A FileQueryInfoFlags. |
cancellable | Cancellable object. |
true
if the attribute was successfully set to value in the file, false
otherwise.Glib::Error |
bool Gio::File::set_attribute_uint64 | ( | const std::string & | attribute, |
guint64 | value, | ||
FileQueryInfoFlags | flags | ||
) |
A set_attribute_uint64() convenience overload.
bool Gio::File::set_attribute_uint64 | ( | const std::string & | attribute, |
guint64 | value, | ||
FileQueryInfoFlags | flags, | ||
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
Sets attribute of type G_FILE_ATTRIBUTE_TYPE_UINT64 to value.
If attribute is of a different type, this operation will fail.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.
attribute | A string containing the attribute's name. |
value | A guint64 containing the attribute's new value. |
flags | A FileQueryInfoFlags. |
cancellable | Cancellable object. |
true
if the attribute was successfully set to value in the file, false
otherwise.Glib::Error |
void Gio::File::set_attributes_async | ( | const Glib::RefPtr< FileInfo > & | info, |
const SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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.
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. |
void Gio::File::set_attributes_async | ( | const Glib::RefPtr< FileInfo > & | info, |
const SlotAsyncReady & | slot, | ||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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.
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. |
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, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
FileQueryInfoFlags | flags = FileQueryInfoFlags::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.
info | A FileInfo. |
cancellable | A Cancellable object which can be used to cancel the operation. |
flags | A set of FileQueryInfoFlags. |
true
if there was any error, false
otherwise.Gio::Error |
bool Gio::File::set_attributes_from_info | ( | const Glib::RefPtr< FileInfo > & | info, |
FileQueryInfoFlags | flags = FileQueryInfoFlags::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.
info | A FileInfo. |
flags | A set of FileQueryInfoFlags. |
true
if there was any error, false
otherwise.Gio::Error |
Glib::RefPtr< File > Gio::File::set_display_name | ( | const Glib::ustring & | display_name | ) |
A set_display_name() convenience overload.
Glib::RefPtr< File > Gio::File::set_display_name | ( | const Glib::ustring & | display_name, |
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
Renames file to the specified display name.
The display name is converted from UTF8 to the correct encoding for the target filesystem if possible and the file is renamed to this.
If you want to implement a rename operation in the user interface the edit name (G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) should be used as the initial value in the rename widget, and then the result after editing should be passed to g_file_set_display_name().
On success the resulting converted filename is returned.
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.
display_name | A string. |
cancellable | Cancellable object. |
nullptr
if there was an error.Glib::Error |
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.
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. |
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.
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. |
Glib::RefPtr< File > Gio::File::set_display_name_finish | ( | const Glib::RefPtr< AsyncResult > & | res | ) |
Finishes setting a display name started with g_file_set_display_name_async().
res | A AsyncResult. |
nullptr
on error. Free the returned object with Glib::object_unref().Glib::Error |
void Gio::File::start_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const Glib::RefPtr< MountOperation > & | start_operation, | ||
Drive::StartFlags | flags = Drive::StartFlags::NONE |
||
) |
Starts a file of type Mountable.
Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.
When this operation has completed, slot will be called and the operation can be finalized with start_mountable_finish().
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
slot | A callback to call when the request is satisfied. |
cancellable | A Cancellable object. |
start_operation | A MountOperation, or nullptr to avoid user interaction. |
flags | Flags affecting the operation |
void Gio::File::start_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< MountOperation > & | start_operation, | ||
Drive::StartFlags | flags = Drive::StartFlags::NONE |
||
) |
Starts a file of type Mountable.
Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.
When this operation has completed, slot will be called and the operation can be finalized with start_mountable_finish().
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
slot | A callback to call when the request is satisfied. |
start_operation | A MountOperation, or nullptr to avoid user interaction. |
flags | Flags affecting the operation |
bool Gio::File::start_mountable_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes a start operation.
See g_file_start_mountable() for details.
Finish an asynchronous start operation that was started with g_file_start_mountable().
result | A AsyncResult. |
true
if the operation finished successfully. false
otherwise.Glib::Error |
void Gio::File::stop_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const Glib::RefPtr< MountOperation > & | start_operation, | ||
Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE |
||
) |
Stops a file of type Mountable.
Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.
When this operation has completed, slot will be called and the operation can be finalized with stop_mountable_finish().
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
slot | A callback to call when the request is satisfied. |
cancellable | A Cancellable object. |
start_operation | A MountOperation, or nullptr to avoid user interaction. |
flags | Flags affecting the operation |
void Gio::File::stop_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< MountOperation > & | start_operation, | ||
Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE |
||
) |
Stops a file of type Mountable.
Using start_operation, you can request callbacks when, for instance, passwords are needed during authentication.
When this operation has completed, slot will be called and the operation can be finalized with stop_mountable_finish().
The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED will be thrown.
slot | A callback to call when the request is satisfied. |
start_operation | A MountOperation, or nullptr to avoid user interaction. |
flags | Flags affecting the operation |
bool Gio::File::stop_mountable_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes a stop operation, see g_file_stop_mountable() for details.
Finish an asynchronous stop operation that was started with g_file_stop_mountable().
result | A AsyncResult. |
true
if the operation finished successfully. false
otherwise.Glib::Error |
bool Gio::File::supports_thread_contexts | ( | ) | const |
Checks if file supports [thread-default contexts][g-main-context-push-thread-default-context].
If this returns false
, you cannot perform asynchronous operations on file in a thread that has a thread-default context.
bool Gio::File::trash | ( | ) |
A trash() convenience overload.
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.
cancellable | Cancellable object. |
true
on successful trash, false
otherwise.Glib::Error |
void Gio::File::trash_async | ( | const SlotAsyncReady & | slot_ready, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously sends the file to the Trash location, if possible.
slot_ready | A SlotAsyncReady to call when the request is satisfied |
cancellable | A Cancellable object which can be used to cancel the operation |
io_priority | The I/O priority of the request |
void Gio::File::trash_async | ( | const SlotAsyncReady & | slot_ready, |
int | io_priority = Glib::PRIORITY_DEFAULT |
||
) |
Asynchronously sends the file to the Trash location, if possible.
slot_ready | A SlotAsyncReady to call when the request is satisfied |
io_priority | The I/O priority of the request |
bool Gio::File::trash_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes an asynchronous file trashing operation, started with g_file_trash_async().
result | A AsyncResult. |
true
on successful trash, false
otherwise.Glib::Error |
void Gio::File::unmount_mountable | ( | const Glib::RefPtr< MountOperation > & | mount_operation, |
Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE |
||
) |
Unmounts a file of type FileType::MOUNTABLE.
mount_operation | A MountOperation |
flags | Flags affecting the operation. |
void Gio::File::unmount_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
const Glib::RefPtr< MountOperation > & | mount_operation, | ||
Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE |
||
) |
Unmounts a file of type FileType::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.
slot | A callback slot which will be called when the request is satisfied. |
cancellable | A Cancellable object which can be used to cancel the operation. |
mount_operation | A MountOperation |
flags | Flags affecting the operation. |
void Gio::File::unmount_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE |
||
) |
Unmounts a file of type FileType::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.
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. |
void Gio::File::unmount_mountable | ( | const SlotAsyncReady & | slot, |
const Glib::RefPtr< MountOperation > & | mount_operation, | ||
Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE |
||
) |
Unmounts a file of type FileType::MOUNTABLE.
When the operation is finished, slot will be called. You can then call unmount_mountable_finish() to get the result of the operation.
slot | A callback slot which will be called when the request is satisfied. |
mount_operation | A MountOperation |
flags | Flags affecting the operation. |
void Gio::File::unmount_mountable | ( | const SlotAsyncReady & | slot, |
Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE |
||
) |
Unmounts a file of type FileType::MOUNTABLE.
When the operation is finished, slot will be called. You can then call unmount_mountable_finish() to get the result of the operation.
slot | A callback slot which will be called when the request is satisfied. |
flags | Flags affecting the operation. |
void Gio::File::unmount_mountable | ( | Mount::UnmountFlags | flags = Mount::UnmountFlags::NONE | ) |
Unmounts a file of type FileType::MOUNTABLE.
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_with_operation() for details.
Finish an asynchronous unmount operation that was started with g_file_unmount_mountable_with_operation().
result | A AsyncResult. |
true
if the operation finished successfully. false
otherwise.Glib::Error |
|
related |
A Glib::wrap() method for this object.
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. |