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 #include "common/step/filesystem/step_remove_temporary_directory.h"
6 #include <boost/filesystem.hpp>
7 #include <boost/system/error_code.hpp>
9 #include "common/installer_context.h"
10 #include "common/utils/file_util.h"
12 namespace common_installer {
13 namespace filesystem {
15 namespace bf = boost::filesystem;
17 Step::Status StepRemoveTemporaryDirectory::RecoveryUpdate() {
21 Step::Status StepRemoveTemporaryDirectory::RecoveryNew() {
25 Step::Status StepRemoveTemporaryDirectory::Cleanup() {
29 Step::Status StepRemoveTemporaryDirectory::RemoveFiles() {
30 bf::path unpack_dir_path = context_->unpacked_dir_path.get();
31 bf::path patch_dir_path = unpack_dir_path;
32 bf::path mount_dir_path = unpack_dir_path;
33 bf::path shared_res_backup_dir_path = unpack_dir_path;
34 patch_dir_path += ".patch";
35 mount_dir_path += ".bck";
36 shared_res_backup_dir_path += ".SharedRes";
37 if (unpack_dir_path.empty())
38 return Step::Status::OK;
39 if (!ClearPath(unpack_dir_path) ||
40 !ClearPath(patch_dir_path) ||
41 !ClearPath(mount_dir_path) ||
42 !ClearPath(shared_res_backup_dir_path))
43 return Step::Status::RECOVERY_ERROR;
44 return Step::Status::OK;
47 bool StepRemoveTemporaryDirectory::ClearPath(const bf::path& path) {
48 return RemoveAll(path);
51 } // namespace filesystem
52 } // namespace common_installer