X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcommon%2Frecovery_file.cc;h=d7999ab413dac9d0b57f9299374a2f3d387fe654;hb=bc819e6bce3bc061383b27e476882aa3babb48c6;hp=ace241469059b66450284c9ba4963d5abf60d3e0;hpb=b04cf9b96466d8ff66692a8e5d84a440bc9366f3;p=platform%2Fcore%2Fappfw%2Fapp-installers.git diff --git a/src/common/recovery_file.cc b/src/common/recovery_file.cc index ace2414..d7999ab 100644 --- a/src/common/recovery_file.cc +++ b/src/common/recovery_file.cc @@ -4,26 +4,21 @@ #include "common/recovery_file.h" -#include -#include -#include -#include - #include #include #include +#include #include +#include #include #include #include "common/installer_context.h" #include "common/utils/file_util.h" -namespace bf = boost::filesystem; -namespace bs = boost::system; -namespace bi = boost::iostreams; namespace ci = common_installer; +namespace fs = std::filesystem; namespace { @@ -65,8 +60,8 @@ namespace common_installer { namespace recovery { std::unique_ptr RecoveryFile::CreateRecoveryFile( - const boost::filesystem::path& path, RequestType type) { - if (bf::exists(path)) { + const std::filesystem::path& path, RequestType type) { + if (fs::exists(path)) { LOG(ERROR) << "Recovery file already exists!"; return nullptr; } @@ -79,8 +74,8 @@ std::unique_ptr RecoveryFile::CreateRecoveryFile( } std::unique_ptr RecoveryFile::OpenRecoveryFile( - const boost::filesystem::path& path) { - if (!bf::exists(path)) { + const std::filesystem::path& path) { + if (!fs::exists(path)) { LOG(ERROR) << "Cannot open recovery file"; return nullptr; } @@ -93,7 +88,7 @@ std::unique_ptr RecoveryFile::OpenRecoveryFile( return file; } -RecoveryFile::RecoveryFile(const bf::path& path, RequestType type, bool load) +RecoveryFile::RecoveryFile(const fs::path& path, RequestType type, bool load) : type_(type), path_(path), backup_done_(false), cleanup_(false), security_operation_done_(false) { backup_path_ = path_.string() + ".bck"; @@ -128,7 +123,7 @@ bool RecoveryFile::is_detached() const { } void RecoveryFile::set_unpacked_dir( - boost::filesystem::path unpacked_dir) { + std::filesystem::path unpacked_dir) { unpacked_dir_ = std::move(unpacked_dir); } @@ -149,7 +144,7 @@ void RecoveryFile::set_security_operation_done(bool security_operation_done) { security_operation_done_ = security_operation_done; } -const boost::filesystem::path& RecoveryFile::unpacked_dir() const { +const std::filesystem::path& RecoveryFile::unpacked_dir() const { return unpacked_dir_; } @@ -236,9 +231,9 @@ bool RecoveryFile::ReadFileContent() { } bool RecoveryFile::WriteAndCommitFileContent() { - if (bf::exists(path_)) { - bs::error_code error; - bf::rename(path_, backup_path_, error); + if (fs::exists(path_)) { + std::error_code error; + fs::rename(path_, backup_path_, error); if (error) { LOG(ERROR) << "Cannot backup recovery file:" << path_ << ", error: " << error; @@ -246,7 +241,7 @@ bool RecoveryFile::WriteAndCommitFileContent() { } } - bi::stream ofs(path_); + std::ofstream ofs(path_); if (!ofs) { LOG(ERROR) << "Cannot write recovery file"; return false; @@ -290,8 +285,8 @@ bool RecoveryFile::WriteAndCommitFileContent() { ofs << (cleanup_ ? "cleanup" : "rollback") << std::endl; ofs << (security_operation_done_ ? "true" : "false") << std::endl; ofs.flush(); - ::fsync(ofs->handle()); ofs.close(); + SyncFile(path_); Remove(backup_path_); return true; @@ -299,4 +294,3 @@ bool RecoveryFile::WriteAndCommitFileContent() { } // namespace recovery } // namespace common_installer -