Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / filesystem / step_move_installed_storage.cc
index f61b1dd..257b5d9 100644 (file)
@@ -4,12 +4,12 @@
 
 #include "common/step/filesystem/step_move_installed_storage.h"
 
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
 #include <tzplatform_config.h>
 
-#include <string>
 #include <cstring>
+#include <filesystem>
+#include <string>
+#include <system_error>
 
 #include "common/external_storage.h"
 #include "common/shared_dirs.h"
 #include "common/pkgmgr_registration.h"
 #include "common/utils/pkgmgr_query.h"
 
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
 
 namespace {
 
 const char kInternalOnly[] = "internal-only";
 
-bool MoveFileAndUpdateTepInfo(const boost::filesystem::path& src,
-    const boost::filesystem::path& dst,
+bool MoveFileAndUpdateTepInfo(const std::filesystem::path& src,
+    const std::filesystem::path& dst,
     const common_installer::InstallerContext* context) {
-  if (!bf::exists(src))
+  if (!fs::exists(src))
     return true;
 
   if (!common_installer::MoveFile(src, dst)) {
@@ -121,9 +120,9 @@ void StepMoveInstalledStorage::SetTepPaths() {
 }
 
 bool StepMoveInstalledStorage::MoveTep() {
-  if (!bf::exists(new_tep_location_.parent_path())) {
-    bs::error_code error;
-    bf::create_directory(new_tep_location_.parent_path(), error);
+  if (!fs::exists(new_tep_location_.parent_path())) {
+    std::error_code error;
+    fs::create_directory(new_tep_location_.parent_path(), error);
     if (error) {
       LOG(ERROR) << "Failed to destination path for new tep location";
       return false;
@@ -171,13 +170,13 @@ bool StepMoveInstalledStorage::MoveBackExternal() {
 bool StepMoveInstalledStorage::MoveExtended() {
   if (move_type_ == MoveType::TO_EXTENDED) {
     old_pkg_location_ = context_->GetPkgPath();
-    new_pkg_location_ = bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+    new_pkg_location_ = fs::path(GetExtendedRootAppPath(context_->uid.get())) /
         context_->pkgid.get();
     context_->storage.set(Storage::EXTENDED);
   } else {
-    old_pkg_location_ = bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+    old_pkg_location_ = fs::path(GetExtendedRootAppPath(context_->uid.get())) /
         context_->pkgid.get();
-    new_pkg_location_ = bf::path(GetRootAppPath(
+    new_pkg_location_ = fs::path(GetRootAppPath(
         context_->is_readonly_package.get(), context_->uid.get())) /
         context_->pkgid.get();
     context_->storage.set(Storage::INTERNAL);
@@ -194,8 +193,8 @@ bool StepMoveInstalledStorage::MoveExtended() {
 
   // create symlink for extended path
   if (move_type_ == MoveType::TO_EXTENDED) {
-    bs::error_code error;
-    bf::create_symlink(new_pkg_location_, old_pkg_location_, error);
+    std::error_code error;
+    fs::create_symlink(new_pkg_location_, old_pkg_location_, error);
     if (error) {
       LOG(ERROR) << "Failed to create symlink for extended path: "
                  << error.message();
@@ -217,8 +216,8 @@ bool StepMoveInstalledStorage::MoveExtended() {
 bool StepMoveInstalledStorage::MoveBackExtended() {
   if (move_type_ == MoveType::TO_EXTENDED) {
     // Remove symlink if exist
-    if (bf::exists(old_pkg_location_) &&
-        bf::is_symlink(symlink_status(old_pkg_location_))) {
+    if (fs::exists(old_pkg_location_) &&
+        fs::is_symlink(symlink_status(old_pkg_location_))) {
       if (!Remove(old_pkg_location_)) {
         LOG(ERROR) << "Failed to remove symlink for extended path";
         return false;
@@ -227,8 +226,8 @@ bool StepMoveInstalledStorage::MoveBackExtended() {
   }
   MoveDir(new_pkg_location_, old_pkg_location_);
   if (move_type_ == MoveType::TO_INTERNAL) {
-    bs::error_code error;
-    bf::create_symlink(old_pkg_location_, new_pkg_location_, error);
+    std::error_code error;
+    fs::create_symlink(old_pkg_location_, new_pkg_location_, error);
     if (error) {
       LOG(ERROR) << "Failed to create symlink for extended path: "
                  << error.message();
@@ -247,4 +246,3 @@ bool StepMoveInstalledStorage::MoveBackExtended() {
 
 }  // namespace filesystem
 }  // namespace common_installer
-