Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / app_query_interface.cc
index 02cfe88..3523fcb 100644 (file)
@@ -2,22 +2,26 @@
 // Use of this source code is governed by an apache-2.0 license that can be
 // found in the LICENSE file.
 
+#include <filesystem>
+
 #include "common/app_query_interface.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
 #include "common/utils/file_util.h"
 
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
 
 namespace common_installer {
 
 bool AppQueryInterface::IsPkgInstalled(const std::string& arg,
     uid_t uid) const {
+  std::error_code ec;
+  std::string pkg_id;
   // argument from commandline is path to file
-  std::string pkg_id = GetPkgIdFromPath(arg);
+  if (fs::exists(arg, ec) && ec.value() == 0)
+    pkg_id = GetPkgIdFromPath(arg);
   if (pkg_id.empty())
     pkg_id = arg;
-  PkgQueryInterface pkg_query(pkg_id, uid);
+  PkgQueryInterface pkg_query(pkg_id, uid, true);
   return pkg_query.IsPackageInstalled(GetRequestMode(uid));
 }
 
@@ -25,13 +29,13 @@ std::string AppQueryInterface::GetPkgId(const std::string& arg) const {
   return GetPkgIdFromPath(arg);
 }
 
-boost::filesystem::path AppQueryInterface::ExtractManifest(
+fs::path AppQueryInterface::ExtractManifest(
     const std::string& from) const {
-  if (!bf::exists(from))
+  if (!fs::exists(from))
     return {};
-  bf::path tmp_path = GenerateTmpDir("/tmp");
-  bs::error_code code;
-  bf::create_directories(tmp_path, code);
+  fs::path tmp_path = GenerateTmpDir("/tmp");
+  std::error_code code;
+  fs::create_directories(tmp_path, code);
   if (code)
     return {};
   if (!ExtractToTmpDir(from.c_str(), tmp_path,
@@ -42,4 +46,9 @@ boost::filesystem::path AppQueryInterface::ExtractManifest(
   return tmp_path;
 }
 
+bool AppQueryInterface::ClearTemporaryFile(
+    const fs::path& path) const {
+  return RemoveAll(path);
+}
+
 }  // namespace common_installer