alicevision / AliceVision

Photogrammetric Computer Vision Framework
http://alicevision.org
Other
2.89k stars 806 forks source link

Catch error codes thrown by `std::filesystem::exists` #1687

Closed cbentejac closed 3 months ago

cbentejac commented 3 months ago

Description

This PR mirrors what has been done in QtAliceVision in alicevision/QtAliceVision#70 and catches the error code thrown by std::filesystem::exists to ensure that there is no unhandled thrown exception (for example if a file exists but the user does not have the correct access rights) that might cause the program to crash.

Additionally, some functions and variables were renamed to respect the camelBack case.

simogasp commented 3 months ago

Instead of cluttering the code with the parameter std::error that is never used, wouldn't it be better to make our wrapper of the std::filesystem::exists() function that does it? Like for example in aliceVision/src/system/ we can declare a function

namespace alicevision{
namespace system{
bool exists( const std::filesystem::path& p )
{
    std::error ec;
    return std::filesystem::exists(p, ec);
}
fabiencastan commented 3 months ago

with inline and noexcept

simogasp commented 3 months ago

and [[nodiscard]]