if (flags & NI_FLAGS_APP_UNDER_RO_AREA) {
niDirPath = replaceAll(niDirPath, getBaseName(__pm->getAppRootPath()), __READ_ONLY_APP_UPDATE_DIR);
- _SERR("App is installed in RO area. So, create NI files in RW area(%s).", niDirPath.c_str());
- _ERR("App is installed in RO area. So, create NI files in RW area(%s).", niDirPath.c_str());
+ _SERR("App is installed in RO area. Change NI path to RW area(%s).", niDirPath.c_str());
+ _ERR("App is installed in RO area. Change NI path to RW area(%s).", niDirPath.c_str());
}
if (!isDirectory(niDirPath)) {
return getNIFilePath(concatPath(niDirPath, getFileName(absDllPath)));
}
-static bool checkNIExistence(const std::string& path)
+static bool checkNIExistence(const std::string& absDllPath, const std::string& absNIPath)
{
- std::string f = getNIFilePath(path);
- if (f.empty()) {
+ if (absNIPath.empty()) {
return false;
}
- if (isFile(f)) {
+ if (isFile(absNIPath)) {
return true;
}
// native image of System.Private.CoreLib.dll should have to overwrite
// original file to support new coreclr
- if (path.find("System.Private.CoreLib.dll") != std::string::npos) {
- std::string coreLibBackup = path + ".Backup";
+ if (absDllPath.find("System.Private.CoreLib.dll") != std::string::npos) {
+ std::string coreLibBackup = absDllPath + ".Backup";
if (isFile(coreLibBackup)) {
return true;
}
return NI_ERROR_INVALID_PARAMETER;
}
- if (checkNIExistence(dllPath)) {
- //_SERR("Already ni file is exist for %s", dllPath.c_str());
- return NI_ERROR_ALREADY_EXIST;
- }
-
std::string absDllPath = getAbsolutePath(dllPath);
std::string absNIPath;
return NI_ERROR_UNKNOWN;
}
+ if (checkNIExistence(absDllPath, absNIPath)) {
+ //_SERR("Already ni file is exist for %s", absNIPath.c_str());
+ return NI_ERROR_ALREADY_EXIST;
+ }
+
#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
uintptr_t baseAddr = 0;
return -1;
}
+ if (removeNIUnderPkgRoot(pkgId) != NI_ERROR_NONE) {
+ _SERR("Failed to remove previous dlls from [%s]", pkgId);
+ return -1;
+ }
+
if (createNIUnderPkgRoot(pkgId, *pFlags) != NI_ERROR_NONE) {
_SERR("Failed to generate NI file [%s]", pkgId);
return -1;
flags |= NI_FLAGS_APP_UNDER_RO_AREA;
} else {
flags &= ~NI_FLAGS_APP_UNDER_RO_AREA;
- ni_error_e err = removeNIUnderPkgRoot(pkgId);
- if (err != NI_ERROR_NONE) {
- _SERR("Failed to remove previous dlls from [%s]", pkgId.c_str());
- return err;
- }
}
// create native image under bin and lib directory
std::vector<std::string> paths;
splitPath(appNIPaths, paths);
for (const auto &path : paths) {
- // Only the native image inside the TAC should be removed.
- if (strstr(path.c_str(), TAC_SYMLINK_SUB_DIR) != NULL) {
- removeNIUnderDirs(path);
- } else {
- if (isDirectory(path)) {
- if (!removeAll(path.c_str())) {
- _SERR("Failed to remove app ni dir [%s]", path.c_str());
+ if (!isReadOnlyArea(path)) {
+ // Only the native image inside the TAC should be removed.
+ if (strstr(path.c_str(), TAC_SYMLINK_SUB_DIR) != NULL) {
+ removeNIUnderDirs(path);
+ } else {
+ if (isDirectory(path)) {
+ if (!removeAll(path.c_str())) {
+ _SERR("Failed to remove app ni dir [%s]", path.c_str());
+ }
}
}
}