g_return_val_if_fail(giognomevfsp!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
g_return_val_if_fail(uri!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
- errvfsresult=gnome_vfs_open_uri(&handle,uri,GNOME_VFS_OPEN_READ);
+ /* Parse 'captive_args' to get at least 'captive_option_rwmode' option value (phase 1). */
+ G_LOCK(libcaptive);
+ errbool=captive_init(
+ captive_args, /* captive_args */
+ NULL); /* image_iochannel */
+ G_UNLOCK(libcaptive);
+ g_assert(errbool==FALSE);
+
+ errvfsresult=gnome_vfs_open_uri(&handle,uri,
+ 0 /* open_mode */
+ | GNOME_VFS_OPEN_RANDOM /* mandatory; otherwise we will get truncation if GNOME_VFS_OPEN_WRITE */
+ | GNOME_VFS_OPEN_READ
+ | (captive_option_rwmode==CAPTIVE_OPTION_RWMODE_RW ? GNOME_VFS_OPEN_WRITE : 0));
g_return_val_if_fail(errvfsresult==GNOME_VFS_OK,errvfsresult);
G_LOCK(giochannel_funcs);
giognomevfs->iochannel.funcs=&giochannel_funcs;
giognomevfs->iochannel.is_seekable=TRUE;
giognomevfs->iochannel.is_readable=TRUE;
- giognomevfs->iochannel.is_writeable=TRUE;
+ giognomevfs->iochannel.is_writeable=(captive_option_rwmode==CAPTIVE_OPTION_RWMODE_RW);
giognomevfs->gnomevfshandle=handle;
+ /* Initialization for the real this time (phase 2). */
G_LOCK(libcaptive);
errbool=captive_init(
- captive_args, /* captive_args */
+ NULL, /* captive_args */
(GIOChannel *)giognomevfs); /* image_iochannel */
G_UNLOCK(libcaptive);
g_assert(errbool==TRUE);