【问题标题】:Create FTP mount using GIO library使用 GIO 库创建 FTP 挂载
【发布时间】:2012-06-17 15:25:13
【问题描述】:

我正在尝试使用GIO。我想出了如何使用 GVolumeMonitor 来捕捉音量变化并获取音量列表。 g_volume_monitor_get_mounts 函数为我提供了现有 GMount 的列表。它们中的每一个都可以代表一个 HDD 分区或一个网络共享的挂载(ftp、smb、sftp 等)。使用g_volume_mount 似乎可以安装硬盘分区。但是如何创建代表网络共享的 GMount 呢?哪些类对此负责?

这是我的代码:

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) << ")";
}

(我知道肯定有g_object_unref和g_list_free。)

输出:

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

我是使用 nautilus 创建的第一个 sftp 挂载。现在我想自己实现这个功能。目标操作系统是 Ubuntu 12.04。

【问题讨论】:

    标签: c gio


    【解决方案1】:

    我想你可能正在寻找g_file_mount_enclosing_volume()

    【讨论】:

      猜你喜欢
      • 2019-10-21
      • 2018-05-11
      • 2022-11-25
      • 1970-01-01
      • 1970-01-01
      • 2021-01-02
      • 1970-01-01
      • 2011-06-02
      • 2017-01-08
      相关资源
      最近更新 更多