7fad89d925c44225ce70486eb7a34b22bb57ff01
[platform/core/appfw/app-installers.git] / src / common / step / mount / step_unmount.cc
1 // Copyright (c) 2020 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 "step/mount/step_unmount.h"
6
7 #include <boost/filesystem/operations.hpp>
8 #include <boost/filesystem/path.hpp>
9
10 #include <string>
11
12 #include "common/utils/paths.h"
13 #include "common/tzip_interface.h"
14 #include "common/zip_interface.h"
15
16 namespace bf = boost::filesystem;
17 namespace bs = boost::system;
18
19 namespace common_installer {
20 namespace mount {
21
22 Step::Status StepUnmount::process() {
23   auto zip_final = CreateZipInterface(
24       GetMountLocation(context_->GetPkgPath()));
25
26   if (!zip_final->UnmountZip()) {
27     LOG(ERROR) << "Failed to unmount zip package after installation";
28     return Status::APP_DIR_ERROR;
29   }
30
31   return Status::OK;
32 }
33
34 std::unique_ptr<IZipInterface> StepUnmount::CreateZipInterface(
35     const boost::filesystem::path& mount_path) {
36   std::unique_ptr<IZipInterface> zip_interface(
37       new TzipInterface(mount_path));
38   return zip_interface;
39 }
40
41 }  // namespace mount
42 }  // namespace common_installer