Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / recovery / step_create_recovery_file.cc
index 51d89c3..f2e139c 100644 (file)
@@ -2,9 +2,7 @@
 // Use of this source code is governed by a apache 2.0 license that can be
 // found in the LICENSE file.
 
-#include "step_create_recovery_file.h"
-
-#include <boost/filesystem/path.hpp>
+#include "common/step/recovery/step_create_recovery_file.h"
 
 #include <pkgmgr-info.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <tzplatform_config.h>
 
+#include <filesystem>
 #include <memory>
 #include <string>
 #include <utility>
 
-#include "common/pkgmgr_query.h"
-#include "common/request.h"
+#include "common/utils/pkgmgr_query.h"
 #include "common/utils/file_util.h"
 #include "common/utils/user_util.h"
+#include "common/utils/request.h"
 #include "common/recovery_file.h"
 
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace common_installer {
-namespace configuration {
+namespace recovery {
 
 Step::Status StepCreateRecoveryFile::process() {
-  std::string recovery_filename = context_->pkg_type.get() + "-recovery";
-  bf::path recovery_filepath = GenerateTemporaryPath(
-      context_->root_application_path.get() / recovery_filename);
+  fs::path recovery_filename = context_->recovery_info.get().filepath;
+
+  if (recovery_filename.empty()) {
+    std::string file_format = context_->pkg_type.get() + "-recovery";
+    recovery_filename = GenerateTemporaryPath(
+        context_->root_application_path.get() / file_format);
+  }
+
   auto recovery_file =
-      recovery::RecoveryFile::CreateRecoveryFile(recovery_filepath,
-          context_->request_type.get());
+    recovery::RecoveryFile::CreateRecoveryFile(recovery_filename,
+        context_->request_type.get());
   if (!recovery_file) {
     LOG(ERROR) << "Failed to create recovery file";
     return Status::CONFIG_ERROR;
   }
-  context_->recovery_info.set(RecoveryInfo(std::move(recovery_file)));
+
+  if (context_->recovery_info.get().filepath.empty())
+    context_->recovery_info.set(RecoveryInfo(std::move(recovery_file)));
+  else
+    context_->recovery_info.get().recovery_file = std::move(recovery_file);
 
   return Status::OK;
 }
@@ -63,5 +71,5 @@ Step::Status StepCreateRecoveryFile::clean() {
 }
 
 
-}  // namespace configuration
+}  // namespace recovery
 }  // namespace common_installer