bug-fix : support TAC and NI_SUB_DIR for nitool --pkg-dll option
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / ni_common.cc
index d2b7ec3..666f752 100644 (file)
@@ -108,15 +108,20 @@ static std::string getNiFilePath(const std::string& dllPath)
 
 static std::string getAppNIPath(const std::string& niPath)
 {
+       std::string fileName;
+       std::string niDirPath;
+       std::string prevPath;
+
        size_t index = niPath.find_last_of("/");
-       if (index == std::string::npos) {
-               fprintf(stderr, "dllPath doesnot contains path info\n");
-               return "";
+       if (index != std::string::npos) {
+               prevPath = niPath.substr(0, index);
+               fileName = niPath.substr(index + 1, niPath.length());
+       } else {
+               prevPath = ".";
+               fileName = niPath;
        }
 
-       std::string prevPath = niPath.substr(0, index);
-       std::string fileName = niPath.substr(index, niPath.length());
-       std::string niDirPath = prevPath + APP_NI_SUB_DIR;
+       niDirPath = concatPath(prevPath, APP_NI_SUB_DIR);
 
        if (!isFileExist(niDirPath)) {
                if (mkdir(niDirPath.c_str(), 0755) == 0) {
@@ -126,7 +131,7 @@ static std::string getAppNIPath(const std::string& niPath)
                }
        }
 
-       return niDirPath + fileName;
+       return concatPath(niDirPath, fileName);
 }
 
 static bool niExist(const std::string& path)
@@ -235,40 +240,6 @@ static ni_error_e crossgen(const std::string& dllPath, const std::string& appPat
        return NI_ERROR_NONE;
 }
 
-static ni_error_e getRootPath(std::string pkgId, std::string& rootPath)
-{
-       int ret = 0;
-       char *path = 0;
-
-       uid_t uid = 0;
-
-       if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
-               _ERR("Failed to get UID");
-               return NI_ERROR_UNKNOWN;
-       }
-
-       pkgmgrinfo_pkginfo_h handle;
-       if (uid == 0) {
-               ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgId.c_str(), &handle);
-               if (ret != PMINFO_R_OK)
-                       return NI_ERROR_UNKNOWN;
-       } else {
-               ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgId.c_str(), uid, &handle);
-               if (ret != PMINFO_R_OK)
-                       return NI_ERROR_UNKNOWN;
-       }
-
-       ret = pkgmgrinfo_pkginfo_get_root_path(handle, &path);
-       if (ret != PMINFO_R_OK) {
-               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-               return NI_ERROR_UNKNOWN;
-       }
-       rootPath = path;
-       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-
-       return NI_ERROR_NONE;
-}
-
 // callback function of "pkgmgrinfo_appinfo_metadata_filter_foreach"
 static int appAotCb(pkgmgrinfo_appinfo_h handle, void *userData)
 {
@@ -428,7 +399,8 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string&
 
        std::string binDir = concatPath(pkgRoot, "bin");
        std::string libDir = concatPath(pkgRoot, "lib");
-       std::string paths = binDir + ":" + libDir;
+       std::string appTAC = concatPath(binDir, ".TAC.Release");
+       std::string paths = binDir + ":" + libDir + ":" + appTAC;
 
        return crossgen(dllPath, paths, enableR2R, true);
 }
@@ -483,14 +455,14 @@ ni_error_e removeNiUnderPkgRoot(const std::string& pkgId)
 
        removeNiUnderDirs(paths, 2);
 
-       std::string binNIDir = binDir + APP_NI_SUB_DIR;
+       std::string binNIDir = concatPath(binDir, APP_NI_SUB_DIR);
        if (isFileExist(binNIDir)) {
                if (rmdir(binNIDir.c_str()) != 0) {
                        fprintf(stderr, "Failed to remove app ni dir [%s]\n", binNIDir.c_str());
                }
        }
 
-       std::string libNIDir = libDir + APP_NI_SUB_DIR;
+       std::string libNIDir = concatPath(libDir, APP_NI_SUB_DIR);
        if (isFileExist(libNIDir)) {
                if (rmdir(libNIDir.c_str()) != 0) {
                        fprintf(stderr, "Failed to remove app ni dir [%s]\n", libNIDir.c_str());