#include <unistd.h>
#include <cstdlib>
-namespace fs = boost::filesystem;
-
namespace common_installer {
bool SatifiesPrivilegeLevel(PrivilegeLevel required_level,
namespace common_installer {
namespace parse {
-namespace fs = boost::filesystem;
+namespace bf = boost::filesystem;
Step::Status StepParse::process() {
- fs::path xml_path = fs::path(getUserManifestPath(context_->uid.get()))
- / fs::path(context_->pkgid.get());
+ bf::path xml_path = bf::path(getUserManifestPath(context_->uid.get()))
+ / bf::path(context_->pkgid.get());
xml_path += ".xml";
context_->xml_path.set(xml_path.string());
namespace common_installer {
namespace pkgmgr {
-namespace fs = boost::filesystem;
-
Step::Status StepRegisterApplication::precheck() {
if (context_->xml_path.get().empty()) {
LOG(ERROR) << "xml_path attribute is empty";
namespace filesystem {
namespace bs = boost::system;
-namespace fs = boost::filesystem;
+namespace bf = boost::filesystem;
Step::Status StepRemoveFiles::precheck() {
if (!context_->manifest_data.get()) {
// to remove the files
if (context_->pkg_path.get().empty())
LOG(ERROR) << "pkg_path attribute is empty";
- else if (!fs::exists(context_->pkg_path.get()))
+ else if (!bf::exists(context_->pkg_path.get()))
LOG(ERROR) << "pkg_path ("
<< context_->pkg_path.get()
<< ") path does not exist";
}
Step::Status StepRemoveFiles::process() {
- fs::path backup_path = GetBackupPathForPackagePath(context_->pkg_path.get());
+ bf::path backup_path = GetBackupPathForPackagePath(context_->pkg_path.get());
if (!MoveDir(context_->pkg_path.get(), backup_path)) {
LOG(ERROR) << "Cannot remove widget files from its location";
return Status::ERROR;
Step::Status StepRemoveFiles::clean() {
bs::error_code error;
- fs::path backup_path = GetBackupPathForPackagePath(context_->pkg_path.get());
- fs::remove_all(backup_path, error);
+ bf::path backup_path = GetBackupPathForPackagePath(context_->pkg_path.get());
+ bf::remove_all(backup_path, error);
return Status::OK;
}
Step::Status StepRemoveFiles::undo() {
- fs::path backup_path = GetBackupPathForPackagePath(context_->pkg_path.get());
- if (fs::exists(backup_path)) {
+ bf::path backup_path = GetBackupPathForPackagePath(context_->pkg_path.get());
+ if (bf::exists(backup_path)) {
LOG(DEBUG) << "Restoring directory: " << context_->pkg_path.get();
if (!MoveDir(backup_path, context_->pkg_path.get())) {
LOG(ERROR) << "Cannot restore widget files";
namespace filesystem {
namespace bs = boost::system;
-namespace fs = boost::filesystem;
+namespace bf = boost::filesystem;
Step::Status StepRemoveIcons::precheck() {
if (!context_->manifest_data.get()) {
PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->uiapplication,
ui);
for (; ui != nullptr; ui = ui->next) {
- fs::path app_icon = fs::path(getIconPath(context_->uid.get()))
- / fs::path(ui->appid);
+ bf::path app_icon = bf::path(getIconPath(context_->uid.get()))
+ / bf::path(ui->appid);
if (ui->icon && ui->icon->text)
- app_icon += fs::path(ui->icon->text).extension();
+ app_icon += bf::path(ui->icon->text).extension();
else
app_icon += ".png";
- if (fs::exists(app_icon)) {
- fs::path backup_icon_file = GetBackupPathForIconFile(app_icon);
+ if (bf::exists(app_icon)) {
+ bf::path backup_icon_file = GetBackupPathForIconFile(app_icon);
if (!MoveFile(app_icon, backup_icon_file)) {
LOG(ERROR) << "Failed to create backup for icon: " << app_icon;
return Status::ERROR;
if (!backups_.empty()) {
LOG(DEBUG) << "Clean up icons files...";
for (auto& pair : backups_) {
- fs::remove(pair.first, error);
+ bf::remove(pair.first, error);
if (error) {
LOG(WARNING) << "Failed to remove: " << pair.first;
}
namespace pkgmgr {
namespace bs = boost::system;
-namespace fs = boost::filesystem;
+namespace bf = boost::filesystem;
Step::Status StepUnregisterApplication::precheck() {
if (context_->pkgid.get().empty()) {
// remove manifest file
bs::error_code error;
- fs::remove(context_->xml_path.get(), error);
+ bf::remove(context_->xml_path.get(), error);
LOG(DEBUG) << "Successfully unregister the application";
namespace tpk {
namespace filesystem {
-namespace fs = boost::filesystem;
+namespace bf = boost::filesystem;
using common_installer::ContextInstaller;
typedef common_installer::Step::Status Status;
boost::system::error_code boost_error;
for (; app != nullptr; app=app->next) {
- fs::path bindir = context->pkg_path.get() /
- fs::path("bin");
+ bf::path bindir = context->pkg_path.get() /
+ bf::path("bin");
LOG(INFO) << "Creating dir: " << bindir;
if (!common_installer::CreateDir(bindir)) {
LOG(ERROR) << "Directory creation failure: " << bindir;
// Exec path
// Make a symlink with the name of appid, pointing exec file
- fs::path symlink_path = bindir / fs::path(app->appid);
+ bf::path symlink_path = bindir / bf::path(app->appid);
LOG(INFO) << "Creating symlink " << symlink_path << " pointing " <<
app->exec;
- fs::create_symlink(fs::path(app->exec), symlink_path, boost_error);
+ bf::create_symlink(bf::path(app->exec), symlink_path, boost_error);
if (boost_error) {
LOG(ERROR) << "Symlink creation failure: " << symlink_path;
return false;
}
// Give an execution permission to the original executable
- fs::path exec_path = bindir / fs::path(app->exec);
+ bf::path exec_path = bindir / bf::path(app->exec);
LOG(INFO) << "Giving exec permission to " << exec_path;
- fs::permissions(exec_path, fs::owner_all |
- fs::group_read | fs::group_exe |
- fs::others_read | fs::others_exe, boost_error);
+ bf::permissions(exec_path, bf::owner_all |
+ bf::group_read | bf::group_exe |
+ bf::others_read | bf::others_exe, boost_error);
if (boost_error) {
LOG(ERROR) << "Permission change failure";
return false;
* So we don't remove the bin/ directory.
*/
for (; app != nullptr; app=app->next) {
- fs::path exec_path = fs::path(context->pkg_path.get()) / fs::path("bin");
- fs::remove_all(exec_path / fs::path(app->appid));
+ bf::path exec_path = bf::path(context->pkg_path.get()) / bf::path("bin");
+ bf::remove_all(exec_path / bf::path(app->appid));
}
return true;
}
namespace wgt {
namespace filesystem {
-namespace fs = boost::filesystem;
+namespace bf = boost::filesystem;
common_installer::Step::Status StepCreateSymbolicLink::process() {
assert(context_->manifest_data.get());
// add ui-application element per ui application
for (; ui != nullptr; ui = ui->next) {
// binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
- fs::path exec_path =
+ bf::path exec_path =
context_->pkg_path.get()
- / fs::path("bin");
+ / bf::path("bin");
common_installer::CreateDir(exec_path);
- exec_path /= fs::path(ui->appid);
+ exec_path /= bf::path(ui->appid);
- fs::create_symlink(fs::path(WRT_LAUNCHER), exec_path, error);
+ bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error);
if (error) {
LOG(ERROR) << "Failed to set symbolic link "
<< boost::system::system_error(error).what();
}
for (; svc != nullptr; svc = svc->next) {
// binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
- fs::path exec_path = context_->pkg_path.get() / fs::path("bin");
+ bf::path exec_path = context_->pkg_path.get() / bf::path("bin");
common_installer::CreateDir(exec_path);
- exec_path /= fs::path(svc->appid);
+ exec_path /= bf::path(svc->appid);
- fs::create_symlink(fs::path(WRT_LAUNCHER), exec_path, error);
+ bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error);
if (error) {
LOG(ERROR) << "Failed to set symbolic link "
<< boost::system::system_error(error).what();
serviceapplication_x* svc = context_->manifest_data.get()->serviceapplication;
for (; ui != nullptr; ui = ui->next) {
- fs::path exec_path = context_->pkg_path.get() / fs::path("bin");
- if (fs::exists(exec_path))
- fs::remove_all(exec_path);
+ bf::path exec_path = context_->pkg_path.get() / bf::path("bin");
+ if (bf::exists(exec_path))
+ bf::remove_all(exec_path);
}
for (; svc != nullptr; svc = svc->next) {
- fs::path exec_path = context_->pkg_path.get() / fs::path("bin");
- if (fs::exists(exec_path))
- fs::remove_all(exec_path);
+ bf::path exec_path = context_->pkg_path.get() / bf::path("bin");
+ if (bf::exists(exec_path))
+ bf::remove_all(exec_path);
}
return Status::OK;
}
#include "common/utils/file_util.h"
namespace bs = boost::system;
-namespace fs = boost::filesystem;
+namespace bf = boost::filesystem;
namespace wgt {
namespace pkgmgr {
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 = context_->pkg_path.get()
- / fs::path("bin") / fs::path(app->appid);
+ bf::path exec_path = context_->pkg_path.get()
+ / bf::path("bin") / bf::path(app->appid);
xmlTextWriterWriteAttribute(writer, BAD_CAST "exec",
BAD_CAST exec_path.string().c_str());
if (app->type)
// icon is renamed to <appid.png>
if (app->icon->text) {
- fs::path app_icon = context_->pkg_path.get() / "res/wgt" /
+ bf::path app_icon = context_->pkg_path.get() / "res/wgt" /
app->icon->text;
- fs::path icon = app->appid;
+ bf::path icon = app->appid;
if (app_icon.has_extension())
icon += app_icon.extension();
else
- icon += fs::path(".png");
+ icon += bf::path(".png");
- if (fs::exists(app_icon)) {
+ if (bf::exists(app_icon)) {
xmlTextWriterWriteFormatElement(writer, BAD_CAST "icon",
"%s", BAD_CAST icon.c_str());
}
}
common_installer::Step::Status StepGenerateXml::process() {
- fs::path xml_path = fs::path(getUserManifestPath(context_->uid.get()))
- / fs::path(context_->pkgid.get());
+ bf::path xml_path = bf::path(getUserManifestPath(context_->uid.get()))
+ / bf::path(context_->pkgid.get());
xml_path += ".xml";
context_->xml_path.set(xml_path.string());
bs::error_code error;
- if (!fs::exists(xml_path.parent_path(), error)) {
+ if (!bf::exists(xml_path.parent_path(), error)) {
if (!common_installer::CreateDir(xml_path.parent_path())) {
LOG(ERROR) <<
"Directory for manifest xml is missing and cannot be created";
common_installer::Step::Status StepGenerateXml::undo() {
bs::error_code error;
- if (fs::exists(context_->xml_path.get()))
- fs::remove_all(context_->xml_path.get(), error);
+ if (bf::exists(context_->xml_path.get()))
+ bf::remove_all(context_->xml_path.get(), error);
return Status::OK;
}