[libcamera-devel] [PATCH 2/2] libcamera: file: Check files exist()
Kieran Bingham
kieran.bingham at ideasonboard.com
Tue Dec 22 14:58:49 CET 2020
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>
---
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
More information about the libcamera-devel
mailing list