Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / pkgmgr_interface.cc
index a754585..b7d3ccd 100644 (file)
@@ -4,14 +4,13 @@
 
 #include "common/pkgmgr_interface.h"
 
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem.hpp>
-
 #include <tzplatform_config.h>
 
 #include <memory>
 #include <string>
+#include <filesystem>
 #include <fstream>
+#include <optional>
 
 #include "common/app_query_interface.h"
 #include "common/utils/pkgmgr_query.h"
@@ -21,7 +20,7 @@
 #include "common/utils/manifest_util.h"
 #include "common/utils/user_util.h"
 
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 namespace ci = common_installer;
 
 namespace {
@@ -33,7 +32,7 @@ const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
 bool CheckIfAppFilesExists(const std::string& pkgid,
                            uid_t uid,
                            bool is_readonly) {
-  return bf::exists(ci::GetManifestLocation(pkgid,
+  return fs::exists(ci::GetManifestLocation(pkgid,
               uid, is_readonly));
 }
 
@@ -45,7 +44,7 @@ bool IsDeltaPkg(const std::string& path) {
   }
 
   if (!is_delta) {
-    std::string extension = bf::path(path).extension().string();
+    std::string extension = fs::path(path).extension().string();
     if (extension == kDeltaFileExtension)
       is_delta = true;
   }
@@ -104,7 +103,7 @@ int PkgMgrInterface::InitInternal(int argc, char** argv) {
     return -1;
   }
 
-  boost::optional<bool> is_admin_user =
+  std::optional<bool> is_admin_user =
       IsAdminUser(pkgmgr_installer_get_uid(pi_));
   if (!is_admin_user) {
     LOG(ERROR) << "Cannot get admin user info. Aborting.";
@@ -131,7 +130,7 @@ PkgMgrInterface::~PkgMgrInterface() {
 // method name?
 bool PkgMgrInterface::SetAppQueryInterface(int idx) {
   // reset this flag to processing new package
-  is_app_installed_ = boost::none;
+  is_app_installed_.reset();
 
   auto it = query_interface_map_.find(idx);
   if (it == query_interface_map_.end()) {
@@ -194,7 +193,7 @@ RequestType PkgMgrInterface::GetRequestType(int idx) const {
       if (request_info.empty())
         return RequestType::Unknown;
       bool is_delta = IsDeltaPkg(request_info);
-      if (!is_app_installed_.get()) {
+      if (!is_app_installed_.value()) {
         if (is_delta) {
           LOG(ERROR) << "Package is not installed. "
                         "Cannot update from delta package";
@@ -239,7 +238,7 @@ RequestType PkgMgrInterface::GetRequestType(int idx) const {
         return RequestType::Uninstall;
     }
     case PKGMGR_REQ_MANIFEST_DIRECT_INSTALL:
-      if (!is_app_installed_.get()) {
+      if (!is_app_installed_.value()) {
         if (GetIsPreloadRequest() && GetIsPartialRW())
           return RequestType::ManifestPartialInstall;
         else
@@ -251,7 +250,7 @@ RequestType PkgMgrInterface::GetRequestType(int idx) const {
           return RequestType::ManifestDirectUpdate;
       }
     case PKGMGR_REQ_MOUNT_INSTALL: {
-      if (!is_app_installed_.get()) {
+      if (!is_app_installed_.value()) {
         return RequestType::MountInstall;
       } else {
         std::string pkgid = query_interface->GetPkgId(GetRequestInfo(idx));
@@ -283,11 +282,11 @@ std::string PkgMgrInterface::GetRequestInfo(int idx) const {
     return request_info;
 }
 
-boost::filesystem::path PkgMgrInterface::GetTepPath() const {
+std::filesystem::path PkgMgrInterface::GetTepPath() const {
   if (pkgmgr_installer_get_tep_path(pi_) == nullptr)
-    return boost::filesystem::path("");
+    return std::filesystem::path("");
   else
-    return boost::filesystem::path(pkgmgr_installer_get_tep_path(pi_));
+    return std::filesystem::path(pkgmgr_installer_get_tep_path(pi_));
 }
 
 bool PkgMgrInterface::GetIsTepMove() const {