catching exception from boost::filesystem::is_directory

▼魔方 西西 提交于 2019-12-05 03:52:29

By "nicer error message" would you mean something like

#include <iostream>
#include <boost/filesystem.hpp>
int main()
{
    boost::filesystem::path p("/proc/1/fd/1");
    try {
       boost::filesystem::is_directory(p);
    } catch(const boost::filesystem::filesystem_error& e)
    {
       if(e.code() == boost::system::errc::permission_denied)
           std::cout << "Search permission is denied for one of the directories "
                     << "in the path prefix of " << p << "\n";
       else
           std::cout << "is_directory(" << p << ") failed with "
                     << e.code().message() << '\n';
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!