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"
8 #include "common/installer_context.h"
9 #include "common/utils/file_util.h"
11 namespace common_installer {
12 namespace filesystem {
14 namespace fs = std::filesystem;
16 Step::Status StepRemoveTemporaryDirectory::RecoveryUpdate() {
20 Step::Status StepRemoveTemporaryDirectory::RecoveryNew() {
24 Step::Status StepRemoveTemporaryDirectory::Cleanup() {
28 Step::Status StepRemoveTemporaryDirectory::RemoveFiles() {
29 fs::path unpack_dir_path = context_->unpacked_dir_path.get();
30 fs::path patch_dir_path = unpack_dir_path;
31 fs::path mount_dir_path = unpack_dir_path;
32 fs::path shared_res_backup_dir_path = unpack_dir_path;
33 patch_dir_path += ".patch";
34 mount_dir_path += ".bck";
35 shared_res_backup_dir_path += ".SharedRes";
36 if (unpack_dir_path.empty())
37 return Step::Status::OK;
38 if (!ClearPath(unpack_dir_path) ||
39 !ClearPath(patch_dir_path) ||
40 !ClearPath(mount_dir_path) ||
41 !ClearPath(shared_res_backup_dir_path))
42 return Step::Status::RECOVERY_ERROR;
43 return Step::Status::OK;
46 bool StepRemoveTemporaryDirectory::ClearPath(const fs::path& path) {
47 return RemoveAll(path);
50 } // namespace filesystem
51 } // namespace common_installer