ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / libgnomevfs / gnome-vfs-ops.c
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* gnome-vfs-ops.c - Synchronous operations for the GNOME Virtual File
3    System.
4
5    Copyright (C) 1999 Free Software Foundation
6
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.
11
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.
16
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.
21
22    Author: Ettore Perazzoli <ettore@gnu.org> */
23
24 #include <config.h>
25 #include "gnome-vfs-ops.h"
26 #include "gnome-vfs-monitor-private.h"
27 #include "gnome-vfs-cancellable-ops.h"
28 #include "gnome-vfs-handle-private.h"
29 #include <glib/gmessages.h>
30
31 /**
32  * gnome_vfs_open:
33  * @handle: A pointer to a pointer to a GnomeVFSHandle object
34  * @text_uri: String representing the URI to open
35  * @open_mode: Open mode
36  * 
37  * Open @text_uri according to mode @open_mode.  On return, @handle will then
38  * contain a pointer to a handle for the open file.
39  * 
40  * Return value: An integer representing the result of the operation
41  **/
42 GnomeVFSResult
43 gnome_vfs_open (GnomeVFSHandle **handle,
44                 const gchar *text_uri,
45                 GnomeVFSOpenMode open_mode)
46 {
47         GnomeVFSURI *uri;
48         GnomeVFSResult result;
49
50         g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
51         g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
52
53         uri = gnome_vfs_uri_new (text_uri);
54         if (uri == NULL)
55                 return GNOME_VFS_ERROR_INVALID_URI;
56
57         result = gnome_vfs_open_uri (handle, uri, open_mode);
58
59         gnome_vfs_uri_unref (uri);
60
61         return result;
62 }
63
64 /**
65  * gnome_vfs_open_uri:
66  * @handle: A pointer to a pointer to a GnomeVFSHandle object
67  * @uri: URI to open
68  * @open_mode: Open mode
69  * 
70  * Open @uri according to mode @open_mode.  On return, @handle will then
71  * contain a pointer to a handle for the open file.
72  * 
73  * Return value: An integer representing the result of the operation
74  **/
75 GnomeVFSResult
76 gnome_vfs_open_uri (GnomeVFSHandle **handle,
77                     GnomeVFSURI *uri,
78                     GnomeVFSOpenMode open_mode)
79 {
80         return gnome_vfs_open_uri_cancellable (handle, uri, open_mode, NULL);
81 }
82
83 /**
84  * gnome_vfs_create:
85  * @handle: A pointer to a pointer to a GnomeVFSHandle object
86  * @text_uri: String representing the URI to create
87  * @open_mode: mode to leave the file opened in after creation (or %GNOME_VFS_OPEN_MODE_NONE
88  * to leave the file closed after creation)
89  * @exclusive: Whether the file should be created in "exclusive" mode:
90  * i.e. if this flag is nonzero, operation will fail if a file with the
91  * same name already exists.
92  * @perm: Bitmap representing the permissions for the newly created file
93  * (Unix style).
94  * 
95  * Create @uri according to mode @open_mode.  On return, @handle will then
96  * contain a pointer to a handle for the open file.
97  * 
98  * Return value: An integer representing the result of the operation
99  **/
100 GnomeVFSResult
101 gnome_vfs_create (GnomeVFSHandle **handle,
102                   const gchar *text_uri,
103                   GnomeVFSOpenMode open_mode,
104                   gboolean exclusive,
105                   guint perm)
106 {
107         GnomeVFSURI *uri;
108         GnomeVFSResult result;
109
110         g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
111         g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
112
113         uri = gnome_vfs_uri_new (text_uri);
114         if (uri == NULL)
115                 return GNOME_VFS_ERROR_INVALID_URI;
116
117         result = gnome_vfs_create_uri (handle, uri, open_mode, exclusive, perm);
118
119         gnome_vfs_uri_unref (uri);
120
121         return result;
122 }
123
124 /**
125  * gnome_vfs_create_uri:
126  * @handle: A pointer to a pointer to a GnomeVFSHandle object
127  * @uri: URI for the file to create
128  * @open_mode: Open mode
129  * @exclusive: Whether the file should be created in "exclusive" mode:
130  * i.e. if this flag is nonzero, operation will fail if a file with the
131  * same name already exists.
132  * @perm: Bitmap representing the permissions for the newly created file
133  * (Unix style).
134  * 
135  * Create @uri according to mode @open_mode.  On return, @handle will then
136  * contain a pointer to a handle for the open file.
137  * 
138  * Return value: An integer representing the result of the operation
139  **/
140 GnomeVFSResult
141 gnome_vfs_create_uri (GnomeVFSHandle **handle,
142                       GnomeVFSURI *uri,
143                       GnomeVFSOpenMode open_mode,
144                       gboolean exclusive,
145                       guint perm)
146 {
147         return gnome_vfs_create_uri_cancellable (handle, uri, open_mode,
148                                                  exclusive, perm, NULL);
149 }
150
151 /**
152  * gnome_vfs_close:
153  * @handle: A pointer to a GnomeVFSHandle object
154  * 
155  * Close file associated with @handle.
156  * 
157  * Return value: An integer representing the result of the operation.
158  **/
159 GnomeVFSResult
160 gnome_vfs_close (GnomeVFSHandle *handle)
161 {
162         return gnome_vfs_close_cancellable (handle, NULL);
163 }
164
165 /**
166  * gnome_vfs_read:
167  * @handle: Handle of the file to read data from
168  * @buffer: Pointer to a buffer that must be at least @bytes bytes large
169  * @bytes: Number of bytes to read
170  * @bytes_read: Pointer to a variable that will hold the number of bytes
171  * effectively read on return.
172  * 
173  * Read @bytes from @handle.  As with Unix system calls, the number of
174  * bytes read can effectively be less than @bytes on return and will be
175  * stored in @bytes_read.
176  * 
177  * Return value: An integer representing the result of the operation
178  **/
179 GnomeVFSResult
180 gnome_vfs_read (GnomeVFSHandle *handle,
181                 gpointer buffer,
182                 GnomeVFSFileSize bytes,
183                 GnomeVFSFileSize *bytes_read)
184 {
185         return gnome_vfs_read_cancellable (handle, buffer, bytes, bytes_read,
186                                            NULL);
187 }
188
189 /**
190  * gnome_vfs_write:
191  * @handle: Handle of the file to write data to
192  * @buffer: Pointer to the buffer containing the data to be written
193  * @bytes: Number of bytes to write
194  * @bytes_written: Pointer to a variable that will hold the number of bytes
195  * effectively written on return.
196  * 
197  * Write @bytes into the file opened through @handle.  As with Unix system
198  * calls, the number of bytes written can effectively be less than @bytes on
199  * return and will be stored in @bytes_written.
200  * 
201  * Return value: An integer representing the result of the operation
202  **/
203 GnomeVFSResult
204 gnome_vfs_write (GnomeVFSHandle *handle,
205                  gconstpointer buffer,
206                  GnomeVFSFileSize bytes,
207                  GnomeVFSFileSize *bytes_written)
208 {
209         return gnome_vfs_write_cancellable (handle, buffer, bytes,
210                                             bytes_written, NULL);
211 }
212
213 /**
214  * gnome_vfs_seek:
215  * @handle: Handle for which the current position must be changed
216  * @whence: Integer value representing the starting position
217  * @offset: Number of bytes to skip from the position specified by @whence
218  * (a positive value means to move forward; a negative one to move backwards)
219  * 
220  * Set the current position for reading/writing through @handle.
221  * 
222  * Return value: 
223  **/
224 GnomeVFSResult
225 gnome_vfs_seek (GnomeVFSHandle *handle,
226                 GnomeVFSSeekPosition whence,
227                 GnomeVFSFileOffset offset)
228 {
229         return gnome_vfs_seek_cancellable (handle, whence, offset, NULL);
230 }
231
232 /**
233  * gnome_vfs_tell:
234  * @handle: Handle for which the current position must be retrieved
235  * @offset_return: Pointer to a variable that will contain the current position
236  * on return
237  * 
238  * Return the current position on @handle. This is the point in the file
239  * pointed to by handle that reads and writes will occur on.
240  * 
241  * Return value: An integer representing the result of the operation
242  **/
243 GnomeVFSResult
244 gnome_vfs_tell (GnomeVFSHandle *handle,
245                 GnomeVFSFileSize *offset_return)
246 {
247         g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
248
249         return _gnome_vfs_handle_do_tell (handle, offset_return);
250 }
251
252 /**
253  * gnome_vfs_get_file_info:
254  * @text_uri: URI of the file for which information will be retrieved
255  * @info: Pointer to a GnomeVFSFileInfo object that will hold the information
256  * for the file on return
257  * @options: Options for retrieving file information
258  * to retrieve for the file
259  * 
260  * Retrieve information about @text_uri.  The information will be stored in
261  * @info.
262  * 
263  * Return value: An integer representing the result of the operation
264  **/
265 GnomeVFSResult
266 gnome_vfs_get_file_info (const gchar *text_uri,
267                          GnomeVFSFileInfo *info,
268                          GnomeVFSFileInfoOptions options)
269 {
270         GnomeVFSURI *uri;
271         GnomeVFSResult result;
272
273         uri = gnome_vfs_uri_new (text_uri);
274
275         if (uri == NULL)
276                 return GNOME_VFS_ERROR_NOT_SUPPORTED;
277         
278         result = gnome_vfs_get_file_info_uri(uri, info, options);
279         gnome_vfs_uri_unref (uri);
280
281         return result;
282 }
283
284 /**
285  * gnome_vfs_get_file_info_uri:
286  * @uri: URI of the file for which information will be retrieved
287  * @info: Pointer to a GnomeVFSFileInfo object that will hold the information
288  * for the file on return
289  * @options: Options for retrieving file information
290  * to retrieve for the file
291  * 
292  * Retrieve information about @text_uri.  The information will be stored in
293  * @info.
294  * 
295  * Return value: An integer representing the result of the operation
296  **/
297 GnomeVFSResult
298 gnome_vfs_get_file_info_uri (GnomeVFSURI *uri,
299                              GnomeVFSFileInfo *info,
300                              GnomeVFSFileInfoOptions options)
301 {
302         return gnome_vfs_get_file_info_uri_cancellable (uri, 
303                                                         info, 
304                                                         options,
305                                                         NULL);
306 }
307
308 /**
309  * gnome_vfs_get_file_info_from_handle:
310  * @handle: Handle of the file for which information must be retrieved
311  * @info: Pointer to a GnomeVFSFileInfo object that will hold the information
312  * for the file on return
313  * @options: Options for retrieving file information
314  * to retrieve for the file
315  * 
316  * Retrieve information about an open file.  The information will be stored in
317  * @info.
318  * 
319  * Return value: An integer representing the result of the operation
320  **/
321 GnomeVFSResult
322 gnome_vfs_get_file_info_from_handle (GnomeVFSHandle *handle,
323                                      GnomeVFSFileInfo *info,
324                                      GnomeVFSFileInfoOptions options)
325 {
326         return gnome_vfs_get_file_info_from_handle_cancellable (handle, info,
327                                                                 options,
328                                                                 NULL);
329 }
330
331 /**
332  * gnome_vfs_truncate:
333  * @text_uri: URI of the file to be truncated
334  * @length: length of the new file at @text_uri
335  * 
336  * Truncate the file at @text_uri to @length bytes.
337  * 
338  * Return value: An integer representing the result of the operation
339  **/
340 GnomeVFSResult
341 gnome_vfs_truncate (const char *text_uri, GnomeVFSFileSize length)
342 {
343         GnomeVFSURI *uri;
344         GnomeVFSResult result;
345
346         uri = gnome_vfs_uri_new (text_uri);
347
348         if (uri == NULL)
349                 return GNOME_VFS_ERROR_NOT_SUPPORTED;
350
351         result = gnome_vfs_truncate_uri(uri, length);
352         gnome_vfs_uri_unref (uri);
353
354         return result;
355 }
356
357
358 /**
359  * gnome_vfs_truncate_uri:
360  * @uri: URI of the file to be truncated
361  * @length: length of the new file at @uri
362  * 
363  * Truncate the file at @uri to be only @length bytes. Data past @length
364  * bytes will be discarded.
365  * 
366  * Return value: An integer representing the result of the operation
367  **/
368 GnomeVFSResult
369 gnome_vfs_truncate_uri (GnomeVFSURI *uri, GnomeVFSFileSize length)
370 {
371         return gnome_vfs_truncate_uri_cancellable(uri, length, NULL);
372 }
373
374 /**
375  * gnome_vfs_truncate_handle:
376  * @handle: a handle to the file to be truncated
377  * @length: length of the new file the handle is open to
378  * 
379  * Truncate the file pointed to be @handle to be only @length bytes. 
380  * Data past @length bytes will be discarded.
381  * 
382  * Return value: An integer representing the result of the operation
383  **/
384 GnomeVFSResult
385 gnome_vfs_truncate_handle (GnomeVFSHandle *handle, GnomeVFSFileSize length)
386 {
387         return gnome_vfs_truncate_handle_cancellable(handle, length, NULL);
388 }
389
390 /**
391  * gnome_vfs_make_directory_for_uri:
392  * @uri: URI of the directory to be created
393  * @perm: Unix-style permissions for the newly created directory
394  * 
395  * Create a directory at @uri. Only succeeds if a file or directory
396  * does not already exist at @uri.
397  * 
398  * Return value: An integer representing the result of the operation
399  **/
400 GnomeVFSResult
401 gnome_vfs_make_directory_for_uri (GnomeVFSURI *uri,
402                                   guint perm)
403 {
404         return gnome_vfs_make_directory_for_uri_cancellable (uri, perm, NULL);
405 }
406
407 /**
408  * gnome_vfs_make_directory:
409  * @text_uri: URI of the directory to be created
410  * @perm: Unix-style permissions for the newly created directory
411  * 
412  * Create @text_uri as a directory.
413  * 
414  * Return value: An integer representing the result of the operation
415  **/
416 GnomeVFSResult
417 gnome_vfs_make_directory (const gchar *text_uri,
418                           guint perm)
419 {
420         GnomeVFSResult result;
421         GnomeVFSURI *uri;
422
423         g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
424
425         uri = gnome_vfs_uri_new (text_uri);
426         if (uri == NULL)
427                 return GNOME_VFS_ERROR_INVALID_URI;
428
429         result = gnome_vfs_make_directory_for_uri (uri, perm);
430
431         gnome_vfs_uri_unref (uri);
432
433         return result;
434 }
435
436 /**
437  * gnome_vfs_remove_directory_from_uri:
438  * @uri: URI of the directory to be removed
439  * 
440  * Remove @uri.  @uri must be an empty directory.
441  * 
442  * Return value: An integer representing the result of the operation
443  **/
444 GnomeVFSResult
445 gnome_vfs_remove_directory_from_uri (GnomeVFSURI *uri)
446 {
447         return gnome_vfs_remove_directory_from_uri_cancellable (uri, NULL);
448 }
449
450 /**
451  * gnome_vfs_remove_directory:
452  * @text_uri: URI of the directory to be removed
453  * 
454  * Remove @text_uri.  @text_uri must be an empty directory.
455  * 
456  * Return value: An integer representing the result of the operation
457  **/
458 GnomeVFSResult
459 gnome_vfs_remove_directory (const gchar *text_uri)
460 {
461         GnomeVFSResult result;
462         GnomeVFSURI *uri;
463
464         g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
465
466         uri = gnome_vfs_uri_new (text_uri);
467         if (uri == NULL)
468                 return GNOME_VFS_ERROR_INVALID_URI;
469
470         result = gnome_vfs_remove_directory_from_uri (uri);
471
472         gnome_vfs_uri_unref (uri);
473
474         return result;
475 }
476
477 /**
478  * gnome_vfs_unlink_from_uri:
479  * @uri: URI of the file to be unlinked
480  * 
481  * Unlink @uri (i.e. delete the file).
482  * 
483  * Return value: An integer representing the result of the operation
484  **/
485 GnomeVFSResult
486 gnome_vfs_unlink_from_uri (GnomeVFSURI *uri)
487 {
488         return gnome_vfs_unlink_from_uri_cancellable (uri, NULL);
489 }
490
491 /**
492  * gnome_vfs_create_symbolic_link:
493  * @uri: URI to create a link at
494  * @target_reference: URI "reference" to point the link to (URI or relative path)
495  *
496  * Creates a symbolic link, or eventually, a URI link (as necessary) 
497  * at @uri pointing to @target_reference
498  *
499  * Return value: An integer representing the result of the operation
500  **/
501 GnomeVFSResult
502 gnome_vfs_create_symbolic_link (GnomeVFSURI *uri, const gchar *target_reference)
503 {
504         return gnome_vfs_create_symbolic_link_cancellable (uri, target_reference, NULL);
505 }
506
507 /**
508  * gnome_vfs_unlink:
509  * @text_uri: URI of the file to be unlinked
510  * 
511  * Unlink @text_uri (i.e. delete the file).
512  * 
513  * Return value: An integer representing the result of the operation
514  **/
515 GnomeVFSResult
516 gnome_vfs_unlink (const gchar *text_uri)
517 {
518         GnomeVFSResult result;
519         GnomeVFSURI *uri;
520
521         g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
522
523         uri = gnome_vfs_uri_new (text_uri);
524         if (uri == NULL)
525                 return GNOME_VFS_ERROR_INVALID_URI;
526
527         result = gnome_vfs_unlink_from_uri (uri);
528
529         gnome_vfs_uri_unref (uri);
530
531         return result;
532 }
533
534 /**
535  * gnome_vfs_move_uri:
536  * @old_uri: Source URI
537  * @new_uri: Destination URI
538  * @force_replace: If %TRUE, move target to @new_uri even if there 
539  * is already a file at @new_uri. If there is a file, it will be discarded.
540  * 
541  * Move a file from URI @old_uri to @new_uri.  This will only work if @old_uri 
542  * and @new_uri are on the same file system.  Otherwise, it is necessary 
543  * to use the more general %gnome_vfs_xfer_uri() function.
544  * 
545  * Return value: An integer representing the result of the operation.
546  **/
547 GnomeVFSResult
548 gnome_vfs_move_uri (GnomeVFSURI *old_uri,
549                     GnomeVFSURI *new_uri,
550                     gboolean force_replace)
551 {
552         return gnome_vfs_move_uri_cancellable (old_uri, new_uri, 
553                                                force_replace, NULL);
554 }
555
556 /**
557  * gnome_vfs_move:
558  * @old_text_uri: Source URI
559  * @new_text_uri: Destination URI
560  * @force_replace: if %TRUE, perform the operation even if it unlinks an existing
561  * file at @new_text_uri
562  * 
563  * Move a file from URI @old_text_uri to @new_text_uri.  This will only work 
564  * if @old_text_uri and @new_text_uri are on the same file system.  Otherwise,
565  * it is necessary to use the more general %gnome_vfs_xfer_uri() function.
566  * 
567  * Return value: An integer representing the result of the operation.
568  **/
569 GnomeVFSResult
570 gnome_vfs_move (const gchar *old_text_uri,
571                 const gchar *new_text_uri,
572                 gboolean force_replace)
573 {
574         GnomeVFSURI *old_uri, *new_uri;
575         GnomeVFSResult retval;
576
577         g_return_val_if_fail (old_text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
578         g_return_val_if_fail (new_text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
579
580         old_uri = gnome_vfs_uri_new (old_text_uri);
581         if (old_uri == NULL)
582                 return GNOME_VFS_ERROR_INVALID_URI;
583
584         new_uri = gnome_vfs_uri_new (new_text_uri);
585         if (new_uri == NULL) {
586                 gnome_vfs_uri_unref (old_uri);
587                 return GNOME_VFS_ERROR_INVALID_URI;
588         }
589
590         retval = gnome_vfs_move_uri (old_uri, new_uri, force_replace);
591
592         gnome_vfs_uri_unref (old_uri);
593         gnome_vfs_uri_unref (new_uri);
594
595         return retval;
596 }
597
598 /**
599  * gnome_vfs_check_same_fs_uris:
600  * @source_uri: A URI
601  * @target_uri: Another URI
602  * @same_fs_return: Pointer to a boolean variable which will be set to %TRUE
603  * if @source_uri and @target_uri are on the same file system on return.
604  * 
605  * Check if @source_uri and @target_uri are on the same file system.
606  * 
607  * Return value: An integer representing the result of the operation.
608  **/
609 GnomeVFSResult
610 gnome_vfs_check_same_fs_uris (GnomeVFSURI *source_uri,
611                               GnomeVFSURI *target_uri,
612                               gboolean *same_fs_return)
613 {
614         return gnome_vfs_check_same_fs_uris_cancellable (source_uri, 
615                                                          target_uri, 
616                                                          same_fs_return,
617                                                          NULL);
618 }
619
620 /**
621  * gnome_vfs_check_same_fs:
622  * @source: A URI
623  * @target: Another URI
624  * @same_fs_return: Pointer to a boolean variable which will be set to %TRUE
625  *
626  * Return %TRUE if @source and @target are on the same file system.
627  * 
628  * Return value: An integer representing the result of the operation.
629  **/
630 GnomeVFSResult
631 gnome_vfs_check_same_fs (const gchar *source,
632                          const gchar *target,
633                          gboolean *same_fs_return)
634 {
635         GnomeVFSURI *a_uri, *b_uri;
636         GnomeVFSResult retval;
637
638         g_return_val_if_fail (source != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
639         g_return_val_if_fail (target != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
640         g_return_val_if_fail (same_fs_return != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
641
642         *same_fs_return = FALSE;
643
644         a_uri = gnome_vfs_uri_new (source);
645         if (a_uri == NULL)
646                 return GNOME_VFS_ERROR_INVALID_URI;
647
648         b_uri = gnome_vfs_uri_new (target);
649         if (b_uri == NULL) {
650                 gnome_vfs_uri_unref (a_uri);
651                 return GNOME_VFS_ERROR_INVALID_URI;
652         }
653
654         retval = gnome_vfs_check_same_fs_uris (a_uri, b_uri, same_fs_return);
655
656         gnome_vfs_uri_unref (a_uri);
657         gnome_vfs_uri_unref (b_uri);
658
659         return retval;
660 }
661
662 /**
663  * gnome_vfs_set_file_info_uri:
664  * @uri: A URI
665  * @info: Information that must be set for the file
666  * @mask: Bit mask representing which fields of @info need to be set 
667  * 
668  * Set file information for @uri; only the information for which the
669  * corresponding bit in @mask is set is actually modified.
670  * 
671  * Return value: An integer representing the result of the operation.
672  **/
673 GnomeVFSResult
674 gnome_vfs_set_file_info_uri (GnomeVFSURI *uri,
675                              GnomeVFSFileInfo *info,
676                              GnomeVFSSetFileInfoMask mask)
677 {
678         return gnome_vfs_set_file_info_cancellable (uri, info, mask, NULL);
679 }
680
681 /**
682  * gnome_vfs_set_file_info:
683  * @text_uri: A URI
684  * @info: Information that must be set for the file
685  * @mask: Bit mask representing which fields of @info need to be set 
686  * 
687  * Set file information for @uri; only the information for which the
688  * corresponding bit in @mask is set is actually modified.
689  * 
690  * Return value: An integer representing the result of the operation.
691  **/
692 GnomeVFSResult
693 gnome_vfs_set_file_info (const gchar *text_uri,
694                          GnomeVFSFileInfo *info,
695                          GnomeVFSSetFileInfoMask mask)
696 {
697         GnomeVFSURI *uri;
698         GnomeVFSResult result;
699
700         uri = gnome_vfs_uri_new (text_uri);
701         if (uri == NULL)
702                 return GNOME_VFS_ERROR_INVALID_URI;
703
704         result = gnome_vfs_set_file_info_uri (uri, info, mask);
705
706         gnome_vfs_uri_unref (uri);
707
708         return result;
709 }
710
711 /**
712  * gnome_vfs_uri_exists:
713  * @uri: A URI
714  * 
715  * Check if the URI points to an existing entity.
716  * 
717  * Return value: TRUE if URI exists.
718  **/
719 gboolean
720 gnome_vfs_uri_exists (GnomeVFSURI *uri)
721 {
722         GnomeVFSFileInfo *info;
723         GnomeVFSResult result;
724
725         info = gnome_vfs_file_info_new ();
726         result = gnome_vfs_get_file_info_uri (uri, info, GNOME_VFS_FILE_INFO_DEFAULT);
727         gnome_vfs_file_info_unref (info);
728
729         return result == GNOME_VFS_OK;
730 }
731
732 /**
733  * gnome_vfs_monitor_add:
734  * @handle: after the call, @handle will be a pointer to an operation handle
735  * @text_uri: URI to monitor
736  * @monitor_type: add a directory or file monitor
737  * @callback: function to call when the monitor is tripped
738  * @user_data: data to pass to @callback
739  *
740  * Watch the file or directory at @text_uri for changes (or the creation/deletion of the file)
741  * and call @callback when there is a change. If a directory monitor is added, @callback is
742  * notified when any file in the directory changes.
743  *
744  * Return value: an integer representing the success of the operation
745  **/
746 GnomeVFSResult 
747 gnome_vfs_monitor_add (GnomeVFSMonitorHandle **handle,
748                        const gchar *text_uri,
749                        GnomeVFSMonitorType monitor_type,
750                        GnomeVFSMonitorCallback callback,
751                        gpointer user_data)
752 {
753         GnomeVFSURI *uri = gnome_vfs_uri_new (text_uri);
754         GnomeVFSResult result;
755
756         if (uri == NULL) {
757                 return GNOME_VFS_ERROR_INVALID_URI;
758         }
759
760         if (!VFS_METHOD_HAS_FUNC(uri->method, monitor_add)) {
761                 gnome_vfs_uri_unref (uri);
762                 return GNOME_VFS_ERROR_NOT_SUPPORTED;
763         }
764
765         result = _gnome_vfs_monitor_do_add (uri->method, handle, uri,
766                                                 monitor_type, callback, 
767                                                 user_data);
768
769         gnome_vfs_uri_unref (uri);
770
771         return result;
772 }
773
774 /**
775  * gnome_vfs_monitor_cancel:
776  * @handle: handle of the monitor to cancel
777  *
778  * Cancel the monitor pointed to be @handle.
779  *
780  * Return value: an integer representing the success of the operation
781  **/
782 GnomeVFSResult 
783 gnome_vfs_monitor_cancel (GnomeVFSMonitorHandle *handle)
784 {
785         g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
786
787         return _gnome_vfs_monitor_do_cancel (handle);
788 }
789
790 /**
791  * gnome_vfs_file_control:
792  * @handle: handle of the file to affect
793  * @operation: The operation to execute
794  * @operation_data: The data needed to execute the operation
795  *
796  * Execute a backend dependent operation specified by the string @operation.
797  * This is typically used for specialized vfs backends that need additional
798  * operations that gnome-vfs doesn't have. Compare it to the unix call ioctl().
799  * The format of @operation_data depends on the operation. Operation that are
800  * backend specific are normally namespaced by their module name.
801  *
802  * Return value: an integer representing the success of the operation
803  **/
804 GnomeVFSResult
805 gnome_vfs_file_control (GnomeVFSHandle *handle,
806                         const char *operation,
807                         gpointer operation_data)
808 {
809         return gnome_vfs_file_control_cancellable (handle, operation, operation_data, NULL);
810 }
811