Fix the core dump by using filesystem error_code

The currently used filesystem method will cause an exception if the
file system is damaged for some reason, resulting in a core dump of
the process.
So the overloaded method with the error_code parameter should be used
here to ensure that the process core dump will not be caused after an
exception is thrown.

Fixes: openbmc/phosphor-bmc-code-mgmt#12

Tested: built phosphor-bmc-code-mgmt successfully and CI passes.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I329f78b481cb466e755bc1b78562583620f561c2
diff --git a/sync_manager.cpp b/sync_manager.cpp
index 1a3e0dd..caafae0 100644
--- a/sync_manager.cpp
+++ b/sync_manager.cpp
@@ -9,6 +9,7 @@
 #include <phosphor-logging/lg2.hpp>
 
 #include <filesystem>
+#include <system_error>
 
 namespace phosphor
 {
@@ -34,18 +35,19 @@
         // so need to differentiate between the different file events.
         if (mask & IN_CLOSE_WRITE)
         {
-            if (!(fs::exists(dst)))
+            std::error_code ec;
+            if (!(fs::exists(dst, ec)))
             {
-                if (fs::is_directory(entryPath))
+                if (fs::is_directory(entryPath, ec))
                 {
                     // Source is a directory, create it at the destination.
-                    fs::create_directories(dst);
+                    fs::create_directories(dst, ec);
                 }
                 else
                 {
                     // Source is a file, create the directory where this file
                     // resides at the destination.
-                    fs::create_directories(dst.parent_path());
+                    fs::create_directories(dst.parent_path(), ec);
                 }
             }