summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2020-11-30 23:25:40 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2020-12-30 13:03:55 +0000
commit0a823785fad27e1eb9a900e80923bc9bde106de9 (patch)
treeefeeba45de3f6c8758dd9420fc451d19f60f735a
parent8f4e16f014c820a0ecb85e28453b88c277bc859f (diff)
libcamera: file: Check files exist()
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/libcamera/file.cpp3
1 files changed, 2 insertions, 1 deletions
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 */