Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / security / step_register_trust_anchor.cc
index c9986e6..06a2b54 100644 (file)
@@ -5,8 +5,8 @@
 #include "common/step/security/step_register_trust_anchor.h"
 
 #include <trust-anchor.h>
-#include <boost/filesystem.hpp>
 
+#include <filesystem>
 #include <string>
 
 #include "common/utils/file_util.h"
@@ -14,7 +14,7 @@
 namespace common_installer {
 namespace security {
 
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace {
 
@@ -22,12 +22,12 @@ const char kTpkTrustAnchorPath[] = "res/.trust-anchor";
 const char kWgtTrustAnchorPath[] = ".trust-anchor";
 const char kWgt[] = "wgt";
 
-bool RemoveWgtTrustAnchorSymLinks(const bf::path& path) {
-  for (bf::directory_iterator file(path);
-      file != bf::directory_iterator(); ++file) {
-    bf::path current(file->path());
-    if (bf::is_symlink(symlink_status(current)) &&
-      !bf::remove(current))
+bool RemoveWgtTrustAnchorSymLinks(const fs::path& path) {
+  for (fs::directory_iterator file(path);
+      file != fs::directory_iterator(); ++file) {
+    fs::path current(file->path());
+    if (fs::is_symlink(symlink_status(current)) &&
+      !fs::remove(current))
         return false;
   }
   return true;
@@ -57,7 +57,7 @@ Step::Status StepRegisterTrustAnchor::precheck() {
 
 Step::Status StepRegisterTrustAnchor::process() {
   int ret;
-  bf::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
+  fs::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
   manifest_x* manifest = context_->manifest_data.get();
 
   if (register_type_ == RegisterType::UPDATE) {
@@ -70,7 +70,7 @@ Step::Status StepRegisterTrustAnchor::process() {
 
     if (!context_->partial_rw.get() &&
         !context_->pkg_type.get().compare(kWgt)) {
-      if (bf::exists(pkg_certs_path) &&
+      if (fs::exists(pkg_certs_path) &&
           !RemoveWgtTrustAnchorSymLinks(pkg_certs_path))
         return Step::Status::APP_DIR_ERROR;
     }
@@ -89,14 +89,14 @@ Step::Status StepRegisterTrustAnchor::process() {
     if (!common_installer::CreateDir(pkg_certs_path))
       return Step::Status::APP_DIR_ERROR;
 
-    bf::path pkg_certs_src_path =
+    fs::path pkg_certs_src_path =
         context_->GetPkgPath() / "res/wgt" / kWgtTrustAnchorPath;
-    for (bf::directory_iterator file(pkg_certs_src_path);
-        file != bf::directory_iterator(); ++file) {
-      bf::path current(file->path());
+    for (fs::directory_iterator file(pkg_certs_src_path);
+        file != fs::directory_iterator(); ++file) {
+      fs::path current(file->path());
       try {
-        bf::create_symlink(current, pkg_certs_path / current.filename());
-      } catch (const bf::filesystem_error& error) {
+        fs::create_symlink(current, pkg_certs_path / current.filename());
+      } catch (const fs::filesystem_error& error) {
         LOG(ERROR) << "Failed to make trust anchor symlink : " << error.what();
         return Step::Status::APP_DIR_ERROR;
       }
@@ -104,7 +104,7 @@ Step::Status StepRegisterTrustAnchor::process() {
   }
 
   ret = trust_anchor_install(context_->pkgid.get().c_str(),
-      context_->uid.get(), pkg_certs_path.string().c_str(),
+      context_->uid.get(), pkg_certs_path.c_str(),
       (strcasecmp(manifest->use_system_certs, "true") == 0) ? true : false);
 
   if (ret != TRUST_ANCHOR_ERROR_NONE) {