Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / filesystem / step_copy_tep.cc
index 0f3e0c5..a9fb3a3 100644 (file)
@@ -7,16 +7,17 @@
 
 #include <cassert>
 #include <cstring>
+#include <filesystem>
 #include <string>
+#include <system_error>
 
-#include "common/backup_paths.h"
+#include "common/utils/paths.h"
 #include "common/utils/file_util.h"
 
 namespace common_installer {
 namespace filesystem {
 
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
 
 Step::Status StepCopyTep::precheck() {
   if (context_->root_application_path.get().empty()) {
@@ -24,7 +25,7 @@ Step::Status StepCopyTep::precheck() {
     return Step::Status::INVALID_VALUE;
   }
 
-  if (!boost::filesystem::exists(context_->root_application_path.get())) {
+  if (!std::filesystem::exists(context_->root_application_path.get())) {
     LOG(ERROR) << "root_application_path ("
                << context_->root_application_path.get()
                << ") path does not exist";
@@ -42,25 +43,21 @@ Step::Status StepCopyTep::precheck() {
 Step::Status StepCopyTep::process() {
   if (context_->tep_path.get().empty())
     return Step::Status::OK;
-
-  context_->pkg_path.set(
-    context_->root_application_path.get() / context_->pkgid.get());
-
-  bf::path tep_path;
+  fs::path tep_path;
   if (context_->external_storage) {
     tep_path = GetExternalTepPath(context_->request_mode.get(),
                                   context_->uid.get());
   } else {
-    tep_path = GetInternalTepPath(context_->pkg_path.get());
+    tep_path = GetInternalTepPath(context_->GetPkgPath());
   }
 
   // Keep filename of app store supplied file. Filename contains hash that
   // appstore uses to identify version of tep on device.
   tep_path /= context_->tep_path.get().filename();
 
-  if (!bf::exists(tep_path.parent_path())) {
-    bs::error_code error;
-    bf::create_directory(tep_path.parent_path(), error);
+  if (!fs::exists(tep_path.parent_path())) {
+    std::error_code error;
+    fs::create_directories(tep_path.parent_path(), error);
     if (error) {
       LOG(ERROR) << "Cannot create tep parent directory";
       return Status::APP_DIR_ERROR;
@@ -87,19 +84,13 @@ Step::Status StepCopyTep::process() {
 }
 
 Step::Status StepCopyTep::undo() {
-  bs::error_code error;
-  if (bf::exists(context_->tep_path.get())) {
-    bf::remove_all(context_->tep_path.get(), error);
-  }
-
+  RemoveAll(context_->tep_path.get());
   // remove tep file is installed outside package path
   if (context_->external_storage) {
-    bf::path tep_path = GetExternalTepPath(context_->request_mode.get(),
+    fs::path tep_path = GetExternalTepPath(context_->request_mode.get(),
                                            context_->uid.get());
     tep_path /= context_->tep_path.get().filename();
-    if (bf::exists(tep_path)) {
-      bf::remove_all(tep_path, error);
-    }
+    RemoveAll(tep_path);
   }
   return Status::OK;
 }