#4101 Handle boost::filesystem's exceptions

master
Andrey Kleshchev 2025-05-19 21:51:55 +03:00 committed by Andrey Kleshchev
parent 479a23af5e
commit 1d40793b17
2 changed files with 17 additions and 4 deletions

View File

@ -110,9 +110,10 @@ std::vector<std::string> LLDir::getFilesInDir(const std::string &dirname)
std::vector<std::string> v;
if (exists(p))
boost::system::error_code ec;
if (exists(p, ec) && !ec.failed())
{
if (is_directory(p))
if (is_directory(p, ec) && !ec.failed())
{
boost::filesystem::directory_iterator end_iter;
for (boost::filesystem::directory_iterator dir_itr(p);

View File

@ -4780,7 +4780,18 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
#else
boost::filesystem::path b_path(lastSnapshotDir);
#endif
if (!boost::filesystem::is_directory(b_path))
boost::system::error_code ec;
if (!boost::filesystem::is_directory(b_path, ec) || ec.failed())
{
LLSD args;
args["PATH"] = lastSnapshotDir;
LLNotificationsUtil::add("SnapshotToLocalDirNotExist", args);
resetSnapshotLoc();
failure_cb();
return;
}
boost::filesystem::space_info b_space = boost::filesystem::space(b_path, ec);
if (ec.failed())
{
LLSD args;
args["PATH"] = lastSnapshotDir;
@ -4789,7 +4800,6 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
failure_cb();
return;
}
boost::filesystem::space_info b_space = boost::filesystem::space(b_path);
if (b_space.free < image->getDataSize())
{
LLSD args;
@ -4806,6 +4816,8 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save
LLNotificationsUtil::add("SnapshotToComputerFailed", args);
failure_cb();
// Shouldn't there be a return here?
}
// Look for an unused file name