2 * captive vfs 'vfs' interface to reactos
3 * Copyright (C) 2002-2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "captive/client-vfs.h" /* self */
23 #include "vfs.h" /* self-priv */
24 #include <glib/gmessages.h>
25 #include "captive/macros.h"
26 #include "captive/sandbox.h"
30 static gpointer captive_vfs_object_parent_class=NULL;
33 static GnomeVFSResult captive_vfs_close(CaptiveVfsObject *captive_vfs_object);
35 static void captive_vfs_object_finalize(CaptiveVfsObject *captive_vfs_object)
37 GnomeVFSResult errvfsresult;
39 g_return_if_fail(captive_vfs_object!=NULL);
41 errvfsresult=captive_vfs_close(captive_vfs_object);
42 g_assert(errvfsresult==GNOME_VFS_OK);
44 G_OBJECT_CLASS(captive_vfs_object_parent_class)->finalize((GObject *)captive_vfs_object);
48 static void captive_vfs_object_class_init(CaptiveVfsObjectClass *class)
50 GObjectClass *gobject_class=G_OBJECT_CLASS(class);
52 captive_vfs_object_parent_class=g_type_class_ref(G_TYPE_OBJECT);
53 gobject_class->finalize=(void (*)(GObject *object))captive_vfs_object_finalize;
57 static void captive_vfs_object_init(CaptiveVfsObject *captive_vfs_object)
59 CAPTIVE_MEMZERO(&captive_vfs_object->options);
63 GType captive_vfs_object_get_type(void)
65 static GType captive_vfs_object_type=0;
67 if (!captive_vfs_object_type) {
68 static const GTypeInfo captive_vfs_object_info={
69 sizeof(CaptiveVfsObjectClass),
71 NULL, /* base_finalize */
72 (GClassInitFunc)captive_vfs_object_class_init,
73 NULL, /* class_finalize */
74 NULL, /* class_data */
75 sizeof(CaptiveVfsObject),
77 (GInstanceInitFunc)captive_vfs_object_init,
80 captive_vfs_object_type=g_type_register_static(G_TYPE_OBJECT,
81 "CaptiveVfsObject",&captive_vfs_object_info,0);
84 return captive_vfs_object_type;
88 GnomeVFSResult captive_vfs_new
89 (CaptiveVfsObject **captive_vfs_object_return,const struct captive_options *options)
91 CaptiveVfsObject *captive_vfs_object;
94 g_return_val_if_fail(captive_vfs_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
95 g_return_val_if_fail(options!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
97 *captive_vfs_object_return=NULL;
99 captive_vfs_object=g_object_new(
100 CAPTIVE_VFS_TYPE_OBJECT, /* object_type */
101 NULL); /* first_property_name; FIXME: support properties */
103 captive_options_copy(&captive_vfs_object->options,options);
105 g_assert(captive_options==NULL);
106 captive_options=&captive_vfs_object->options;
108 errbool=captive_init();
109 g_assert(errbool==TRUE);
111 *captive_vfs_object_return=captive_vfs_object;
116 static GnomeVFSResult captive_vfs_close(CaptiveVfsObject *captive_vfs_object)
120 if (CAPTIVE_IS_SANDBOX_PARENT())
121 return captive_sandbox_parent_vfs_close(captive_vfs_object);
123 g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
125 g_assert(captive_options==&captive_vfs_object->options);
126 errbool=captive_shutdown();
127 g_assert(errbool==TRUE);
129 captive_options=NULL;
130 captive_options_free(&captive_vfs_object->options);