c++macosg++fstreamdistributed-filesystem

std::ifstream accesses network files in mac osx


How can I open a network shared file in OSX? I tried with and without "cifs:". also tried "192.168.xxx.xxx" but not working. thanks.

const std::string path_name("cifs://netshare.local/data/config.txt");

std::ifstream file( path_name.c_str(), std::ios::binary );

if (file.is_open())
{
    file.close();
    return true;
}
else
{
    // program comes in here
    return false;
}

Solution

  • Paths to network shares mounted on Mac OS X appear under /Volumes, just like any other removable disk or disk image. If the share is called "data", it'll usually be mounted at /Volumes/data, but may end up at another path if that one isn't available.

    (There's no way to directly access files on network shares that aren't mounted. So do that first.)