#include "common/step/filesystem/step_recover_files.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
+#include <filesystem>
#include "common/utils/paths.h"
#include "common/recovery_file.h"
#include "common/utils/file_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace {
const char kExternalMemoryMountPoint[] = ".mmc";
-bool Move(const boost::filesystem::path& from,
- const boost::filesystem::path& to,
+bool Move(const std::filesystem::path& from,
+ const std::filesystem::path& to,
common_installer::FSFlag flag = common_installer::FSFlag::FS_NONE) {
- if (bf::is_directory(from)) {
+ if (fs::is_directory(from)) {
if (!common_installer::MoveDir(from, to / from.filename(), flag)) {
LOG(ERROR) << "Failed to move directory: " << from;
return false;
recovery::RecoveryFile* recovery_file =
context_->recovery_info.get().recovery_file.get();
bool backup_done = recovery_file->backup_done();
- bf::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
- if (bf::exists(backup_path)) {
+ fs::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
+ if (fs::exists(backup_path)) {
// Remove pkgdir only if backup original contents is completely done.
if (backup_done) {
- for (bf::directory_iterator iter(context_->GetPkgPath());
- iter != bf::directory_iterator(); ++iter) {
+ for (fs::directory_iterator iter(context_->GetPkgPath());
+ iter != fs::directory_iterator(); ++iter) {
if (iter->path().filename() == kExternalMemoryMountPoint)
continue;
}
// create copy of old package content skipping the external memory mount point
- for (bf::directory_iterator iter(backup_path);
- iter != bf::directory_iterator(); ++iter) {
+ for (fs::directory_iterator iter(backup_path);
+ iter != fs::directory_iterator(); ++iter) {
if (!Move(iter->path(), context_->GetPkgPath()))
return Status::RECOVERY_ERROR;
}
}
Step::Status StepRecoverFiles::RecoveryMountNew() {
- bf::path zip_location = GetZipPackageLocation(
+ fs::path zip_location = GetZipPackageLocation(
context_->GetPkgPath(), context_->pkgid.get());
Remove(zip_location);
ClearPath(context_->GetPkgPath());
}
Step::Status StepRecoverFiles::RecoveryMountUpdate() {
- bf::path zip_location = GetZipPackageLocation(
+ fs::path zip_location = GetZipPackageLocation(
context_->GetPkgPath(), context_->pkgid.get());
- bf::path backup_zip_location = GetBackupPathForZipFile(zip_location);
- if (bf::exists(backup_zip_location)) {
+ fs::path backup_zip_location = GetBackupPathForZipFile(zip_location);
+ if (fs::exists(backup_zip_location)) {
Remove(zip_location);
if (!MoveFile(backup_zip_location, zip_location))
LOG(ERROR) << "Failed to move " << backup_zip_location << " to "
// directories without mounting zip package file. In other words in mount
// install or mount update mode we don't mount everything - some files are
// still unpacked due to necessity.
- bf::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
- if (bf::exists(backup_path)) {
- for (bf::directory_iterator iter(backup_path);
- iter != bf::directory_iterator(); ++iter) {
+ fs::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
+ if (fs::exists(backup_path)) {
+ for (fs::directory_iterator iter(backup_path);
+ iter != fs::directory_iterator(); ++iter) {
ClearPath(context_->GetPkgPath() / iter->path().filename());
if (!Move(iter->path(), context_->GetPkgPath())) {
LOG(ERROR) << "Failed to recovery backup file(" << iter->path()
Step::Status StepRecoverFiles::RecoveryReadonlyUpdateInstall() {
// Remove package directory at RW area
- bf::path pkg_path =
- bf::path(GetRootAppPath(false, context_->uid.get())) /
+ fs::path pkg_path =
+ fs::path(GetRootAppPath(false, context_->uid.get())) /
context_->pkgid.get();
if (!ClearPath(pkg_path))
return Status::RECOVERY_ERROR;
Step::Status StepRecoverFiles::Cleanup() {
recovery::RecoveryFile* recovery_file =
context_->recovery_info.get().recovery_file.get();
- bf::path root_path(GetRootAppPath(
+ fs::path root_path(GetRootAppPath(
context_->is_readonly_package.get(), context_->uid.get()));
- bf::path backup_path = GetBackupPathForPackagePath(
+ fs::path backup_path = GetBackupPathForPackagePath(
root_path / recovery_file->pkgid());
- if (!bf::exists(backup_path))
+ if (!fs::exists(backup_path))
return Status::OK;
if (!ClearPath(backup_path)) {
return Status::OK;
}
-bool StepRecoverFiles::ClearPath(const bf::path& path) {
+bool StepRecoverFiles::ClearPath(const fs::path& path) {
return RemoveAll(path);
}