1 // Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
7 #include "common/app_query_interface.h"
8 #include "common/utils/pkgmgr_query.h"
9 #include "common/utils/file_util.h"
11 namespace fs = std::filesystem;
13 namespace common_installer {
15 bool AppQueryInterface::IsPkgInstalled(const std::string& arg,
19 // argument from commandline is path to file
20 if (fs::exists(arg, ec) && ec.value() == 0)
21 pkg_id = GetPkgIdFromPath(arg);
24 PkgQueryInterface pkg_query(pkg_id, uid, true);
25 return pkg_query.IsPackageInstalled(GetRequestMode(uid));
28 std::string AppQueryInterface::GetPkgId(const std::string& arg) const {
29 return GetPkgIdFromPath(arg);
32 fs::path AppQueryInterface::ExtractManifest(
33 const std::string& from) const {
34 if (!fs::exists(from))
36 fs::path tmp_path = GenerateTmpDir("/tmp");
38 fs::create_directories(tmp_path, code);
41 if (!ExtractToTmpDir(from.c_str(), tmp_path,
42 GetManifestFileName())) {
49 bool AppQueryInterface::ClearTemporaryFile(
50 const fs::path& path) const {
51 return RemoveAll(path);
54 } // namespace common_installer