[libcamera-devel] [PATCH 05/10] android: remove references to std::filesystem
Jacopo Mondi
jacopo at jmondi.org
Thu Oct 27 18:43:16 CEST 2022
On Thu, Oct 27, 2022 at 12:55:10AM -0500, Nicholas Roth via libcamera-devel wrote:
> From: Nicholas Roth <nicholas at rothemail.net>
>
> Android 11's toolchain does not support std::filesystem, but
> camera_hal_config.cpp currently uses it. Remove references to
> std::filesystem in order to support Android <= 11.
>
> This adds a very small difference in behaviour, as File::exist() will
> return true for special files (pipes, character or block devices, ...)
> while std::filesystem::is_regular_file() doesn't, but I consider this
> to be a corner case that doesn't matter much.
>
I think we can live with this, yes
> Signed-off-by: Nicholas Roth <nicholas at rothemail.net>
> ---
> src/android/camera_hal_config.cpp | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp
> index bacfe4b9..6fd71162 100644
> --- a/src/android/camera_hal_config.cpp
> +++ b/src/android/camera_hal_config.cpp
> @@ -6,7 +6,6 @@
> */
> #include "camera_hal_config.h"
>
> -#include <filesystem>
> #include <stdlib.h>
> #include <string>
>
> @@ -160,15 +159,15 @@ CameraHalConfig::CameraHalConfig()
> */
> int CameraHalConfig::parseConfigurationFile()
> {
> - std::filesystem::path filePath = LIBCAMERA_SYSCONF_DIR;
> - filePath /= "camera_hal.yaml";
> - if (!std::filesystem::is_regular_file(filePath)) {
> + std::string filePath = LIBCAMERA_SYSCONF_DIR "/camera_hal.yaml";
> +
> + File file(filePath);
> + if (!file.exists()) {
> LOG(HALConfig, Debug)
> - << "Configuration file: \"" << filePath << "\" not found";
> + << "Configuration file: \"" << filePath << "\" not found";
I would not change the indentation.
This apart:
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
I'm surprised this is the only place where we use std::filesystem!
> return -ENOENT;
> }
>
> - File file(filePath);
> if (!file.open(File::OpenModeFlag::ReadOnly)) {
> int ret = file.error();
> LOG(HALConfig, Error) << "Failed to open configuration file "
> --
> 2.34.1
>
More information about the libcamera-devel
mailing list