Code review feedback
author최종헌/MDE Lab(SR)/삼성전자 <j-h.choi@samsung.com>
Wed, 3 Jan 2024 08:43:52 +0000 (17:43 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Thu, 4 Jan 2024 01:38:54 +0000 (10:38 +0900)
NativeLauncher/tool/ni_common.cc

index f897251..df98335 100644 (file)
@@ -684,6 +684,23 @@ static ni_error_e createCoreLibNI(NIOption* opt)
        return NI_ERROR_NONE;
 }
 
+static void renameAppNITmpPath(NIOption* opt)
+{
+       std::string niTmpPath = __pm->getAppRootPath() + "/bin/" + APP_NI_SUB_TMP_DIR;
+       std::string niPath = __pm->getAppRootPath() + "/bin/" + APP_NI_SUB_DIR;
+
+       if (opt->flags & NI_FLAGS_APP_UNDER_RO_AREA) {
+               niTmpPath = replaceAll(niTmpPath, getBaseName(__pm->getAppRootPath()), __READ_ONLY_APP_UPDATE_DIR);
+               niPath = replaceAll(niPath, getBaseName(__pm->getAppRootPath()), __READ_ONLY_APP_UPDATE_DIR);
+       }
+
+       if (isDirectory(niTmpPath)) {
+               if (rename(niTmpPath.c_str(), niPath.c_str())) {
+                       _SERR("Fail to rename from .native_image_tmp to .native_image");
+               }
+       }
+}
+
 static ni_error_e doAOTList(std::vector<std::string>& dllList, const std::string& refPaths, NIOption* opt)
 {
        ni_error_e ret = NI_ERROR_NONE;
@@ -777,12 +794,7 @@ static ni_error_e doAOTList(std::vector<std::string>& dllList, const std::string
                        }
                }
                if (opt->flags & NI_FLAGS_APPNI) {
-                       for (const auto &path : paths) {
-                               if (path.find("/bin") != std::string::npos) {
-                                       rename(concatPath(path, APP_NI_SUB_TMP_DIR).c_str(), concatPath(path, APP_NI_SUB_DIR).c_str());
-                                       break;
-                               }
-                       }
+                       renameAppNITmpPath(opt);
                }
        }