Skip to content

Commit

Permalink
remove catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk committed Mar 22, 2024
1 parent 1c16bba commit 5e166b8
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions application/F3DColorMapTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,40 @@ std::string Find(const std::string& str)
}
}

fs::path cmPath;
try
{
std::vector<fs::path> dirsToCheck;
dirsToCheck.emplace_back(F3DConfigFileTools::GetUserConfigFileDirectory() / "colormaps");
std::vector<fs::path> dirsToCheck;
dirsToCheck.emplace_back(F3DConfigFileTools::GetUserConfigFileDirectory() / "colormaps");
#ifdef __APPLE__
dirsToCheck.emplace_back("/usr/local/etc/f3d/colormaps");
dirsToCheck.emplace_back("/usr/local/etc/f3d/colormaps");
#endif
#ifdef __linux__
dirsToCheck.emplace_back("/etc/f3d/colormaps");
dirsToCheck.emplace_back("/usr/share/f3d/colormaps");
dirsToCheck.emplace_back("/etc/f3d/colormaps");
dirsToCheck.emplace_back("/usr/share/f3d/colormaps");
#endif
dirsToCheck.emplace_back(F3DConfigFileTools::GetBinaryConfigFileDirectory() / "colormaps");
dirsToCheck.emplace_back(F3DConfigFileTools::GetBinaryConfigFileDirectory() / "colormaps");

for (const fs::path& dir : dirsToCheck)
for (const fs::path& dir : dirsToCheck)
{
// If the string is a stem, try adding supported extensions
if (fs::path(str).stem() == str)
{
// If the string is a stem, try adding supported extensions
if (fs::path(str).stem() == str)
for (const std::string& ext : f3d::image::getSupportedFormats())
{
for (const std::string& ext : f3d::image::getSupportedFormats())
fs::path cmPath = dir / (str + ext);
if (fs::exists(cmPath))
{
cmPath = dir / (str + ext);
if (fs::exists(cmPath))
{
return cmPath.string();
}
return cmPath.string();
}
}
else
{
// If not, use directly
cmPath = dir / str;
}

}
else
{
// If not, use directly
fs::path cmPath = dir / str;
if (fs::exists(cmPath))
{
return cmPath.string();
}
}

return {};
}
catch (const fs::filesystem_error&)
{
f3d::log::error("Error recovering color map file path: ", str);
return {};
}

return {};
Expand Down

0 comments on commit 5e166b8

Please sign in to comment.