// found in the LICENSE file.
#include "rpk/rpk_app_query_interface.h"
+#include "rpk_manifest_handlers/rpk_config_parser.h"
+#include "rpk_manifest_handlers/package_handler.h"
#include <string>
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+namespace {
+
+const char kManifestFileName[] = "tizen-manifest.xml";
+
+const char kManifestKey[] = "manifest";
+
+} // namespace
+
namespace rpk {
std::string RpkAppQueryInterface::GetManifestFileName() const {
- return {};
+ return std::string(kManifestFileName);
}
std::string RpkAppQueryInterface::GetPkgIdFromPath(
const std::string& path) const {
- return {};
+ bf::path tmp_path = ExtractManifest(path);
+ if (tmp_path.empty())
+ return {};
+ bf::path manifest_path = tmp_path / kManifestFileName;
+ if (!bf::exists(manifest_path)) {
+ ClearTemporaryFile(tmp_path);
+ return {};
+ }
+
+ rpk::parse::RPKConfigParser parser;
+ if (!parser.ParseManifest(manifest_path)) {
+ ClearTemporaryFile(tmp_path);
+ return {};
+ }
+ auto package_info = std::static_pointer_cast<const rpk::parse::PackageInfo>(
+ parser.GetManifestData(kManifestKey));
+ if (!package_info) {
+ ClearTemporaryFile(tmp_path);
+ return {};
+ }
+ std::string pkg_id = package_info->package();
+ ClearTemporaryFile(tmp_path);
+ return pkg_id;
}
} // namespace rpk