Esempio n. 1
0
/**
 * gnome_vfs_async_set_file_info:
 * @handle_return: when the function returns, will point to a handle for
 * the async operation.
 * @uri: uri to set the file info of.
 * @info: the struct containing new information about the file.
 * @mask: control which fields of @info are to be changed about the file at @uri.
 * @options: packed boolean type providing control over various details
 * of the set_file_info operation.
 * @priority: a value from %GNOME_VFS_PRIORITY_MIN to %GNOME_VFS_PRIORITY_MAX (normally
 * should be %GNOME_VFS_PRIORITY_DEFAULT) indicating the priority to assign this job
 * in allocating threads from the thread pool.
 * @callback: function to be called when the operation is complete.
 * @callback_data: data to pass to @callback.
 * 
 * Set file info details about the file at @uri, such as permissions, name,
 * owner, and modification time.
 */
void
gnome_vfs_async_set_file_info (GnomeVFSAsyncHandle **handle_return,
			       GnomeVFSURI *uri,
			       GnomeVFSFileInfo *info,
			       GnomeVFSSetFileInfoMask mask,
			       GnomeVFSFileInfoOptions options,
			       int priority,
			       GnomeVFSAsyncSetFileInfoCallback callback,
			       gpointer callback_data)
{
	GnomeVFSJob *job;
	GnomeVFSSetFileInfoOp *op;

	g_return_if_fail (handle_return != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (info != NULL);
	g_return_if_fail (callback != NULL);
	g_return_if_fail (priority >= GNOME_VFS_PRIORITY_MIN);
	g_return_if_fail (priority <= GNOME_VFS_PRIORITY_MAX);

	job = _gnome_vfs_job_new (GNOME_VFS_OP_SET_FILE_INFO, priority, (GFunc) callback, callback_data);

	op = &job->op->specifics.set_file_info;

	op->uri = gnome_vfs_uri_ref (uri);
	op->info = gnome_vfs_file_info_new ();
	gnome_vfs_file_info_copy (op->info, info);
	op->mask = mask;
	op->options = options;

	*handle_return = job->job_handle;
	_gnome_vfs_job_go (job);
}
Esempio n. 2
0
/**
 * gnome_vfs_async_create_uri_as_channel:
 * @handle_return: pointer to a pointer to a #GnomeVFSHandle object.
 * @uri: uri to open as a #GIOChannel, creating it as necessary.
 * @open_mode: open mode i.e. for reading, writing, random, etc.
 * @exclusive: replace the file if it already exists.
 * @perm: standard POSIX-style permissions bitmask, permissions of created file.
 * @priority: a value from %GNOME_VFS_PRIORITY_MIN to %GNOME_VFS_PRIORITY_MAX (normally
 * should be %GNOME_VFS_PRIORITY_DEFAULT) indicating the priority to assign this job
 * in allocating threads from the thread pool.
 * @callback: function to be called when the operation is complete.
 * @callback_data: data to pass to @callback.
 *
 * Open @uri as a #GIOChannel, creating it as necessary. Once the channel has 
 * been established @callback will be called with @callback_data, the result of the 
 * operation, and if the result was %GNOME_VFS_OK, a reference to a #GIOChannel pointing
 * at @text_uri in @open_mode.
 *
 * Since: 2.12
 */
void           gnome_vfs_async_create_uri_as_channel  (GnomeVFSAsyncHandle                  **handle_return,
						       GnomeVFSURI                           *uri,
						       GnomeVFSOpenMode                       open_mode,
						       gboolean                               exclusive,
						       guint                                  perm,
						       int				      priority,
						       GnomeVFSAsyncCreateAsChannelCallback   callback,
						       gpointer                               callback_data)
{
	GnomeVFSJob *job;
	GnomeVFSCreateAsChannelOp *create_as_channel_op;

	g_return_if_fail (handle_return != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (callback != NULL);
	g_return_if_fail (priority >= GNOME_VFS_PRIORITY_MIN);
	g_return_if_fail (priority <= GNOME_VFS_PRIORITY_MAX);

	job = _gnome_vfs_job_new (GNOME_VFS_OP_CREATE_AS_CHANNEL, priority, (GFunc) callback, callback_data);


	create_as_channel_op = &job->op->specifics.create_as_channel;
	create_as_channel_op->uri = uri == NULL ? NULL : gnome_vfs_uri_ref (uri);
	create_as_channel_op->open_mode = open_mode;
	create_as_channel_op->exclusive = exclusive;
	create_as_channel_op->perm = perm;

	*handle_return = job->job_handle;
	_gnome_vfs_job_go (job);
}
Esempio n. 3
0
/**
 * gnome_vfs_async_create_symbolic_link:
 * @handle_return: when the function returns, will point to a handle for
 * the async operation.
 * @uri: location to create the link at.
 * @uri_reference: location to point @uri to (can be a uri fragment, i.e. relative).
 * @priority: a value from %GNOME_VFS_PRIORITY_MIN to %GNOME_VFS_PRIORITY_MAX (normally
 * should be %GNOME_VFS_PRIORITY_DEFAULT) indicating the priority to assign to this job
 * in allocating threads from the thread pool.
 * @callback: function to be called when the operation is complete.
 * @callback_data: data to pass to @callback.
 * 
 * Create a symbolic link at @uri pointing to @uri_reference. When the operation
 * has completed @callback will be called with the result of the operation and
 * @callback_data.
 */
void
gnome_vfs_async_create_symbolic_link (GnomeVFSAsyncHandle **handle_return,
				      GnomeVFSURI *uri,
				      const gchar *uri_reference,
				      int priority,
				      GnomeVFSAsyncOpenCallback callback,
				      gpointer callback_data)
{
	GnomeVFSJob *job;
	GnomeVFSCreateLinkOp *create_op;

	g_return_if_fail (handle_return != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (callback != NULL);
	g_return_if_fail (priority >= GNOME_VFS_PRIORITY_MIN);
	g_return_if_fail (priority <= GNOME_VFS_PRIORITY_MAX);

	job = _gnome_vfs_job_new (GNOME_VFS_OP_CREATE_SYMBOLIC_LINK, priority, (GFunc) callback, callback_data);

	create_op = &job->op->specifics.create_symbolic_link;
	create_op->uri = gnome_vfs_uri_ref (uri);
	create_op->uri_reference = g_strdup (uri_reference);

	*handle_return = job->job_handle;
	_gnome_vfs_job_go (job);
}
Esempio n. 4
0
static GnomeVFSAsyncHandle *
async_create (GnomeVFSURI *uri,
	      GnomeVFSOpenMode open_mode,
	      gboolean exclusive,
	      guint perm,
	      int priority,
	      GnomeVFSAsyncOpenCallback callback,
	      gpointer callback_data)
{
	GnomeVFSJob *job;
	GnomeVFSCreateOp *create_op;
	GnomeVFSAsyncHandle *result;

	job = _gnome_vfs_job_new (GNOME_VFS_OP_CREATE, priority, (GFunc) callback, callback_data);

	create_op = &job->op->specifics.create;
	create_op->uri = uri == NULL ? NULL : gnome_vfs_uri_ref (uri);
	create_op->open_mode = open_mode;
	create_op->exclusive = exclusive;
	create_op->perm = perm;

	result = job->job_handle;
	_gnome_vfs_job_go (job);

	return result;
}
Esempio n. 5
0
GnomeVFSURI *la_track_get_vfs_uri(LaTrack * self)
{
    if (!self->vfs_uri) {
	self->vfs_uri = gnome_vfs_uri_new(self->uri);
    }
    gnome_vfs_uri_ref(self->vfs_uri);
    return self->vfs_uri;
}
Esempio n. 6
0
static FileHandle *
file_handle_new (GnomeVFSURI *uri,
		 gint fd)
{
	FileHandle *result;
	result = g_new (FileHandle, 1);

	result->uri = gnome_vfs_uri_ref (uri);
	result->fd = fd;

	return result;
}
Esempio n. 7
0
/**
 * gnome_vfs_find_directory_result_dup:
 * @result: a #GnomeVFSFindDirectoryResult.
 *
 * Duplicates @result.
 *
 * Note: The internal uri is not duplicated but its
 * refcount is incremented.
 * 
 * Return value: A 1:1 copy of @result.
 * 
 * Since: 2.12
 */
GnomeVFSFindDirectoryResult*
gnome_vfs_find_directory_result_dup (GnomeVFSFindDirectoryResult *result)
{
	GnomeVFSFindDirectoryResult *copy;
	
	g_return_val_if_fail (result != NULL, NULL);

	copy = g_new0 (GnomeVFSFindDirectoryResult, 1);

	/* "Copy" and ref the objects. */
	copy->uri = result->uri;
	gnome_vfs_uri_ref (result->uri);

	copy->result = result->result;

	return copy;
}
Esempio n. 8
0
GnomeVFSResult
_gnome_vfs_monitor_do_add (GnomeVFSMethod *method,
			  GnomeVFSMonitorHandle **handle,
			  GnomeVFSURI *uri,
                          GnomeVFSMonitorType monitor_type,
			  GnomeVFSMonitorCallback callback,
			  gpointer user_data)
{
	GnomeVFSResult result;
	GnomeVFSMonitorHandle *monitor_handle = 
		g_new0(GnomeVFSMonitorHandle, 1);

	init_hash_table ();
	gnome_vfs_uri_ref (uri);
	monitor_handle->uri = uri;

	monitor_handle->type = monitor_type;
	monitor_handle->callback = callback;
	monitor_handle->user_data = user_data;
	monitor_handle->pending_callbacks = g_queue_new ();
	monitor_handle->min_send_at = 0;

	result = uri->method->monitor_add (uri->method, 
			&monitor_handle->method_handle, uri, monitor_type);

	if (result != GNOME_VFS_OK) {
		gnome_vfs_uri_unref (uri);
		g_free (monitor_handle);
		monitor_handle = NULL;
	} else {
		G_LOCK (handle_hash);
		g_hash_table_insert (handle_hash, 
				     monitor_handle->method_handle,
				     monitor_handle);
		G_UNLOCK (handle_hash);
	}

	*handle = monitor_handle;

	return result;
}
Esempio n. 9
0
static GnomeVFSAsyncHandle *
async_open (GnomeVFSURI *uri,
	    GnomeVFSOpenMode open_mode,
	    int priority,
	    GnomeVFSAsyncOpenCallback callback,
	    gpointer callback_data)
{
	GnomeVFSJob *job;
	GnomeVFSOpenOp *open_op;
	GnomeVFSAsyncHandle *result;

	job = _gnome_vfs_job_new (GNOME_VFS_OP_OPEN, priority, (GFunc) callback, callback_data);
	
	open_op = &job->op->specifics.open;
	
	open_op->uri = uri == NULL ? NULL : gnome_vfs_uri_ref (uri);
	open_op->open_mode = open_mode;

	result = job->job_handle;
	_gnome_vfs_job_go (job);

	return result;
}
Esempio n. 10
0
static GnomeVFSURI *content_make_dst_uri(WebsiteContent *content, GenerateWebsiteWorkspace *workspace)
{
    const gchar *dst_dir;
    GnomeVFSURI *path_uri;
    GnomeVFSURI *result_uri;

    g_assert(content);
    g_assert(workspace);

    dst_dir = content_get_dir(content);

    if (dst_dir) {
        path_uri = gnome_vfs_uri_append_path(workspace->build_uri, dst_dir);

    } else {
        path_uri = workspace->build_uri;
        gnome_vfs_uri_ref(workspace->build_uri);
    }

    result_uri = gnome_vfs_uri_append_path(path_uri, content->dst_filename);
    gnome_vfs_uri_unref(path_uri);

    return result_uri;
}
Esempio n. 11
0
static GnomeVFSAsyncHandle *
async_load_directory (GnomeVFSURI *uri,
		      GnomeVFSFileInfoOptions options,
		      guint items_per_notification,
		      int priority,
		      GnomeVFSAsyncDirectoryLoadCallback callback,
		      gpointer callback_data)
{
	GnomeVFSJob *job;
	GnomeVFSLoadDirectoryOp *load_directory_op;
	GnomeVFSAsyncHandle *result;

	job = _gnome_vfs_job_new (GNOME_VFS_OP_LOAD_DIRECTORY, priority, (GFunc) callback, callback_data);

	load_directory_op = &job->op->specifics.load_directory;
	load_directory_op->uri = uri == NULL ? NULL : gnome_vfs_uri_ref (uri);
	load_directory_op->options = options;
	load_directory_op->items_per_notification = items_per_notification;

	result = job->job_handle;
	_gnome_vfs_job_go (job);

	return result;
}
Esempio n. 12
0
static GnomeVFSAsyncHandle *
async_open_as_channel (GnomeVFSURI *uri,
		       GnomeVFSOpenMode open_mode,
		       guint advised_block_size,
		       int priority,
		       GnomeVFSAsyncOpenAsChannelCallback callback,
		       gpointer callback_data)
{
	GnomeVFSJob *job;
	GnomeVFSOpenAsChannelOp *open_as_channel_op;
	GnomeVFSAsyncHandle *result;

	job = _gnome_vfs_job_new (GNOME_VFS_OP_OPEN_AS_CHANNEL, priority, (GFunc) callback, callback_data);

	open_as_channel_op = &job->op->specifics.open_as_channel;
	open_as_channel_op->uri = uri == NULL ? NULL : gnome_vfs_uri_ref (uri);
	open_as_channel_op->open_mode = open_mode;
	open_as_channel_op->advised_block_size = advised_block_size;

	result = job->job_handle;
	_gnome_vfs_job_go (job);

	return result;
}
Esempio n. 13
0
	URI(const URI& other) : m_handle(other.m_handle)
	{
		if (m_handle != 0)
			gnome_vfs_uri_ref(m_handle);
	}
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;
}