From a7af15746516e7c690d227847b322b227bc7539b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=B5=9C=EC=A2=85=ED=97=8C/MDE=20Lab=28SR=29/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 3 Jan 2024 17:43:52 +0900 Subject: [PATCH] Code review feedback --- NativeLauncher/tool/ni_common.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index f897251..df98335 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -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& 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& 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); } } -- 2.7.4