[gvfs] afp: Allow seek past end of file
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] afp: Allow seek past end of file
- Date: Tue, 8 Oct 2013 07:51:26 +0000 (UTC)
commit 1474a61207aa33362a674abe674c822691a57331
Author: Alexander Larsson <alexl redhat com>
Date: Tue Oct 8 09:28:18 2013 +0200
afp: Allow seek past end of file
Also, only query file size if needed for G_SEEK_END.
https://bugzilla.gnome.org/show_bug.cgi?id=709432
daemon/gvfsbackendafp.c | 62 ++++++++++++++++++++--------------------------
1 files changed, 27 insertions(+), 35 deletions(-)
---
diff --git a/daemon/gvfsbackendafp.c b/daemon/gvfsbackendafp.c
index 679bc2c..510ce87 100644
--- a/daemon/gvfsbackendafp.c
+++ b/daemon/gvfsbackendafp.c
@@ -725,23 +725,10 @@ seek_on_write_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
size = g_file_info_get_size (info);
g_object_unref (info);
- switch (job->seek_type)
- {
- case G_SEEK_CUR:
- afp_handle->offset += job->requested_offset;
- break;
- case G_SEEK_SET:
- afp_handle->offset = job->requested_offset;
- break;
- case G_SEEK_END:
- afp_handle->offset = size + job->requested_offset;
- break;
- }
+ afp_handle->offset = size + job->requested_offset;
if (afp_handle->offset < 0)
afp_handle->offset = 0;
- else if (afp_handle->offset > size)
- afp_handle->offset = size;
g_vfs_job_seek_write_set_offset (job, afp_handle->offset);
g_vfs_job_succeeded (G_VFS_JOB (job));
@@ -757,7 +744,8 @@ try_seek_on_write (GVfsBackend *backend,
GVfsBackendAfp *afp_backend = G_VFS_BACKEND_AFP (backend);
AfpHandle *afp_handle = (AfpHandle *)handle;
- if (afp_handle->type == AFP_HANDLE_TYPE_REPLACE_FILE_DIRECT)
+ if (afp_handle->type == AFP_HANDLE_TYPE_REPLACE_FILE_DIRECT ||
+ job->seek_type != G_SEEK_END)
{
switch (job->seek_type)
{
@@ -774,8 +762,6 @@ try_seek_on_write (GVfsBackend *backend,
if (afp_handle->offset < 0)
afp_handle->offset = 0;
- else if (afp_handle->offset > afp_handle->size)
- afp_handle->offset = afp_handle->size;
g_vfs_job_seek_write_set_offset (job, afp_handle->offset);
g_vfs_job_succeeded (G_VFS_JOB (job));
@@ -813,23 +799,10 @@ seek_on_read_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
size = g_file_info_get_size (info);
g_object_unref (info);
- switch (job->seek_type)
- {
- case G_SEEK_CUR:
- afp_handle->offset += job->requested_offset;
- break;
- case G_SEEK_SET:
- afp_handle->offset = job->requested_offset;
- break;
- case G_SEEK_END:
- afp_handle->offset = size + job->requested_offset;
- break;
- }
+ afp_handle->offset = size + job->requested_offset;
if (afp_handle->offset < 0)
afp_handle->offset = 0;
- else if (afp_handle->offset > size)
- afp_handle->offset = size;
g_vfs_job_seek_read_set_offset (job, afp_handle->offset);
g_vfs_job_succeeded (G_VFS_JOB (job));
@@ -845,10 +818,29 @@ try_seek_on_read (GVfsBackend *backend,
GVfsBackendAfp *afp_backend = G_VFS_BACKEND_AFP (backend);
AfpHandle *afp_handle = (AfpHandle *)handle;
- g_vfs_afp_volume_get_fork_parms (afp_backend->volume, afp_handle->fork_refnum,
- AFP_FILE_BITMAP_EXT_DATA_FORK_LEN_BIT,
- G_VFS_JOB (job)->cancellable, seek_on_read_cb, job);
-
+ if (job->seek_type != G_SEEK_END)
+ {
+ switch (job->seek_type)
+ {
+ case G_SEEK_CUR:
+ afp_handle->offset += job->requested_offset;
+ break;
+ case G_SEEK_SET:
+ afp_handle->offset = job->requested_offset;
+ break;
+ }
+
+ if (afp_handle->offset < 0)
+ afp_handle->offset = 0;
+
+ g_vfs_job_seek_read_set_offset (job, afp_handle->offset);
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ }
+ else
+ g_vfs_afp_volume_get_fork_parms (afp_backend->volume, afp_handle->fork_refnum,
+ AFP_FILE_BITMAP_EXT_DATA_FORK_LEN_BIT,
+ G_VFS_JOB (job)->cancellable, seek_on_read_cb, job);
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]