Fixed svace (376818, 386676, 386690)
[platform/core/dotnet/launcher.git] / NativeLauncher / installer-plugin / prefer_dotnet_aot_plugin.cc
index 470468e..91204f5 100644 (file)
@@ -77,27 +77,32 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
                                _ERR("Failed to get UID");
                                return 0;
                        }
-                       for (auto& symlinkAssembly : bf::recursive_directory_iterator(tacDir)) {
-                               std::string symPath = symlinkAssembly.path().string();
-                               if (!isNativeImage(symPath)) {
-                                       std::string originPath = bf::read_symlink(symPath).string();
-                                       std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
-                                       if (!bf::exists(originNiPath)) {
-                                               if(createNiDll(originPath, false) != NI_ERROR_NONE) {
-                                                       _ERR("Failed to create NI file [%s]", originPath.c_str());
-                                                       return -1;
+                       try {
+                               for (auto& symlinkAssembly : bf::recursive_directory_iterator(tacDir)) {
+                                       std::string symPath = symlinkAssembly.path().string();
+                                       if (!isNativeImage(symPath)) {
+                                               std::string originPath = bf::read_symlink(symPath).string();
+                                               std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
+                                               if (!bf::exists(originNiPath)) {
+                                                       if(createNiDll(originPath, false) != NI_ERROR_NONE) {
+                                                               _ERR("Failed to create NI file [%s]", originPath.c_str());
+                                                               return -1;
+                                                       }
                                                }
-                                       }
-                                       std::string setNiPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
-                                       if (!bf::exists(setNiPath)) {
-                                               bf::create_symlink(originNiPath, setNiPath);
-                                               _INFO("%s symbolic link file generated successfully.", setNiPath.c_str());
-                                               if (lchown(setNiPath.c_str(), uid, 0)) {
-                                                       _ERR("Failed to change owner of: %s", setNiPath.c_str());
-                                                       return -1;
+                                               std::string setNiPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
+                                               if (!bf::exists(setNiPath)) {
+                                                       bf::create_symlink(originNiPath, setNiPath);
+                                                       _INFO("%s symbolic link file generated successfully.", setNiPath.c_str());
+                                                       if (lchown(setNiPath.c_str(), uid, 0)) {
+                                                               _ERR("Failed to change owner of: %s", setNiPath.c_str());
+                                                               return -1;
+                                                       }
                                                }
                                        }
                                }
+                       } catch (const bf::filesystem_error& error) {
+                               _ERR("Failed to recursive directory: %s", error.what());
+                               return -1;
                        }
                }
        }