Question

I'm trying to use GIO. I figured out how to use GVolumeMonitor to catch volume changes and get list of volumes. g_volume_monitor_get_mounts function gives me a list of existing GMount's. Each of them can represent a HDD partition or a mount of network share (ftp, smb, sftp etc). Mounting a HDD partition seems to be possible using g_volume_mount. But how to create GMount representing a network share? Which classes are responsible for this?

Here is my code:

GVolumeMonitor* monitor = g_volume_monitor_get();
GList* list = g_volume_monitor_get_mounts(monitor);
for(; list; list = list->next) {
  GMount* mount = static_cast<GMount*>(list->data);
  GFile* file = g_mount_get_root(mount);
  qDebug() << "Mount(" << g_mount_get_name(mount) << 
              ", " << g_file_get_path(file) << ")";
}

(I know there must be g_object_unref and g_list_free.)

Output:

Mount( SFTP for ri on host.org ,  /home/ri/.gvfs/SFTP for ri on host.org ) 
Mount( Yellow hard disk ,  /media/Yellow hard disk ) 

I was created the first sftp mount using nautilus. Now I want to implement this functionality myself. Target OS is Ubuntu 12.04.

Was it helpful?

Solution

I think you might be looking for g_file_mount_enclosing_volume()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top