Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / backup / step_copy_backup.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_BACKUP_STEP_COPY_BACKUP_H_
6 #define COMMON_STEP_BACKUP_STEP_COPY_BACKUP_H_
7
8 #include <manifest_parser/utils/logging.h>
9
10 #include <filesystem>
11
12 #include "common/installer_context.h"
13 #include "common/step/step.h"
14
15 namespace common_installer {
16 namespace backup {
17
18 /**
19  * \brief Responsible for backuping original package resources during
20  *        update or uninstallation and copying new content of the package.
21  *        Used by WGT and TPK backend
22  */
23 class StepCopyBackup : public Step {
24  public:
25   using Step::Step;
26
27   /**
28    * \brief main logic of creating backup and copying new content
29    *
30    * \return Status::OK
31    */
32   Status process() override;
33
34   /**
35    * \brief removing backup files
36    *
37    * \return Status::OK if success, Status::ERROR otherwise
38    */
39   Status clean() override;
40
41   /**
42    * \brief Restoring original pacakge files
43    *
44    * \return Status::OK if success, Status::Error otherwise
45    */
46   Status undo() override;
47
48   /**
49    * \brief checks if necessary paths are available
50    *
51    * \return Status::OK if success, Status::Error otherwise
52    */
53   Status precheck() override;
54
55  private:
56   bool Backup();
57   bool NewContent();
58   void RemoveContent();
59   bool CleanBackupDirectory();
60   bool RollbackApplicationDirectory();
61   bool MoveMountPointContent(const std::filesystem::path& from,
62                    const std::filesystem::path& to);
63   void AddRecoveryInfo();
64   bool ShouldBackupSharedRes();
65
66   std::filesystem::path install_path_;
67   std::filesystem::path backup_path_;
68
69   STEP_NAME(CopyBackup)
70 };
71
72 }  // namespace backup
73 }  // namespace common_installer
74
75 #endif  // COMMON_STEP_BACKUP_STEP_COPY_BACKUP_H_