summaryrefslogtreecommitdiff
path: root/daemon/gvfsbackendafp.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-10-08 09:28:18 +0200
committerAlexander Larsson <alexl@redhat.com>2013-10-08 09:31:05 +0200
commit1474a61207aa33362a674abe674c822691a57331 (patch)
tree611a1afda20917fefdbd4655e57a25cdfaf33edb /daemon/gvfsbackendafp.c
parentd12755f991a14f4f7d5cc6930a9026e106b88933 (diff)
downloadgvfs-1474a61207aa33362a674abe674c822691a57331.tar.gz
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
Diffstat (limited to 'daemon/gvfsbackendafp.c')
-rw-r--r--daemon/gvfsbackendafp.c62
1 files changed, 27 insertions, 35 deletions
diff --git a/daemon/gvfsbackendafp.c b/daemon/gvfsbackendafp.c
index 679bc2ca..510ce879 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;
}