Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / filesystem / step_remove_files.cc
index 63d3c6c..77f1b90 100644 (file)
@@ -4,13 +4,11 @@
 
 #include "common/step/filesystem/step_remove_files.h"
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
-
 #include <sys/types.h>
 #include <tzplatform_config.h>
 
 #include <algorithm>
+#include <filesystem>
 #include <string>
 #include <vector>
 
 #include "common/utils/user_util.h"
 #include "common/shared_dirs.h"
 
-namespace bs = boost::system;
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace {
 
 const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
 const char kSubsesionDir[] = "subsession";
 
-bool SkipRWDirectories(const bf::path& path) {
+bool SkipRWDirectories(const fs::path& path) {
   static const std::vector<std::string> dirs_to_ignore = {
     {"cache"},
     {"data"},
@@ -40,7 +37,7 @@ bool SkipRWDirectories(const bf::path& path) {
 }
 
 bool RemoveSignature(const std::string& pkgid, bool is_readonly) {
-  bf::path signature_path = bf::path(is_readonly ?
+  fs::path signature_path = fs::path(is_readonly ?
       tzplatform_getenv(TZ_SYS_RO_SHARE) : tzplatform_getenv(TZ_SYS_SHARE)) /
           "signatures";
   signature_path /= std::string(pkgid + ".txt");
@@ -66,7 +63,7 @@ Step::Status StepRemoveFiles::precheck() {
   // to remove the files
   if (context_->GetPkgPath().empty())
     LOG(ERROR) << "pkg_path attribute is empty";
-  else if (!bf::exists(context_->GetPkgPath()))
+  else if (!fs::exists(context_->GetPkgPath()))
     LOG(ERROR) << "pkg_path ("
                << context_->GetPkgPath()
                << ") path does not exist";
@@ -89,7 +86,7 @@ Step::Status StepRemoveFiles::process() {
   }
 
   bool is_error = false;
-  std::vector<bf::path> root_paths;
+  std::vector<fs::path> root_paths;
   // Use RootAppPath + Pkgid because of ReadonlyUpdateUninstall
   root_paths.push_back(context_->root_application_path.get());
 
@@ -100,10 +97,10 @@ Step::Status StepRemoveFiles::process() {
   for (auto& root_path : root_paths) {
     if (is_keep_rwdata) {
       bool ret;
-      for (bf::directory_iterator itr(root_path / context_->pkgid.get());
-          itr != bf::directory_iterator(); ++itr) {
-        if (bf::is_directory(itr->status())) {
-          if (SkipRWDirectories(itr->path().leaf())) {
+      for (fs::directory_iterator itr(root_path / context_->pkgid.get());
+          itr != fs::directory_iterator(); ++itr) {
+        if (fs::is_directory(itr->status())) {
+          if (SkipRWDirectories(itr->path().filename())) {
             LOG(DEBUG) << "Skipping remove dir:" << itr->path().c_str();
             continue;
           }
@@ -127,8 +124,8 @@ Step::Status StepRemoveFiles::process() {
 
   // Remove package files at extended storage
   if (context_->storage.get() == Storage::EXTENDED) {
-    bf::path extended_path =
-        bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+    fs::path extended_path =
+        fs::path(GetExtendedRootAppPath(context_->uid.get())) /
             context_->pkgid.get();
     if (!RemoveAll(extended_path))
       return Status::APP_DIR_ERROR;
@@ -136,8 +133,8 @@ Step::Status StepRemoveFiles::process() {
 
   for (auto& lw_user : GetLightUserList(context_->uid.get())) {
     if (context_->storage.get() == Storage::EXTENDED) {
-      bf::path extended_path =
-          bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+      fs::path extended_path =
+          fs::path(GetExtendedRootAppPath(context_->uid.get())) /
           kSubsesionDir / lw_user / context_->pkgid.get();
       if (!RemoveAll(extended_path))
         return Status::APP_DIR_ERROR;