From 1d0dbc0da83968d9b2f21b9552151ca28fd392e5 Mon Sep 17 00:00:00 2001 From: Hirokazu Honda Date: Thu, 10 Jun 2021 16:50:18 +0900 Subject: libcamera: base: file_descriptor: Add constructor from UniqueFD Add a FileDescriptor constructor that takes a UniqueFD, transfering ownership of the file descriptor to the FileDescriptor. Signed-off-by: Hirokazu Honda Signed-off-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- src/libcamera/base/file_descriptor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/libcamera/base/file_descriptor.cpp b/src/libcamera/base/file_descriptor.cpp index 98d4b4bf..da696b25 100644 --- a/src/libcamera/base/file_descriptor.cpp +++ b/src/libcamera/base/file_descriptor.cpp @@ -13,6 +13,7 @@ #include #include +#include /** * \file base/file_descriptor.h @@ -109,6 +110,18 @@ FileDescriptor::FileDescriptor(int &&fd) fd = -1; } +/** + * \brief Create a FileDescriptor taking ownership of a given UniqueFD \a fd + * \param[in] fd UniqueFD + * + * Construct a FileDescriptor from UniqueFD by taking ownership of the \a fd. + * The original \a fd becomes invalid. + */ +FileDescriptor::FileDescriptor(UniqueFD fd) + : FileDescriptor(fd.release()) +{ +} + /** * \brief Copy constructor, create a FileDescriptor from a copy of \a other * \param[in] other The other FileDescriptor -- cgit v1.2.1