[gvfs] afc: Implement truncate support for output streams



commit 8a717606329e1a4edfee67f2d01cba5a1a81e405
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Thu Oct 17 22:47:42 2013 +0200

    afc: Implement truncate support for output streams
    
    https://bugzilla.gnome.org/show_bug.cgi?id=573837

 daemon/gvfsbackendafc.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackendafc.c b/daemon/gvfsbackendafc.c
index f6b0118..ada844c 100644
--- a/daemon/gvfsbackendafc.c
+++ b/daemon/gvfsbackendafc.c
@@ -1055,6 +1055,7 @@ g_vfs_backend_afc_create (GVfsBackend *backend,
 
   g_vfs_job_open_for_write_set_handle (job, fh);
   g_vfs_job_open_for_write_set_can_seek (job, TRUE);
+  g_vfs_job_open_for_write_set_can_truncate (job, TRUE);
   g_vfs_job_succeeded (G_VFS_JOB(job));
 
   return;
@@ -1136,6 +1137,7 @@ g_vfs_backend_afc_append_to (GVfsBackend *backend,
 
   g_vfs_job_open_for_write_set_handle (job, fh);
   g_vfs_job_open_for_write_set_can_seek (job, TRUE);
+  g_vfs_job_open_for_write_set_can_truncate (job, TRUE);
   g_vfs_job_open_for_write_set_initial_offset (job, off);
   g_vfs_job_succeeded (G_VFS_JOB(job));
 
@@ -1212,6 +1214,7 @@ g_vfs_backend_afc_replace (GVfsBackend *backend,
 
   g_vfs_job_open_for_write_set_handle (job, fh);
   g_vfs_job_open_for_write_set_can_seek (job, TRUE);
+  g_vfs_job_open_for_write_set_can_truncate (job, TRUE);
   g_vfs_job_succeeded (G_VFS_JOB(job));
 
   return;
@@ -1396,6 +1399,27 @@ g_vfs_backend_afc_seek_on_write (GVfsBackend *backend,
 }
 
 static void
+g_vfs_backend_afc_truncate (GVfsBackend *backend,
+                            GVfsJobTruncate *job,
+                            GVfsBackendHandle handle,
+                            goffset size)
+{
+  GVfsBackendAfc *self;
+  FileHandle *fh;
+
+  g_return_if_fail (handle != NULL);
+
+  self = G_VFS_BACKEND_AFC(backend);
+  g_return_if_fail (self->connected);
+
+  fh = (FileHandle *) handle;
+
+  if (!g_vfs_backend_afc_check (afc_file_truncate (fh->afc_cli, fh->fd, size),
+                                G_VFS_JOB(job)))
+    g_vfs_job_succeeded (G_VFS_JOB(job));
+}
+
+static void
 g_vfs_backend_afc_set_info_from_afcinfo (GVfsBackendAfc *self,
                                          GFileInfo *info,
                                          char **afcinfo,
@@ -2698,6 +2722,7 @@ g_vfs_backend_afc_class_init (GVfsBackendAfcClass *klass)
   backend_class->close_write      = g_vfs_backend_afc_close_write;
   backend_class->write            = g_vfs_backend_afc_write;
   backend_class->seek_on_write    = g_vfs_backend_afc_seek_on_write;
+  backend_class->truncate         = g_vfs_backend_afc_truncate;
   backend_class->enumerate        = g_vfs_backend_afc_enumerate;
   backend_class->query_info       = g_vfs_backend_afc_query_info;
   backend_class->query_fs_info    = g_vfs_backend_afc_query_fs_info;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]