560f015d15dca9f151355e1f9a54869b7e8787a0
[platform/core/appfw/wgt-backend.git] / src / wgt / step / configuration / step_check_rds_manifest.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 "wgt/step/configuration/step_check_rds_manifest.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 {
15
16 const char kConfigInstalled[] = "res/wgt/config.xml";
17 const char kConfigDeltaDir[] = "res/wgt/config.xml";
18
19 }  // namespace
20
21 namespace wgt {
22 namespace configuration {
23
24 common_installer::Step::Status StepCheckRDSManifest::process() {
25   bf::path target = context_->unpacked_dir_path.get() / kConfigDeltaDir;
26   if (!bf::exists(target)) {
27     bf::path source = context_->root_application_path.get() /
28         context_->pkgid.get() / kConfigInstalled;
29     if (!bf::exists(source)) {
30       LOG(ERROR) << "Cannot find old manifest file";
31       return Status::APP_DIR_ERROR;
32     }
33     bs::error_code error;
34     bf::create_directories(source.parent_path(), error);
35     if (error) {
36       LOG(ERROR) << "Failed to create directories for manifest file";
37       return Status::APP_DIR_ERROR;
38     }
39     bf::copy_file(source, target, error);
40     if (error) {
41       LOG(ERROR) << "Failed to copy old manifest file";
42       return Status::APP_DIR_ERROR;
43     }
44   }
45   return Status::OK;
46 }
47
48 }  // namespace configuration
49 }  // namespace wgt