[gvfs] dav: Implement truncate for output streams
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] dav: Implement truncate for output streams
- Date: Sun, 12 Jan 2014 09:06:28 +0000 (UTC)
commit 686776f1a6f932e7751069715d9693e00f672b5c
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Sun Dec 8 22:46:17 2013 +0200
dav: Implement truncate for output streams
https://bugzilla.gnome.org/show_bug.cgi?id=720062
daemon/gvfsbackenddav.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index aed8603..b75ddff 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -2321,6 +2321,8 @@ try_create_tested_existence (SoupSession *session, SoupMessage *msg,
g_vfs_job_open_for_write_set_handle (G_VFS_JOB_OPEN_FOR_WRITE (job), stream);
g_vfs_job_open_for_write_set_can_seek (G_VFS_JOB_OPEN_FOR_WRITE (job),
g_seekable_can_seek (G_SEEKABLE (stream)));
+ g_vfs_job_open_for_write_set_can_truncate (G_VFS_JOB_OPEN_FOR_WRITE (job),
+ g_seekable_can_truncate (G_SEEKABLE (stream)));
g_vfs_job_succeeded (job);
}
@@ -2365,6 +2367,8 @@ open_for_replace_succeeded (GVfsBackendHttp *op_backend, GVfsJob *job,
g_vfs_job_open_for_write_set_handle (G_VFS_JOB_OPEN_FOR_WRITE (job), stream);
g_vfs_job_open_for_write_set_can_seek (G_VFS_JOB_OPEN_FOR_WRITE (job),
g_seekable_can_seek (G_SEEKABLE (stream)));
+ g_vfs_job_open_for_write_set_can_truncate (G_VFS_JOB_OPEN_FOR_WRITE (job),
+ g_seekable_can_truncate (G_SEEKABLE (stream)));
g_vfs_job_succeeded (job);
}
@@ -2513,6 +2517,26 @@ do_seek_on_write (GVfsBackend *backend,
}
}
+static void
+do_truncate (GVfsBackend *backend,
+ GVfsJobTruncate *job,
+ GVfsBackendHandle handle,
+ goffset size)
+{
+ GSeekable *stream = G_SEEKABLE (handle);
+ GError *error = NULL;
+
+ if (g_seekable_truncate (stream, size, G_VFS_JOB (job)->cancellable, &error))
+ {
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ }
+ else
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+ g_error_free (error);
+ }
+}
+
/* *** close_write () *** */
static void
try_close_write_sent (SoupSession *session,
@@ -2717,6 +2741,7 @@ g_vfs_backend_dav_class_init (GVfsBackendDavClass *klass)
backend_class->try_replace = try_replace;
backend_class->try_write = try_write;
backend_class->seek_on_write = do_seek_on_write;
+ backend_class->truncate = do_truncate;
backend_class->try_close_write = try_close_write;
backend_class->make_directory = do_make_directory;
backend_class->delete = do_delete;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]