#include <pkgmgr-info.h>
#include <tzplatform_config.h>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include <string>
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
namespace common_installer {
-bf::path GetManifestLocation(const std::string& pkgid,
+fs::path GetManifestLocation(const std::string& pkgid,
uid_t uid,
bool is_readonly) {
PkgQueryInterface pkg_query(pkgid, uid);
uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
is_readonly = pkg_query.IsReadonlyPackage();
}
- bf::path xml_path = bf::path(getUserManifestPath(uid, is_readonly))
- / bf::path(pkgid.c_str());
+ fs::path xml_path = fs::path(getUserManifestPath(uid, is_readonly))
+ / fs::path(pkgid.c_str());
xml_path += ".xml";
return xml_path;
}
-int PkgmgrGenerateManifestInfoFromDB(manifest_x* mfx,
- const std::string &pkgid,
- uid_t uid) {
+manifest_x* PkgmgrGenerateManifestInfoFromDB(const std::string &pkgid,
+ uid_t uid) {
pkgmgrinfo_appinfo_filter_h filter;
- mfx->package = strdup(pkgid.c_str());
-
if (pkgmgrinfo_appinfo_filter_create(&filter))
- return PMINFO_R_ERROR;
+ return nullptr;
if (pkgmgrinfo_appinfo_filter_add_string(filter,
PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid.c_str())) {
pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
+ return nullptr;
}
+ manifest_x* mfx = static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
+ if (!mfx) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ LOG(ERROR) << "Out of memory";
+ return nullptr;
+ }
if (pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(filter,
PkgmgrAppInfoCallback,
mfx, uid)) {
+ pkgmgr_parser_free_manifest_xml(mfx);
pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
+ return nullptr;
}
+ mfx->package = strdup(pkgid.c_str());
pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_OK;
+ return mfx;
}
} // namespace common_installer