Fix Util::PrepareAppSocket() method 87/317487/3
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 11 Sep 2024 02:34:39 +0000 (11:34 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 11 Sep 2024 03:10:03 +0000 (12:10 +0900)
To avoid throwing the exception, this patch uses the following method:
- bool create_directory( const std::filesystem::path& p,
                         std::error_code& ec ) noexcept;

Change-Id: I2df244b430181c7c9736c87f7a4ab999ecf47d03
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/launchpad-glib/util.cc

index 3545bf8e3885280f5184636db3692efee3bdeade..90dfd40b245ca731917d8ed628930cf90eb1af20 100644 (file)
@@ -575,8 +575,14 @@ int Util::PrepareAppSocket() {
   try {
     std::string path = "/run/aul/apps/" + std::to_string(getuid()) + "/" +
         std::to_string(getpid());
-    if (access(path.c_str(), F_OK) != 0)
-      fs::create_directory(path);
+    if (access(path.c_str(), F_OK) != 0) {
+      std::error_code ec;
+      if (!fs::create_directory(path, ec)) {
+        _E("Failed to create directory. path=%s, error_code=%d(%s)",
+            path.c_str(), ec.value(), ec.message().c_str());
+        return -1;
+      }
+    }
 
     path += "/.app-sock";
     ServerSocket socket;