【问题标题】:boost filesystem how to access shared folders提升文件系统如何访问共享文件夹
【发布时间】:2013-10-27 18:37:27
【问题描述】:

我正在寻找这个,但我找不到任何可以帮助我的东西。我认为这很简单,我需要做的是使用 boost 库在我的网络中显示共享文件夹。

例如

std::string dir = "/home/user";
for (boost::filesystem::directory_iterator it(dir), end; it!=end; it++)
    if (boost::filesystem::is_directory(*it))
        cout << it->path().filename().generic_string();

这显示了路径 "/home/user" 中的所有文件夹。问题是,我需要用来显示网络中的共享文件夹的dir 是什么?我尝试"\\", "\\my_pc_name", "\\Workgroup",但我不知道,我不知道我是否可以这样做。 谢谢。

【问题讨论】:

    标签: networking boost boost-filesystem shared-directory


    【解决方案1】:

    根据您的问题,我假设您使用的是 Linux,并且您尝试访问的文件夹位于 Windows 共享上。您不能直接访问它们——您需要使用 smbfs 之类的东西来安装它们。 See this answer 了解更多。

    【讨论】:

    • 是的,我在 Linux 上并试图访问 Windows 共享,但我也需要在 Windows 中进行此操作,但当我首先执行此操作时。我正在寻找一种适用于 Linux 和 Windows 的方法。现在我开始了。感谢您的回答,我看到了链接。
    • 在 Windows 上,您可以直接访问路径(或者this link 说,我手边没有 Windows 盒子)。
    • 我在文件/proc/mounts 中看到有已安装的驱动器。如果我挂载一个共享文件夹,我可以将此路径与 boost::filesystem 一起使用,它可以工作。有没有办法挂载共享文件夹并以这种方式使用它?我在 C++ &lt;sys/mount.h&gt; 中看到命令 mount 但我不知道如何使用它,并且系统命令 mount 需要管理员权限才能使用它。
    • 当然。如果您没有 root,请尝试smbnetfs,如下所述:askubuntu.com/questions/24348/…
    猜你喜欢
    • 2012-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-28
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 2011-06-07
    相关资源
    最近更新 更多