From 0a823785fad27e1eb9a900e80923bc9bde106de9 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Mon, 30 Nov 2020 23:25:40 +0000 Subject: libcamera: file: Check files exist() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Signed-off-by: Kieran Bingham --- src/libcamera/file.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libcamera/file.cpp') diff --git a/src/libcamera/file.cpp b/src/libcamera/file.cpp index 3a3f5bb6..bce2b613 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 */ -- cgit v1.2.1