Context paths types changed to boost::filesystem::path 54/38254/1
authorTomasz Iwanek <t.iwanek@samsung.com>
Wed, 1 Apr 2015 14:41:31 +0000 (16:41 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Wed, 15 Apr 2015 09:02:29 +0000 (11:02 +0200)
Change-Id: Ic82ebf53ecbae4029c39332e6fd057719d93a78d

src/common/context_installer.h
src/common/step/step_check_signature.cc
src/common/step/step_generate_xml.cc
src/common/step/step_unzip.cc
src/common/step/step_unzip.h
src/tpk/step/step_create_symbolic_link.cc
src/wgt/step/step_create_symbolic_link.cc

index 678223b..29a85a2 100644 (file)
@@ -3,6 +3,8 @@
 #ifndef COMMON_CONTEXT_INSTALLER_H_
 #define COMMON_CONTEXT_INSTALLER_H_
 
+#include <boost/filesystem/path.hpp>
+
 #include <pkgmgr_parser.h>
 
 #include <unistd.h>
@@ -56,19 +58,19 @@ class ContextInstaller {
   Property<manifest_x*> manifest_data;
 
   // path to manifest xml file used to register data in databases
-  Property<std::string> xml_path;
+  Property<boost::filesystem::path> xml_path;
 
   // pkgid used for update or uninstallation processing
   Property<std::string> pkgid;
 
   // package directory path containing app data
-  Property<std::string> pkg_path;
+  Property<boost::filesystem::path> pkg_path;
 
   // file path used for installation or reinstallation process
-  Property<std::string> file_path;
+  Property<boost::filesystem::path> file_path;
 
   // directory path where app data are temporarily extracted
-  Property<std::string> unpacked_dir_path;
+  Property<boost::filesystem::path> unpacked_dir_path;
 
   // uid of the user that request the operation
   Property<uid_t> uid;
@@ -77,10 +79,10 @@ class ContextInstaller {
   Property<ConfigData> config_data;
 
   // path for the applications directory
-  Property<std::string> application_path;
+  Property<boost::filesystem::path> application_path;
 
   // path for the applications root directory
-  Property<std::string> root_application_path;
+  Property<boost::filesystem::path> root_application_path;
 };
 
 }  // namespace common_installer
index 92edafd..bf1e481 100644 (file)
@@ -16,7 +16,7 @@ namespace common_installer {
 namespace signature {
 
 Step::Status StepCheckSignature::process() {
-  return (SignatureValidator::Check(bf::path(context_->unpacked_dir_path.get()))
+  return (SignatureValidator::Check(context_->unpacked_dir_path.get())
       == SignatureValidator::INVALID) ? Status::ERROR : Status::OK;
 }
 
index e393538..86cd8a8 100644 (file)
@@ -32,7 +32,7 @@ Step::Status StepGenerateXml::GenerateApplicationCommonXml(T* app,
   xmlTextWriterWriteAttribute(writer, BAD_CAST "appid", BAD_CAST app->appid);
 
   // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
-  fs::path exec_path = fs::path(context_->pkg_path.get()) / fs::path(app->appid)
+  fs::path exec_path = context_->pkg_path.get() / fs::path(app->appid)
       / fs::path("bin") / fs::path(app->appid);
   xmlTextWriterWriteAttribute(writer, BAD_CAST "exec",
                               BAD_CAST exec_path.string().c_str());
index 225dddd..0b76859 100644 (file)
@@ -109,7 +109,7 @@ StepUnzip::StepUnzip(ContextInstaller* context)
     : Step(context),
       is_extracted_(false) {}
 
-boost::filesystem::path StepUnzip::GenerateTmpDir(const std::string &app_path) {
+boost::filesystem::path StepUnzip::GenerateTmpDir(const bf::path &app_path) {
   boost::filesystem::path install_tmp_dir;
   boost::filesystem::path tmp_dir(app_path);
 
@@ -230,8 +230,7 @@ Step::Status StepUnzip::process() {
     return Step::Status::ERROR;
   }
 
-  int64_t required_size =
-      GetUnpackedPackageSize(bf::path(context_->file_path.get()));
+  int64_t required_size = GetUnpackedPackageSize(context_->file_path.get());
 
   if (required_size == -1) {
     LOG(ERROR) << "Couldn't get uncompressed size for package: "
@@ -252,12 +251,12 @@ Step::Status StepUnzip::process() {
     return Step::Status::OUT_OF_SPACE;
   }
 
-  if (ExtractToTmpDir(context_->file_path.get().c_str(), tmp_dir)
+  if (ExtractToTmpDir(context_->file_path.get().string().c_str(), tmp_dir)
       != Step::Status::OK) {
     LOG(ERROR) << "Failed to process unpack step";
     return Step::Status::ERROR;
   }
-  context_->unpacked_dir_path.set(tmp_dir.string());
+  context_->unpacked_dir_path.set(tmp_dir);
 
   LOG(INFO) << context_->file_path.get() << " was successfully unzipped into "
       << context_->unpacked_dir_path.get();
@@ -265,7 +264,7 @@ Step::Status StepUnzip::process() {
 }
 
 Step::Status StepUnzip::undo() {
-  if (access(context_->unpacked_dir_path.get().c_str(), F_OK) == 0) {
+  if (access(context_->unpacked_dir_path.get().string().c_str(), F_OK) == 0) {
     bf::remove_all(context_->unpacked_dir_path.get());
     LOG(DEBUG) << "remove temp dir: " << context_->unpacked_dir_path.get();
   }
index 40b9281..6e90fe1 100644 (file)
@@ -5,8 +5,6 @@
 
 #include <boost/filesystem/path.hpp>
 
-#include <string>
-
 #include "common/context_installer.h"
 #include "common/step/step.h"
 #include "utils/logging.h"
@@ -23,7 +21,8 @@ class StepUnzip : public Step {
   Status undo() override;
 
  private:
-  boost::filesystem::path GenerateTmpDir(const std::string &app_path);
+  boost::filesystem::path GenerateTmpDir(
+      const boost::filesystem::path& app_path);
   Step::Status ExtractToTmpDir(const char* source_dir,
       const boost::filesystem::path& tmp_dir);
 
index fd057f2..16353d2 100644 (file)
@@ -25,7 +25,7 @@ bool CreateSymLink(T *app, ContextInstaller* context) {
   boost::system::error_code error;
 
   for (; app != nullptr; app=app->next) {
-    fs::path bindir = fs::path(context->pkg_path.get()) / fs::path(app->appid) /
+    fs::path bindir = context->pkg_path.get() / fs::path(app->appid) /
         fs::path("bin");
     LOG(INFO) << "Creating dir: " << bindir;
     if (!common_installer::utils::CreateDir(bindir)) {
index be4087b..bb7bf12 100644 (file)
@@ -33,7 +33,7 @@ common_installer::Step::Status StepCreateSymbolicLink::process() {
   for (; ui != nullptr; ui = ui->next) {
     // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
     fs::path exec_path =
-        fs::path(context_->pkg_path.get()) / fs::path(ui->appid)
+        context_->pkg_path.get() / fs::path(ui->appid)
             / fs::path("bin");
     common_installer::utils::CreateDir(exec_path);
 
@@ -49,7 +49,7 @@ common_installer::Step::Status StepCreateSymbolicLink::process() {
   for (; svc != nullptr; svc = svc->next) {
     // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
     fs::path exec_path =
-        fs::path(context_->pkg_path.get()) / fs::path(svc->appid)/
+        context_->pkg_path.get() / fs::path(svc->appid)/
             fs::path("bin");
     common_installer::utils::CreateDir(exec_path);
 
@@ -77,14 +77,14 @@ common_installer::Step::Status StepCreateSymbolicLink::undo() {
 
   for (; ui != nullptr; ui = ui->next) {
     fs::path exec_path =
-        fs::path(context_->pkg_path.get()) / fs::path(ui->appid)
+        context_->pkg_path.get() / fs::path(ui->appid)
             / fs::path("bin");
     if (fs::exists(exec_path))
       fs::remove_all(exec_path);
   }
   for (; svc != nullptr; svc = svc->next) {
     fs::path exec_path =
-        fs::path(context_->pkg_path.get()) / fs::path(svc->appid)
+        context_->pkg_path.get() / fs::path(svc->appid)
             / fs::path("bin");
     if (fs::exists(exec_path))
       fs::remove_all(exec_path);