[libcamera-devel,v5,05/10] android: remove references to std::filesystem
diff mbox series

Message ID 20221028031726.4849-6-nicholas@rothemail.net
State Accepted
Headers show
Series
  • [libcamera-devel,v5,01/10] ipa: workaround libcxx duration limitation
Related show

Commit Message

Nicolas Dufresne via libcamera-devel Oct. 28, 2022, 3:17 a.m. UTC
From: Nicholas Roth <nicholas@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.

Signed-off-by: Nicholas Roth <nicholas@rothemail.net>
---
 src/android/camera_hal_config.cpp | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Kieran Bingham Oct. 28, 2022, 10:29 a.m. UTC | #1
Quoting Nicholas Roth via libcamera-devel (2022-10-28 04:17:21)
> From: Nicholas Roth <nicholas@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.
> 
> Signed-off-by: Nicholas Roth <nicholas@rothemail.net>

From Jacopo on an earlier version:

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

And from me:

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/android/camera_hal_config.cpp | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp
> index bacfe4b9..0e7cde63 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";
>                 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
>

Patch
diff mbox series

diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp
index bacfe4b9..0e7cde63 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";
 		return -ENOENT;
 	}
 
-	File file(filePath);
 	if (!file.open(File::OpenModeFlag::ReadOnly)) {
 		int ret = file.error();
 		LOG(HALConfig, Error) << "Failed to open configuration file "