const char kManifestFileName[] = "tizen-manifest.xml";
-uid_t GetUid(int argc, char** argv) {
- uid_t uid = 0;
- for (int i = 0; i < argc; ++i) {
- if (!strcmp(argv[i], "-u")) {
- if (i + 1 < argc) {
- uid = atoi(argv[i + 1]);
- break;
- }
- }
- }
-
- return uid;
-}
-
-std::string GetInstallationPackagePath(int argc, char** argv) {
- std::string path;
- for (int i = 0; i < argc; ++i) {
- if (!strcmp(argv[i], "-i") || !strcmp(argv[i], "-w")) {
- if (i + 1 < argc) {
- path = argv[i + 1];
- break;
- }
- }
- }
- return path;
-}
-
-std::string GetPkgIdFromCmd(int argc, char** argv) {
- std::string pkgid;
- for (int i = 0; i < argc; ++i) {
- if (!strcmp(argv[i], "-y")) {
- if (i + 1 < argc) {
- pkgid = argv[i + 1];
- break;
- }
- }
- }
- return pkgid;
-}
-
std::string GetPkgIdFromPath(const std::string& path) {
+ if (!bf::exists(path))
+ return {};
bf::path tmp_path = common_installer::GenerateTmpDir("/tmp");
bs::error_code code;
bf::create_directories(tmp_path, code);
namespace tpk {
-bool TpkAppQueryInterface::IsAppInstalledByArgv(int argc, char** argv) {
- std::string path = GetInstallationPackagePath(argc, argv);
- std::string pkg_id;
- if (path.empty()) {
- // check if it is manifest direct install
- pkg_id = GetPkgIdFromCmd(argc, argv);
- } else {
- pkg_id = GetPkgIdFromPath(path);
- }
+bool TpkAppQueryInterface::IsPkgInstalled(const std::string& arg, uid_t uid) {
+ // argument from commandline is package id
+ if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode(uid), uid))
+ return true;
+ // argument from commandline is path to file
+ std::string pkg_id = GetPkgIdFromPath(arg);
if (pkg_id.empty())
return false;
- uid_t uid = GetUid(argc, argv);
return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode(uid), uid);
}
} // namespace tpk
-
#define TPK_BACKEND_EXPORT_API
#endif
+#include <sys/types.h>
+
+#include <string>
+
#include <common/app_query_interface.h>
namespace tpk {
class TPK_BACKEND_EXPORT_API TpkAppQueryInterface
: public common_installer::AppQueryInterface {
public:
- bool IsAppInstalledByArgv(int argc, char** argv) override;
+ bool IsPkgInstalled(const std::string& arg, uid_t uid) override;
};
} // namespace tpk