我正在使用boost 1.52,當我試圖從網絡驅動器中獲取文件時,我無權讀取該文件。使用後我得到一個例外boost::filesystem::exists(fileName)
有沒有比在每個地方只做try, catch
更好的工作?boost :: filesystem :: exists崩潰
我已經切換回我的老代碼現在:
bool FileExists(const char* fileName)
{
struct stat my_stat;
return (stat(fileName, &my_stat) == 0);
}
//boost Exists throws exception if there are no permissions for share folder
bool FileExists(const std::string& fileName)
{
return FileExists(fileName.c_str());
}
難道你不能只使用你正在使用的函數,用'boost :: filesystem :: exists'替換'stat'以及必要的異常處理嗎?那麼你不必在每個地方都使用try-catch。它在這個功能中是孤立的。 – 2013-03-10 17:18:27