GnomeVFSResult gnome_vfs_create_uri_cancellable (GnomeVFSHandle **handle, GnomeVFSURI *uri, GnomeVFSOpenMode open_mode, gboolean exclusive, guint perm, GnomeVFSContext *context) { GnomeVFSMethodHandle *method_handle; GnomeVFSResult result; g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail (uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); if (gnome_vfs_context_check_cancellation (context)) return GNOME_VFS_ERROR_CANCELLED; if (!VFS_METHOD_HAS_FUNC(uri->method, create)) return GNOME_VFS_ERROR_NOT_SUPPORTED; result = uri->method->create (uri->method, &method_handle, uri, open_mode, exclusive, perm, context); if (result != GNOME_VFS_OK) return result; *handle = _gnome_vfs_handle_new (uri, method_handle, open_mode); return GNOME_VFS_OK; }
/** * mate_vfs_monitor_add: * @handle: after the call, @handle will be a pointer to an operation handle. * @text_uri: string representing the uri to monitor. * @monitor_type: add a directory or file monitor. * @callback: function to call when the monitor is tripped. * @user_data: data to pass to @callback. * * Watch the file or directory at @text_uri for changes (or the creation/deletion of the file) * and call @callback when there is a change. If a directory monitor is added, @callback is * notified when any file in the directory changes. * * Return value: an integer representing the result of the operation. */ MateVFSResult mate_vfs_monitor_add (MateVFSMonitorHandle **handle, const gchar *text_uri, MateVFSMonitorType monitor_type, MateVFSMonitorCallback callback, gpointer user_data) { MateVFSURI *uri; MateVFSResult result; g_return_val_if_fail (handle != NULL, MATE_VFS_ERROR_BAD_PARAMETERS); *handle = NULL; g_return_val_if_fail (text_uri != NULL, MATE_VFS_ERROR_BAD_PARAMETERS); uri = mate_vfs_uri_new (text_uri); if (uri == NULL) { return MATE_VFS_ERROR_INVALID_URI; } if (!VFS_METHOD_HAS_FUNC(uri->method, monitor_add)) { mate_vfs_uri_unref (uri); return MATE_VFS_ERROR_NOT_SUPPORTED; } result = _mate_vfs_monitor_do_add (uri->method, handle, uri, monitor_type, callback, user_data); mate_vfs_uri_unref (uri); return result; }
GnomeVFSResult _gnome_vfs_monitor_do_cancel (GnomeVFSMonitorHandle *handle) { GnomeVFSResult result; init_hash_table (); if (!VFS_METHOD_HAS_FUNC(handle->uri->method, monitor_cancel)) { return GNOME_VFS_ERROR_NOT_SUPPORTED; } result = handle->uri->method->monitor_cancel (handle->uri->method, handle->method_handle); if (result == GNOME_VFS_OK) { G_LOCK (handle_hash); /* mark this monitor as cancelled */ handle->cancelled = TRUE; /* we might be in the unlocked part of actually_dispatch_callback, * in that case, don't free the handle now. * Instead we do it in actually_dispatch_callback. */ if (!handle->in_dispatch) { destroy_monitor_handle (handle); } G_UNLOCK (handle_hash); } return result; }
GnomeVFSResult gnome_vfs_truncate_uri_cancellable (GnomeVFSURI *uri, GnomeVFSFileSize length, GnomeVFSContext *context) { g_return_val_if_fail (uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); if (gnome_vfs_context_check_cancellation (context)) return GNOME_VFS_ERROR_CANCELLED; if (!VFS_METHOD_HAS_FUNC(uri->method, truncate)) return GNOME_VFS_ERROR_NOT_SUPPORTED; return uri->method->truncate(uri->method, uri, length, context); }
GnomeVFSResult gnome_vfs_unlink_from_uri_cancellable (GnomeVFSURI *uri, GnomeVFSContext *context) { g_return_val_if_fail (uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); if (gnome_vfs_context_check_cancellation (context)) { return GNOME_VFS_ERROR_CANCELLED; } if (!VFS_METHOD_HAS_FUNC(uri->method, unlink)) { return GNOME_VFS_ERROR_NOT_SUPPORTED; } return uri->method->unlink (uri->method, uri, context); }
GnomeVFSResult gnome_vfs_create_symbolic_link_cancellable (GnomeVFSURI *uri, const char *target_reference, GnomeVFSContext *context) { g_return_val_if_fail (uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); if (gnome_vfs_context_check_cancellation (context)) { return GNOME_VFS_ERROR_CANCELLED; } if (!VFS_METHOD_HAS_FUNC(uri->method, create_symbolic_link)) { return GNOME_VFS_ERROR_NOT_SUPPORTED; } return uri->method->create_symbolic_link (uri->method, uri, target_reference, context); }
GnomeVFSResult gnome_vfs_make_directory_for_uri_cancellable (GnomeVFSURI *uri, guint perm, GnomeVFSContext *context) { GnomeVFSResult result; g_return_val_if_fail (uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); if (gnome_vfs_context_check_cancellation (context)) return GNOME_VFS_ERROR_CANCELLED; if (!VFS_METHOD_HAS_FUNC(uri->method, make_directory)) return GNOME_VFS_ERROR_NOT_SUPPORTED; result = uri->method->make_directory (uri->method, uri, perm, context); return result; }
GnomeVFSResult gnome_vfs_get_file_info_uri_cancellable (GnomeVFSURI *uri, GnomeVFSFileInfo *info, GnomeVFSFileInfoOptions options, GnomeVFSContext *context) { GnomeVFSResult result; g_return_val_if_fail (uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail (info != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); if (gnome_vfs_context_check_cancellation (context)) return GNOME_VFS_ERROR_CANCELLED; if (!VFS_METHOD_HAS_FUNC(uri->method, get_file_info)) return GNOME_VFS_ERROR_NOT_SUPPORTED; result = uri->method->get_file_info (uri->method, uri, info, options, context); return result; }
GnomeVFSResult gnome_vfs_find_directory_cancellable (GnomeVFSURI *near_uri, GnomeVFSFindDirectoryKind kind, GnomeVFSURI **result_uri, gboolean create_if_needed, gboolean find_if_needed, guint permissions, GnomeVFSContext *context) { GnomeVFSResult result; GnomeVFSURI *resolved_uri; g_return_val_if_fail (result_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); *result_uri = NULL; if (gnome_vfs_context_check_cancellation (context)) return GNOME_VFS_ERROR_CANCELLED; if (near_uri != NULL) { gnome_vfs_uri_ref (near_uri); } else { char *text_uri; text_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); g_assert (text_uri != NULL); /* assume file: method and the home directory */ near_uri = gnome_vfs_uri_new (text_uri); g_free (text_uri); } g_assert (near_uri != NULL); if (!VFS_METHOD_HAS_FUNC (near_uri->method, find_directory)) { /* skip file systems not supporting find_directory. * * TODO if we decide to introduce cross-method links (e.g. http allows * arbitrary URIs), this could be slightly wrong, because the target * method may support find_directory, so we'd also have to make sure * that a method doesn't support cross-method links. **/ return GNOME_VFS_ERROR_NOT_SUPPORTED; } /* Need to expand the final symlink, since if the directory is a symlink * we want to look at the device the symlink points to, not the one the * symlink is stored on */ result = _gnome_vfs_uri_resolve_all_symlinks_uri (near_uri, &resolved_uri); if (result == GNOME_VFS_OK) { gnome_vfs_uri_unref (near_uri); near_uri = resolved_uri; } else return result; g_assert (near_uri != NULL); if (!VFS_METHOD_HAS_FUNC(near_uri->method, find_directory)) { gnome_vfs_uri_unref (near_uri); return GNOME_VFS_ERROR_NOT_SUPPORTED; } result = near_uri->method->find_directory (near_uri->method, near_uri, kind, result_uri, create_if_needed, find_if_needed, permissions, context); gnome_vfs_uri_unref (near_uri); return result; }