Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / rds / step_rds_modify.h
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_STEP_RDS_STEP_RDS_MODIFY_H_
6 #define COMMON_STEP_RDS_STEP_RDS_MODIFY_H_
7
8 #include <common/step/step.h>
9
10 #include <filesystem>
11 #include <string>
12 #include <utility>
13 #include <vector>
14
15 #include "common/installer_context.h"
16
17 namespace common_installer {
18 namespace rds {
19
20 /**
21  * \brief Step that apply RDS modification during reinstallation process
22  */
23 class StepRDSModify : public Step {
24  public:
25   /**
26    * \brief Explicit constructor
27    *
28    * \param context Installer context
29    */
30   explicit StepRDSModify(common_installer::InstallerContext* context);
31
32   /**
33    * \brief
34    *
35    * \return
36    */
37   Status process() override;
38
39   /**
40    * \brief Remove files from temporary location
41    *
42    * \return Status::OK
43    */
44   Status clean() override;
45
46   /**
47    * \brief Restore files to the state from before RDS installation
48    *
49    * \return Status::OK
50    */
51   Status undo() override;
52
53   /**
54    * \brief
55    *
56    * \return Status::ERROR when manifest is missing, pkgid is missing,
57    *         or when path to the unpacked directory is missing or not exist,
58    *         Status::OK otherwise
59    */
60   Status precheck() override;
61
62  private:
63   enum class Operation {
64     ADD,
65     MODIFY,
66     DELETE
67   };
68
69   bool AddFiles(std::filesystem::path unzip_path,
70                 std::filesystem::path install_path);
71   bool ModifyFiles(std::filesystem::path unzip_path,
72                    std::filesystem::path install_path);
73   bool DeleteFiles(std::filesystem::path install_path);
74   bool SetUpTempBackupDir();
75   void DeleteTempBackupDir();
76   bool PerformBackup(std::string relative_path, Operation operation);
77   void RestoreFiles();
78
79   std::vector<std::pair<std::string, Operation>> success_modifications_;
80   std::filesystem::path backup_temp_dir_;
81   std::vector<std::string> files_to_modify_;
82   std::vector<std::string> files_to_add_;
83   std::vector<std::string> files_to_delete_;
84
85   STEP_NAME(RDSModify)
86 };
87
88 }  // namespace rds
89 }  // namespace common_installer
90
91 #endif  // COMMON_STEP_RDS_STEP_RDS_MODIFY_H_