[libcamera-devel] [PATCH 2/2] libcamera: file: Check files exist()

Niklas Söderlund niklas.soderlund at ragnatech.se
Sun Dec 27 11:54:05 CET 2020


Hi Kieran,

On 2020-12-22 13:58:49 +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.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

With the long line already pointed out fixed,

Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>

> ---
>  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);
>  }
>  
>  } /* namespace libcamera */
> -- 
> 2.25.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list