const char kManifestFileName[] = "tizen-manifest.xml";
-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);
- if (code)
- return {};
- if (!common_installer::ExtractToTmpDir(path.c_str(), tmp_path,
- kManifestFileName)) {
- ci::RemoveAll(tmp_path);
+} // namespace
+
+namespace tpk {
+
+std::string TpkAppQueryInterface::GetManifestFileName() const {
+ return std::string(kManifestFileName);
+}
+
+std::string TpkAppQueryInterface::GetPkgIdFromPath(
+ const std::string& path) const {
+ bf::path tmp_path = ExtractManifest(path);
+ if (tmp_path.empty())
return {};
- }
bf::path manifest_path = tmp_path / kManifestFileName;
if (!bf::exists(manifest_path)) {
ci::RemoveAll(tmp_path);
return pkg_id;
}
-} // namespace
-
-namespace tpk {
-
-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;
- return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode(uid), uid);
-}
-
-std::string TpkAppQueryInterface::GetPkgId(const std::string& arg) {
- return GetPkgIdFromPath(arg);
-}
-
} // namespace tpk
class TPK_BACKEND_EXPORT_API TpkAppQueryInterface
: public common_installer::AppQueryInterface {
- public:
- bool IsPkgInstalled(const std::string& arg, uid_t uid) override;
- std::string GetPkgId(const std::string& arg) override;
+ private:
+ std::string GetPkgIdFromPath(const std::string& path) const override;
+ std::string GetManifestFileName() const override;
};
} // namespace tpk