GSettings: deprecate 'schema' property
[platform/upstream/glib.git] / gio / gvfs.c
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #include "config.h"
24 #include <string.h>
25 #include "gvfs.h"
26 #include "glocalvfs.h"
27 #include "giomodule-priv.h"
28 #include "glibintl.h"
29
30
31 /**
32  * SECTION:gvfs
33  * @short_description: Virtual File System 
34  * @include: gio/gio.h
35  * 
36  * Entry point for using GIO functionality.
37  *
38  **/
39
40 G_DEFINE_TYPE (GVfs, g_vfs, G_TYPE_OBJECT);
41
42 static void
43 g_vfs_class_init (GVfsClass *klass)
44 {
45 }
46
47 static void
48 g_vfs_init (GVfs *vfs)
49 {
50 }
51
52 /**
53  * g_vfs_is_active:
54  * @vfs: a #GVfs.
55  * 
56  * Checks if the VFS is active.
57  * 
58  * Returns: %TRUE if construction of the @vfs was successful and it is now active.
59  **/
60 gboolean
61 g_vfs_is_active (GVfs *vfs)
62 {
63   GVfsClass *class;
64
65   g_return_val_if_fail (G_IS_VFS (vfs), FALSE);
66
67   class = G_VFS_GET_CLASS (vfs);
68
69   return (* class->is_active) (vfs);
70 }
71
72
73 /**
74  * g_vfs_get_file_for_path:
75  * @vfs: a #GVfs.
76  * @path: a string containing a VFS path.
77  * 
78  * Gets a #GFile for @path.
79  * 
80  * Returns: (transfer full): a #GFile. 
81  *     Free the returned object with g_object_unref().
82  **/
83 GFile *
84 g_vfs_get_file_for_path (GVfs       *vfs,
85                          const char *path)
86 {
87   GVfsClass *class;
88   
89   g_return_val_if_fail (G_IS_VFS (vfs), NULL);
90   g_return_val_if_fail (path != NULL, NULL);
91
92   class = G_VFS_GET_CLASS (vfs);
93
94   return (* class->get_file_for_path) (vfs, path);
95 }
96
97 /**
98  * g_vfs_get_file_for_uri:
99  * @vfs: a#GVfs.
100  * @uri: a string containing a URI 
101  * 
102  * Gets a #GFile for @uri.
103  * 
104  * This operation never fails, but the returned object
105  * might not support any I/O operation if the URI 
106  * is malformed or if the URI scheme is not supported.
107  * 
108  * Returns: (transfer full): a #GFile. 
109  *     Free the returned object with g_object_unref().
110  **/
111 GFile *
112 g_vfs_get_file_for_uri (GVfs       *vfs,
113                         const char *uri)
114 {
115   GVfsClass *class;
116   
117   g_return_val_if_fail (G_IS_VFS (vfs), NULL);
118   g_return_val_if_fail (uri != NULL, NULL);
119
120   class = G_VFS_GET_CLASS (vfs);
121
122   return (* class->get_file_for_uri) (vfs, uri);
123 }
124
125 /**
126  * g_vfs_get_supported_uri_schemes:
127  * @vfs: a #GVfs.
128  * 
129  * Gets a list of URI schemes supported by @vfs.
130  * 
131  * Returns: (transfer none): a %NULL-terminated array of strings.
132  *     The returned array belongs to GIO and must 
133  *     not be freed or modified.
134  **/
135 const gchar * const *
136 g_vfs_get_supported_uri_schemes (GVfs *vfs)
137 {
138   GVfsClass *class;
139   
140   g_return_val_if_fail (G_IS_VFS (vfs), NULL);
141
142   class = G_VFS_GET_CLASS (vfs);
143
144   return (* class->get_supported_uri_schemes) (vfs);
145 }
146
147 /**
148  * g_vfs_parse_name:
149  * @vfs: a #GVfs.
150  * @parse_name: a string to be parsed by the VFS module.
151  * 
152  * This operation never fails, but the returned object might 
153  * not support any I/O operations if the @parse_name cannot 
154  * be parsed by the #GVfs module.
155  * 
156  * Returns: (transfer full): a #GFile for the given @parse_name.
157  *     Free the returned object with g_object_unref().
158  **/
159 GFile *
160 g_vfs_parse_name (GVfs       *vfs,
161                   const char *parse_name)
162 {
163   GVfsClass *class;
164   
165   g_return_val_if_fail (G_IS_VFS (vfs), NULL);
166   g_return_val_if_fail (parse_name != NULL, NULL);
167
168   class = G_VFS_GET_CLASS (vfs);
169
170   return (* class->parse_name) (vfs, parse_name);
171 }
172
173 /**
174  * g_vfs_get_default:
175  * 
176  * Gets the default #GVfs for the system.
177  * 
178  * Returns: (transfer none): a #GVfs. 
179  **/
180 GVfs *
181 g_vfs_get_default (void)
182 {
183   return _g_io_module_get_default (G_VFS_EXTENSION_POINT_NAME,
184                                    "GIO_USE_VFS",
185                                    (GIOModuleVerifyFunc)g_vfs_is_active);
186 }
187
188 /**
189  * g_vfs_get_local:
190  * 
191  * Gets the local #GVfs for the system.
192  * 
193  * Returns: (transfer none): a #GVfs.
194  **/
195 GVfs *
196 g_vfs_get_local (void)
197 {
198   static gsize vfs = 0;
199
200   if (g_once_init_enter (&vfs))
201     g_once_init_leave (&vfs, (gsize)_g_local_vfs_new ());
202
203   return G_VFS (vfs);
204 }