1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* gnome-vfs-method.h - Virtual class for access methods in the GNOME
5 Copyright (C) 1999, 2001 Free Software Foundation
7 The Gnome Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The Gnome Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the Gnome Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 Author: Ettore Perazzoli <ettore@comm2000.it>
23 Seth Nickell <snickell@stanford.edu>
26 #ifndef GNOME_VFS_METHOD_H
27 #define GNOME_VFS_METHOD_H
30 * The following include helps Solaris copy with its own headers. (With 64-
31 * bit stuff enabled they like to #define open open64, etc.)
32 * See http://bugzilla.gnome.org/show_bug.cgi?id=71184 for details.
36 #include <libgnomevfs/gnome-vfs-context.h>
37 #include <libgnomevfs/gnome-vfs-file-info.h>
38 #include <libgnomevfs/gnome-vfs-find-directory.h>
39 #include <libgnomevfs/gnome-vfs-handle.h>
40 #include <libgnomevfs/gnome-vfs-transform.h>
41 #include <libgnomevfs/gnome-vfs-monitor.h>
45 #define _GNOME_VFS_METHOD_PARAM_CHECK(expression) \
46 g_return_val_if_fail ((expression), GNOME_VFS_ERROR_BAD_PARAMETERS);
48 typedef struct GnomeVFSMethod GnomeVFSMethod;
50 typedef GnomeVFSMethod * (* GnomeVFSMethodInitFunc)(const char *method_name, const char *config_args);
51 typedef void (*GnomeVFSMethodShutdownFunc)(GnomeVFSMethod *method);
53 typedef GnomeVFSResult (* GnomeVFSMethodOpenFunc)
54 (GnomeVFSMethod *method,
56 **method_handle_return,
58 GnomeVFSOpenMode mode,
59 GnomeVFSContext *context);
61 typedef GnomeVFSResult (* GnomeVFSMethodCreateFunc)
62 (GnomeVFSMethod *method,
64 **method_handle_return,
66 GnomeVFSOpenMode mode,
69 GnomeVFSContext *context);
71 typedef GnomeVFSResult (* GnomeVFSMethodCloseFunc)
72 (GnomeVFSMethod *method,
73 GnomeVFSMethodHandle *method_handle,
74 GnomeVFSContext *context);
76 typedef GnomeVFSResult (* GnomeVFSMethodReadFunc)
77 (GnomeVFSMethod *method,
78 GnomeVFSMethodHandle *method_handle,
80 GnomeVFSFileSize num_bytes,
81 GnomeVFSFileSize *bytes_read_return,
82 GnomeVFSContext *context);
84 typedef GnomeVFSResult (* GnomeVFSMethodWriteFunc)
85 (GnomeVFSMethod *method,
86 GnomeVFSMethodHandle *method_handle,
88 GnomeVFSFileSize num_bytes,
89 GnomeVFSFileSize *bytes_written_return,
90 GnomeVFSContext *context);
92 typedef GnomeVFSResult (* GnomeVFSMethodSeekFunc)
93 (GnomeVFSMethod *method,
94 GnomeVFSMethodHandle *method_handle,
95 GnomeVFSSeekPosition whence,
96 GnomeVFSFileOffset offset,
97 GnomeVFSContext *context);
99 typedef GnomeVFSResult (* GnomeVFSMethodTellFunc)
100 (GnomeVFSMethod *method,
101 GnomeVFSMethodHandle *method_handle,
102 GnomeVFSFileOffset *offset_return);
104 typedef GnomeVFSResult (* GnomeVFSMethodOpenDirectoryFunc)
105 (GnomeVFSMethod *method,
106 GnomeVFSMethodHandle **method_handle,
108 GnomeVFSFileInfoOptions options,
109 GnomeVFSContext *context);
111 typedef GnomeVFSResult (* GnomeVFSMethodCloseDirectoryFunc)
112 (GnomeVFSMethod *method,
113 GnomeVFSMethodHandle *method_handle,
114 GnomeVFSContext *context);
116 typedef GnomeVFSResult (* GnomeVFSMethodReadDirectoryFunc)
117 (GnomeVFSMethod *method,
118 GnomeVFSMethodHandle *method_handle,
119 GnomeVFSFileInfo *file_info,
120 GnomeVFSContext *context);
122 typedef GnomeVFSResult (* GnomeVFSMethodGetFileInfoFunc)
123 (GnomeVFSMethod *method,
125 GnomeVFSFileInfo *file_info,
126 GnomeVFSFileInfoOptions options,
127 GnomeVFSContext *context);
129 typedef GnomeVFSResult (* GnomeVFSMethodGetFileInfoFromHandleFunc)
130 (GnomeVFSMethod *method,
131 GnomeVFSMethodHandle *method_handle,
132 GnomeVFSFileInfo *file_info,
133 GnomeVFSFileInfoOptions options,
134 GnomeVFSContext *context);
136 typedef GnomeVFSResult (* GnomeVFSMethodTruncateFunc) (GnomeVFSMethod *method,
138 GnomeVFSFileSize length,
139 GnomeVFSContext *context);
140 typedef GnomeVFSResult (* GnomeVFSMethodTruncateHandleFunc) (GnomeVFSMethod *method,
141 GnomeVFSMethodHandle *handle,
142 GnomeVFSFileSize length,
143 GnomeVFSContext *context);
145 typedef gboolean (* GnomeVFSMethodIsLocalFunc)
146 (GnomeVFSMethod *method,
147 const GnomeVFSURI *uri);
149 typedef GnomeVFSResult (* GnomeVFSMethodMakeDirectoryFunc)
150 (GnomeVFSMethod *method,
153 GnomeVFSContext *context);
155 typedef GnomeVFSResult (* GnomeVFSMethodFindDirectoryFunc)
156 (GnomeVFSMethod *method,
157 GnomeVFSURI *find_near_uri,
158 GnomeVFSFindDirectoryKind kind,
159 GnomeVFSURI **result_uri,
160 gboolean create_if_needed,
161 gboolean find_if_needed,
163 GnomeVFSContext *context);
165 typedef GnomeVFSResult (* GnomeVFSMethodRemoveDirectoryFunc)
166 (GnomeVFSMethod *method,
168 GnomeVFSContext *context);
170 typedef GnomeVFSResult (* GnomeVFSMethodMoveFunc)
171 (GnomeVFSMethod *method,
172 GnomeVFSURI *old_uri,
173 GnomeVFSURI *new_uri,
174 gboolean force_replace,
175 GnomeVFSContext *context);
177 typedef GnomeVFSResult (* GnomeVFSMethodUnlinkFunc)
178 (GnomeVFSMethod *method,
180 GnomeVFSContext *context);
182 typedef GnomeVFSResult (* GnomeVFSMethodCheckSameFSFunc)
183 (GnomeVFSMethod *method,
186 gboolean *same_fs_return,
187 GnomeVFSContext *context);
189 typedef GnomeVFSResult (* GnomeVFSMethodSetFileInfo)
190 (GnomeVFSMethod *method,
192 const GnomeVFSFileInfo *info,
193 GnomeVFSSetFileInfoMask mask,
194 GnomeVFSContext *context);
196 typedef GnomeVFSResult (* GnomeVFSMethodCreateSymbolicLinkFunc)
197 (GnomeVFSMethod *method,
199 const gchar *target_reference,
200 GnomeVFSContext *context);
201 typedef GnomeVFSResult (* GnomeVFSMethodMonitorAddFunc)
202 (GnomeVFSMethod *method,
203 GnomeVFSMethodHandle **method_handle_return,
205 GnomeVFSMonitorType monitor_type);
207 typedef GnomeVFSResult (* GnomeVFSMethodMonitorCancelFunc)
208 (GnomeVFSMethod *method,
209 GnomeVFSMethodHandle *handle);
211 typedef GnomeVFSResult (* GnomeVFSMethodFileControlFunc)
212 (GnomeVFSMethod *method,
213 GnomeVFSMethodHandle *method_handle,
214 const char *operation,
215 gpointer operation_data,
216 GnomeVFSContext *context);
220 /* Use this macro to test whether a given function is implemented in
221 * a given GnomeVFSMethod. Note that it checks the expected size of the structure
222 * prior to testing NULL.
225 #define VFS_METHOD_HAS_FUNC(method,func) ((((char *)&((method)->func)) - ((char *)(method)) < (method)->method_table_size) && method->func != NULL)
227 /* Structure defining an access method. This is also defined as an
228 opaque type in `gnome-vfs-types.h'. */
229 struct GnomeVFSMethod {
230 gsize method_table_size; /* Used for versioning */
231 GnomeVFSMethodOpenFunc open;
232 GnomeVFSMethodCreateFunc create;
233 GnomeVFSMethodCloseFunc close;
234 GnomeVFSMethodReadFunc read;
235 GnomeVFSMethodWriteFunc write;
236 GnomeVFSMethodSeekFunc seek;
237 GnomeVFSMethodTellFunc tell;
238 GnomeVFSMethodTruncateHandleFunc truncate_handle;
239 GnomeVFSMethodOpenDirectoryFunc open_directory;
240 GnomeVFSMethodCloseDirectoryFunc close_directory;
241 GnomeVFSMethodReadDirectoryFunc read_directory;
242 GnomeVFSMethodGetFileInfoFunc get_file_info;
243 GnomeVFSMethodGetFileInfoFromHandleFunc get_file_info_from_handle;
244 GnomeVFSMethodIsLocalFunc is_local;
245 GnomeVFSMethodMakeDirectoryFunc make_directory;
246 GnomeVFSMethodRemoveDirectoryFunc remove_directory;
247 GnomeVFSMethodMoveFunc move;
248 GnomeVFSMethodUnlinkFunc unlink;
249 GnomeVFSMethodCheckSameFSFunc check_same_fs;
250 GnomeVFSMethodSetFileInfo set_file_info;
251 GnomeVFSMethodTruncateFunc truncate;
252 GnomeVFSMethodFindDirectoryFunc find_directory;
253 GnomeVFSMethodCreateSymbolicLinkFunc create_symbolic_link;
254 GnomeVFSMethodMonitorAddFunc monitor_add;
255 GnomeVFSMethodMonitorCancelFunc monitor_cancel;
256 GnomeVFSMethodFileControlFunc file_control;
259 gboolean gnome_vfs_method_init (void);
260 GnomeVFSMethod *gnome_vfs_method_get (const gchar *name);
261 GnomeVFSTransform *gnome_vfs_transform_get (const gchar *name);
265 #endif /* GNOME_VFS_METHOD_H */