[libcamera-devel] [PATCH 2/2] libcamera: file: Check files exist()
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Dec 22 16:57:27 CET 2020
Hi Kieran,
Thank you for the patch.
On Tue, Dec 22, 2020 at 01:58:49PM +0000, Kieran Bingham wrote:
> Ensure that when we check for existence with File() it will only
> return if the path leads to a file, and not a directory.
>
> Device nodes which could still be opened by this class are still supported.
Sometimes I wonder if text editors also have their moments of
inattention and forget to wrap some lines :-)
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> src/libcamera/file.cpp | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/file.cpp b/src/libcamera/file.cpp
> index 3a3f5bb63ffc..bce2b6138239 100644
> --- a/src/libcamera/file.cpp
> +++ b/src/libcamera/file.cpp
> @@ -458,7 +458,8 @@ bool File::exists(const std::string &name)
> if (ret < 0)
> return false;
>
> - return true;
> + /* Directories can not be handled here, even if they exist. */
> + return !S_ISDIR(st.st_mode);
I initially thought that we would still return true for a symlink
pointing to a directory, but stat() dereferences symlinks, so I think
we're good.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> }
>
> } /* namespace libcamera */
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list