ef415d30a433ee1728cfac8075505ae33c905e5d
[platform/core/appfw/app-installers.git] / src / common / step / filesystem / step_remove_tep.cc
1 // Copyright (c) 2016 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.
4
5 #include "common/step/filesystem/step_remove_tep.h"
6
7 #include <boost/filesystem/operations.hpp>
8 #include <boost/filesystem/path.hpp>
9 #include <boost/system/error_code.hpp>
10
11 namespace bf = boost::filesystem;
12 namespace bs = boost::system;
13
14 namespace common_installer {
15 namespace filesystem {
16
17 Step::Status StepRemoveTep::process() {
18   if (context_->manifest_data.get()->tep_name) {
19     bf::path tep_path(context_->manifest_data.get()->tep_name);
20     if (bf::exists(tep_path)) {
21       bs::error_code error;
22       bf::remove(tep_path, error);
23       if (error) {
24         // Deinstallation should not fail even if sd card is not inserted
25         // In spite of this, we print only warning
26         LOG(WARNING) << "Failed to remove tep file from: " << tep_path;
27       }
28     }
29     LOG(DEBUG) << "Tep package file removed: " << tep_path;
30   }
31   return Status::OK;
32 }
33
34 }  // namespace filesystem
35 }  // namespace common_installer