Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / filesystem / step_copy.cc
index b90c6c0..9e92a4e 100644 (file)
@@ -7,14 +7,15 @@
 
 #include <cassert>
 #include <cstring>
+#include <filesystem>
 #include <string>
+#include <system_error>
 
 #include "common/shared_dirs.h"
 #include "common/utils/file_util.h"
 
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
 namespace ci = common_installer;
+namespace fs = std::filesystem;
 
 namespace common_installer {
 namespace filesystem {
@@ -24,7 +25,7 @@ Step::Status StepCopy::precheck() {
     LOG(ERROR) << "root_application_path attribute is empty";
     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";
@@ -35,7 +36,7 @@ Step::Status StepCopy::precheck() {
     LOG(ERROR) << "unpacked_dir_path attribute is empty";
     return Step::Status::INVALID_VALUE;
   }
-  if (!boost::filesystem::exists(context_->unpacked_dir_path.get())) {
+  if (!std::filesystem::exists(context_->unpacked_dir_path.get())) {
     LOG(ERROR) << "unpacked_dir_path ("
                << context_->unpacked_dir_path.get()
                << ") path does not exist";
@@ -56,9 +57,9 @@ Step::Status StepCopy::precheck() {
 }
 
 Step::Status StepCopy::process() {
-  bf::path install_path;
+  fs::path install_path;
   if (context_->storage.get() == Storage::EXTENDED) {
-    install_path = bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+    install_path = fs::path(GetExtendedRootAppPath(context_->uid.get())) /
         context_->pkgid.get();
   } else {
     install_path = context_->GetPkgPath();
@@ -66,8 +67,8 @@ Step::Status StepCopy::process() {
 
   ci::RemoveRWDirectories(context_->unpacked_dir_path.get());
 
-  bs::error_code error;
-  bf::create_directories(install_path.parent_path(), error);
+  std::error_code error;
+  fs::create_directories(install_path.parent_path(), error);
   if (error) {
     LOG(ERROR) << "Cannot create directory: "
                << install_path.parent_path().string();
@@ -83,7 +84,7 @@ Step::Status StepCopy::process() {
             << " to: " << install_path << " directory";
 
   if (context_->storage.get() == Storage::EXTENDED) {
-    bf::create_symlink(install_path, context_->GetPkgPath(), error);
+    fs::create_symlink(install_path, context_->GetPkgPath(), error);
     if (error) {
       LOG(ERROR) << "Failed to create symlink for extended path: "
                  << error.message();
@@ -102,8 +103,8 @@ Step::Status StepCopy::undo() {
   if (context_->external_storage) {
     context_->external_storage->Abort();
   } else if (context_->storage.get() == Storage::EXTENDED) {
-    bf::path install_path =
-        bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+    fs::path install_path =
+        fs::path(GetExtendedRootAppPath(context_->uid.get())) /
             context_->pkgid.get();
     RemoveAll(install_path);
   }