1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #ifndef COMMON_RECOVERY_FILE_H_
6 #define COMMON_RECOVERY_FILE_H_
8 #include <boost/filesystem/path.hpp>
14 #include "common/utils/request.h"
16 namespace common_installer {
21 * Responsible for managing recovery file.
23 * It dumps information to recover file regarding current status of handled
29 * Creates new RecoveryFile object for given file
31 * \param path path to the package/id
33 * \return new RecoveryFile object
35 static std::unique_ptr<RecoveryFile> CreateRecoveryFile(
36 const boost::filesystem::path& path, RequestType type);
39 * Opens RecoveryFile object for given request
41 * \param path path to the package/id
43 * \return new RecoveryFile object
45 static std::unique_ptr<RecoveryFile> OpenRecoveryFile(
46 const boost::filesystem::path& path);
51 /** Detaching object from given recovery file */
55 * Checks if object is detached from file
57 * \return true if detached
60 bool is_detached() const;
63 * setter for unpacked dir
65 * \param unpacked_dir new unpacked_dir value
67 void set_unpacked_dir(boost::filesystem::path unpacked_dir);
72 * \param pkgid new pkgid value
74 void set_pkgid(std::string pkgid);
77 * setter for backup done
79 * \param backup_done boolean value of backup_done
81 void set_backup_done(bool backup_done);
84 * setter for cleanup flag
86 * \param cleanup boolean value of cleanup
88 void set_cleanup(bool cleanup);
91 * getter for unpacked dir
93 * \return current unpacked_dir
95 const boost::filesystem::path& unpacked_dir() const;
100 * * \return current pkgid
102 const std::string& pkgid() const;
105 * getter for request type
107 * \return current request type
109 RequestType type() const;
112 * getter for backup exist flag
114 * \return true if backup does exist
116 bool backup_done() const;
119 * getter for cleanup flag
121 * \return true if cleanup flag has set
123 bool cleanup() const;
126 * Transaction of current RecoveryFile content into recovery file
128 * \return true if success
130 bool WriteAndCommitFileContent();
133 RecoveryFile(const boost::filesystem::path& path, RequestType type,
136 bool ReadFileContent();
139 boost::filesystem::path unpacked_dir_;
142 boost::filesystem::path path_;
143 boost::filesystem::path backup_path_;
148 } // namespace recovery
149 } // namespace common_installer
151 #endif // COMMON_RECOVERY_FILE_H_