}
+static GnomeVFSResult captive_sandbox_parent_file_seek_slave
+ (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset);
+
GnomeVFSResult captive_sandbox_parent_file_read(CaptiveFileParentObject *captive_file_parent_object,
gpointer buffer_captive,GnomeVFSFileSize num_bytes,GnomeVFSFileSize *bytes_read_return)
{
xmlNewProp(xml_action,"num_bytes",captive_printf_alloca("%lu",(unsigned long)num_bytes));
}
- Captive_File_read(captive_file_parent_object->corba_File_object,&buffer_corba,num_bytes,&captive_corba_ev);
- r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev);
+ r=captive_sandbox_parent_file_seek_slave(captive_file_parent_object,
+ GNOME_VFS_SEEK_START,captive_file_parent_object->offset);
+ if (r==GNOME_VFS_OK) {
+ Captive_File_read(captive_file_parent_object->corba_File_object,&buffer_corba,num_bytes,&captive_corba_ev);
+ r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev);
+ }
if (xml_action)
xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
if (r!=GNOME_VFS_OK)
g_return_val_if_fail(buffer_corba->_length<=num_bytes,GNOME_VFS_ERROR_GENERIC);
memcpy(buffer_captive,buffer_corba->_buffer,buffer_corba->_length);
*bytes_read_return=buffer_corba->_length;
+ captive_file_parent_object->offset+=buffer_corba->_length;
Captive_Bytes__freekids(buffer_corba,NULL/* 'd'; meaning? */);
CORBA_free(buffer_corba);
xmlNewProp(xml_action,"num_bytes",captive_printf_alloca("%lu",(unsigned long)num_bytes));
}
- buffer_corba_local._maximum=num_bytes;
- buffer_corba_local._length=num_bytes;
- buffer_corba_local._buffer=(/* de-const */gpointer)buffer_captive;
- buffer_corba_local._release=FALSE;
-
- Captive_File_write(captive_file_parent_object->corba_File_object,&buffer_corba_local,&bytes_written_corba,&captive_corba_ev);
- r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev);
+ r=captive_sandbox_parent_file_seek_slave(captive_file_parent_object,
+ GNOME_VFS_SEEK_START,captive_file_parent_object->offset);
+ if (r==GNOME_VFS_OK) {
+ buffer_corba_local._maximum=num_bytes;
+ buffer_corba_local._length=num_bytes;
+ buffer_corba_local._buffer=(/* de-const */gpointer)buffer_captive;
+ buffer_corba_local._release=FALSE;
+
+ Captive_File_write(captive_file_parent_object->corba_File_object,
+ &buffer_corba_local,&bytes_written_corba,&captive_corba_ev);
+ r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev);
+ }
if (xml_action)
xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
if (r!=GNOME_VFS_OK)
return r;
*bytes_written_return=bytes_written_corba;
+ captive_file_parent_object->offset+=bytes_written_corba;
if (xml_action)
xmlNewProp(xml_action,"bytes_written_return",captive_printf_alloca("%lu",(unsigned long)*bytes_written_return));
}
-GnomeVFSResult captive_sandbox_parent_file_seek
+static GnomeVFSResult captive_sandbox_parent_file_seek_slave
(CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset)
{
GnomeVFSResult r;
}
-GnomeVFSResult captive_sandbox_parent_file_tell(CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileOffset *offset_return)
+GnomeVFSResult captive_sandbox_parent_file_seek
+ (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset)
+{
+GnomeVFSResult r;
+xmlNode *xml_action=NULL;
+CaptiveVfsParentObject *captive_vfs_parent_object;
+
+ g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
+
+ captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
+
+ if (captive_vfs_parent_object->corba_bug_action) {
+ xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_seek",NULL);
+ xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
+ xmlNewProp(xml_action,"whence",
+ (whence==GNOME_VFS_SEEK_START ? "start" :
+ (whence==GNOME_VFS_SEEK_CURRENT ? "current" :
+ (whence==GNOME_VFS_SEEK_END ? "end" : captive_printf_alloca("%lu",(unsigned long)whence)))));
+ xmlNewProp(xml_action,"offset",captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)offset));
+ }
+
+ switch (whence) {
+ case GNOME_VFS_SEEK_START:
+ captive_file_parent_object->offset=offset;
+ break;
+ case GNOME_VFS_SEEK_CURRENT:
+ if (0
+ || (offset>0 && (captive_file_parent_object->offset+offset)<captive_file_parent_object->offset)
+ || (offset<0 && (captive_file_parent_object->offset+offset)>captive_file_parent_object->offset))
+ r=GNOME_VFS_ERROR_BAD_PARAMETERS;
+ else
+ captive_file_parent_object->offset+=offset;
+ break;
+ case GNOME_VFS_SEEK_END:
+ g_assert_not_reached(); /* NOT IMPLEMENTED YET */
+ r=GNOME_VFS_ERROR_GENERIC;
+ break;
+ default:
+ r=GNOME_VFS_ERROR_BAD_PARAMETERS;
+ }
+
+ if (xml_action)
+ xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+ if (r!=GNOME_VFS_OK)
+ return r;
+
+ return GNOME_VFS_OK;
+}
+
+
+#if 0 /* unused */
+static GnomeVFSResult captive_sandbox_parent_file_tell_slave
+ (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileOffset *offset_return)
{
Captive_GnomeVFSFileOffset offset_corba;
GnomeVFSResult r;
return GNOME_VFS_OK;
}
+#endif
+
+
+GnomeVFSResult captive_sandbox_parent_file_tell(CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileOffset *offset_return)
+{
+GnomeVFSResult r;
+xmlNode *xml_action=NULL;
+CaptiveVfsParentObject *captive_vfs_parent_object;
+
+ g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
+ g_return_val_if_fail(offset_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
+
+ captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
+
+ if (captive_vfs_parent_object->corba_bug_action) {
+ xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_tell",NULL);
+ xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
+ }
+
+ *offset_return=captive_file_parent_object->offset;
+ r=GNOME_VFS_OK;
+ if (xml_action)
+ xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+ if (r!=GNOME_VFS_OK)
+ return r;
+
+ if (xml_action)
+ xmlNewProp(xml_action,"offset_return",captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)*offset_return));
+
+ return GNOME_VFS_OK;
+}
GnomeVFSResult captive_sandbox_parent_file_remove(CaptiveFileParentObject *captive_file_parent_object)