From patchwork Tue Dec 22 13:58:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10695 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0EAC1C0F1A for ; Tue, 22 Dec 2020 13:58:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 42A45615B0; Tue, 22 Dec 2020 14:58:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="n1+azX+g"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D6E6615AC for ; Tue, 22 Dec 2020 14:58:55 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B9B89122D; Tue, 22 Dec 2020 14:58:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1608645534; bh=R4Wh/zlrA6x3NiPzgk5P/f3VImanYz6p9nc32FLlknA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n1+azX+gvZQLN07jOhMLMfuQ1C+gqw+B16UeNwfUtiWJGK7zul8aI6pAcqGHV+O6R CUmC9+slT204qWGnFjmsC/h8dQqF1hVvqZUPQZbEvp1xxLzP/+7TU04o85BkCVYEy+ fi7EzXu5ksfoYhtoIcu53EMlDYs/cxuoE0cI0QVE= From: Kieran Bingham To: libcamera devel Date: Tue, 22 Dec 2020 13:58:49 +0000 Message-Id: <20201222135849.38052-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201222135849.38052-1-kieran.bingham@ideasonboard.com> References: <20201222135849.38052-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: file: Check files exist() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- 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 */