std::string getMetadataValue(const std::string& pkgId, const std::string& key);
/**
+ * @brief change the extension of a path or file
+ * @param[in] source path or file
+ * @param[in] from extension
+ * @param[in] to extension
+ * @return std::string path or file with changed extension
+ */
+std::string changeExtension(const std::string& path, const std::string& from, const std::string& to);
+
+/**
* @brief check the package is 'readonly' or not
* @param[in] package id
* @return bool package readonly value
}
// if there is symlink and original file for native image, skip generation
- std::string symNIPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
+ std::string symNIPath = changeExtension(symPath, "dll", "ni.dll");
if (isFile(symNIPath)) {
continue;
}
// if original native image not exist, generate native image
std::string originPath = bf::read_symlink(symPath).string();
- std::string originNIPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
+ std::string originNIPath = changeExtension(originPath, "dll", "ni.dll");
if (!isFile(originNIPath)) {
if (!crossgen(originPath, path.c_str(), flags)) {
waitInterval();
for (auto& originPath : enableNuget) {
if (exist(originPath)) {
std::string fileName = originPath.substr(originPath.rfind('/') + 1);
- std::string NIFileName = fileName.substr(0, fileName.rfind(".dll")) + ".ni.dll";
+ std::string NIFileName = changeExtension(fileName, "dll", "ni.dll");
if (exist(binNIDir)) {
- std::string originNIPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
+ std::string originNIPath = changeExtension(originPath, "dll", "ni.dll");
if (exist(originNIPath)) {
bf::create_symlink(originNIPath, concatPath(tacDir, NIFileName));
fprintf(stdout, "%s symbolic link file generated successfully.\n", concatPath(tacDir, NIFileName).c_str());
std::vector<std::string> depsJsonParser(const std::string& rootPath, const std::string& execName)
{
std::vector<std::string> parserData;
- std::string depsJsonName = execName.substr(0, execName.rfind(".dll")) + ".deps.json";
+ std::string depsJsonName = changeExtension(execName, "dll", "deps.json");
std::string depsJsonPath = concatPath(rootPath, depsJsonName);
try {
if (exist(depsJsonPath)) {
return result;
}
+std::string changeExtension(const std::string& path, const std::string& from, const std::string& to)
+{
+ return path.substr(0, path.rfind(from)) + to;
+}
+
bool isFile(const std::string& path)
{
struct stat sb;