[glibmm] Gio::File: Add replace_contents_bytes_aync().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Gio::File: Add replace_contents_bytes_aync().
- Date: Tue, 3 Mar 2015 08:31:29 +0000 (UTC)
commit 9b8258db815cee36c593b40e3cdc192f23fbbb63
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Mar 3 09:15:13 2015 +0100
Gio::File: Add replace_contents_bytes_aync().
There is no g_file_replace_content_bytes_finish() because this
uses the existing g_file_replace_contents_finish().
gio/src/file.ccg | 46 ++++++++++++++++++++++++++++++++++++++++++++++
gio/src/file.hg | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+), 0 deletions(-)
---
diff --git a/gio/src/file.ccg b/gio/src/file.ccg
index cdd31e6..639d4d7 100644
--- a/gio/src/file.ccg
+++ b/gio/src/file.ccg
@@ -1456,6 +1456,52 @@ void File::replace_contents_finish(const Glib::RefPtr<AsyncResult>& result)
}
+void
+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,
+ FileCreateFlags flags)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_file_replace_contents_bytes_async(gobj(),
+ const_cast<GBytes*>(Glib::unwrap(contents)),
+ etag.empty() ? 0 : etag.c_str(),
+ make_backup,
+ static_cast<GFileCreateFlags>(flags),
+ Glib::unwrap(cancellable),
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void
+File::replace_contents_bytes_async(const SlotAsyncReady& slot,
+ const Glib::RefPtr<const Glib::Bytes>& contents,
+ const std::string& etag,
+ bool make_backup,
+ FileCreateFlags flags)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_file_replace_contents_bytes_async(gobj(),
+ const_cast<GBytes*>(Glib::unwrap(contents)),
+ etag.empty() ? 0 : etag.c_str(),
+ make_backup,
+ static_cast<GFileCreateFlags>(flags),
+ 0,
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+
Glib::RefPtr<FileOutputStream> File::replace(const Glib::RefPtr<Cancellable>& cancellable, const
std::string& etag, bool make_backup, FileCreateFlags flags)
{
GError* gerror = 0;
diff --git a/gio/src/file.hg b/gio/src/file.hg
index 9dffa9f..3618b06 100644
--- a/gio/src/file.hg
+++ b/gio/src/file.hg
@@ -2360,6 +2360,51 @@ public:
void replace_contents_finish(const Glib::RefPtr<AsyncResult>& result);
_IGNORE(g_file_replace_contents_finish)
+
+ /** Same as replace_contents_async() but takes a Gio::Bytes input instead.
+ *
+ * When this operation has completed, @a 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 @a make_backup is true, this function will attempt to
+ * make a backup of the file.
+ *
+ * @param slot: A callback to call when the request is satisfied.
+ * @param cancellable A Cancellable object.
+ * @param contents Bytes of contents to replace the file with.
+ * @param etag a new entity tag for the file.
+ * @param make_backup true if a backup should be created.
+ * @param flags A set of FileCreateFlags.
+ */
+ void replace_contents_bytes_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>&
cancellable, const Glib::RefPtr<const Glib::Bytes>& contents, const std::string& etag, bool make_backup =
false, FileCreateFlags flags = FILE_CREATE_NONE);
+
+ /** Same as replace_contents_async() but takes a Gio::Bytes input instead.
+ *
+ * When this operation has completed, @a 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 @a make_backup is true, this function will attempt to
+ * make a backup of the file.
+ *
+ * @param slot: A callback to call when the request is satisfied.
+ * @param contents Bytes of contents to replace the file with.
+ * @param etag a new entity tag for the file.
+ * @param make_backup true if a backup should be created.
+ * @param flags A set of FileCreateFlags.
+ */
+ void replace_contents_bytes_async(const SlotAsyncReady& slot, const Glib::RefPtr<const Glib::Bytes>&
contents, const std::string& etag, bool make_backup = false, FileCreateFlags flags = FILE_CREATE_NONE);
+
+ _IGNORE(g_file_replace_contents_async)
+
+
_WRAP_METHOD(bool supports_thread_contexts() const, g_file_supports_thread_contexts)
// *** vfuncs ***
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]