/**
* @brief create the directory including parents directory, and
- * copy ownership and smack labels to the created directory.
+ * copy ownership and smack labels to the created directory.
* @param[in] target directory path
* @param[in] source directory path to get ownership and smack label
* @return if directory created successfully, return true otherwise false
}
}
+ if (opt->flags & NI_FLAGS_RM_ORIGIN_AFTER_NI) {
+ if (!removeFile(dllPath)) {
+ _SERR("Fail to remove original file : %s", dllPath.c_str());
+ }
+ }
+
if (!(opt->flags & NI_FLAGS_INPUT_BUBBLE && opt->flags & NI_FLAGS_NO_PIPELINE)) {
_SOUT("Native image %s generated successfully.", outFile.c_str());
}
if (!isFile(coreLibBackup) && !isR2RImage(coreLib)) {
if (crossgen2NoPipeLine(dllList, refPaths, opt) == NI_ERROR_NONE) {
- if (rename(coreLib.c_str(), coreLibBackup.c_str())) {
+ if (opt->flags & NI_FLAGS_RM_ORIGIN_AFTER_NI) {
+ std::ofstream output(coreLibBackup);
+ if (!exist(coreLibBackup)) {
+ _SERR("Failed to create System.Private.CoreLib.dll.Backup");
+ return NI_ERROR_CORE_NI_FILE;
+ }
+ copySmackAndOwnership(__pm->getRuntimePath(), coreLibBackup, false);
+ output.close();
+ } else if (rename(coreLib.c_str(), coreLibBackup.c_str())) {
_SERR("Failed to rename from System.Private.CoreLib.dll to System.Private.CoreLib.dll.Backup");
return NI_ERROR_CORE_NI_FILE;
}
std::string coreLib = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll");
bool hasSPC = false;
- std::vector<std::string> niList;
for (auto it = dllList.begin(); it != dllList.end(); it++) {
std::string f = *it;
if (!isFile(f)) {
_SERR("dll file is not exist : %s", f.c_str());
dllList.erase(it--);
}
- if (!isManagedAssembly(f)) {
+ else if (!isManagedAssembly(f)) {
_SERR("Input file is not a dll file : %s", f.c_str());
dllList.erase(it--);
}
// handle System.Private.CoreLib.dll separately.
// dllList and path manager contain absolute path. So, there is no need to change path to absolute path
- if (f == coreLib) {
+ else if (f == coreLib) {
hasSPC = true;
dllList.erase(it--);
- } else {
- niList.push_back(changeExtension(f, ".dll", ".ni.dll"));
}
}
{
auto convert = [](const std::string& path, const std::string& filename) {
if (isNativeImage(path)) {
- if (remove(path.c_str())) {
- _SERR("Failed to remove %s", path.c_str());
+ std::string assemblyPath = changeExtension(path, ".ni.dll", ".dll");
+ if (exist(assemblyPath)) {
+ if (remove(path.c_str())) {
+ _SERR("Failed to remove %s", path.c_str());
+ }
+ } else {
+ _SOUT("%s cannot be removed because there is no %s", path.c_str(), assemblyPath.c_str());
}
}
};