Rework step/ directory structure
[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 <boost/filesystem/path.hpp>
9
10 #include <manifest_parser/utils/logging.h>
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   bool CleanBackupDirectory();
59   bool RollbackApplicationDirectory();
60
61   boost::filesystem::path install_path_;
62   boost::filesystem::path backup_path_;
63
64   SCOPE_LOG_TAG(CopyBackup)
65 };
66
67 }  // namespace backup
68 }  // namespace common_installer
69
70 #endif  // COMMON_STEP_BACKUP_STEP_COPY_BACKUP_H_