typedef int (*coreclr_preload_assembly_ptr)(const char* assemblyPath);
typedef int (*launcher_real_main_ptr)(int argc, char *argv[], const char* mode);
-static std::string absolutePath(const std::string& path)
+static std::string getAbsolutePath(const std::string& path)
{
std::string absPath;
char *realPath = realpath(path.c_str(), NULL);
return absPath;
}
-static bool isFileExist(const std::string& path)
+static bool isFile(const std::string& path)
{
struct stat sb;
return stat(path.c_str(), &sb) == 0;
// check whether the target file exist under netcoreapp directory
result = netcoreappDir + filename;
- if (isFileExist(result)) {
+ if (isFile(result)) {
return result;
}
// check whether the target file exist under framework directory
result = frameworkDir + filename;
- if (isFileExist(result)) {
+ if (isFile(result)) {
return result;
}
// check whether the target file exist under netcoreapp directory
std::string path = findDllPath(in_line);
if (!path.empty()) {
- int st = preloadAssembly(absolutePath(path).c_str());
+ int st = preloadAssembly(getAbsolutePath(path).c_str());
if (st != 0) {
_ERR("preload of %s failed! (0x%08x)", path.c_str(), st);
} else {
/**
* @brief : structure which contains base directory info
*/
-typedef struct NiCommonOption {
+typedef struct NICommonOption {
std::string runtimeDir; /**< .NETCore Runtime directory */
std::string tizenFXDir; /**< TizenFX directory */
std::string extraDirs; /**< ":" seperated directories which can be set by plugins */
-} NiCommonOption;
+} NICommonOption;
/**
* @brief initialize NICommon
* @param[i] options base directory info
* @return ni_error_e 0 on success, otherwise a negative error value
*/
-ni_error_e initNICommon(NiCommonOption* option);
+ni_error_e initNICommon(NICommonOption* option);
/**
* @brief finalize NICommon
* @param[i] flags additional flags for the image generator
* @return ni_error_e
*/
-ni_error_e createNiPlatform(DWORD flags);
+ni_error_e createNIPlatform(DWORD flags);
/**
* @brief create a native image for a single DLL
* @param[i] flags additional flags for the image generator
* @return ni_error_e
*/
-ni_error_e createNiDll(const std::string& dllPath, DWORD flags);
+ni_error_e createNIDll(const std::string& dllPath, DWORD flags);
/**
* @brief create native images for TAC DLLs
* @param[i] count length of rootPaths
* @param[i] flags additional flags for the image generator
*/
-void createNiUnderTAC(const std::string rootPaths[], int count, DWORD flags);
+void createNIUnderTAC(const std::string rootPaths[], int count, DWORD flags);
/**
* @brief creates a symbolic link file, the native image of TAC for specific package.
* @param[i] flags additional flags for the image generator
* @return ni_error_e
*/
-ni_error_e createNiUnderDirs(const std::string rootPaths[], int count, DWORD flags);
+ni_error_e createNIUnderDirs(const std::string rootPaths[], int count, DWORD flags);
/**
* @brief create native images for all DLLs in a package
* @param[i] flags additional flags for the image generator
* @return ni_error_e
*/
-ni_error_e createNiUnderPkgRoot(const std::string& pkgId, DWORD flags);
+ni_error_e createNIUnderPkgRoot(const std::string& pkgId, DWORD flags);
/**
* @brief create a native image for a single dll in a package
* @param[i] flags additional flags for the image generator
* @return ni_error_e
*/
-ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, DWORD flags);
+ni_error_e createNIDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, DWORD flags);
/**
* @brief remove platform native images (.NETCore + TizenFX)
*/
-void removeNiPlatform();
+void removeNIPlatform();
/**
* @brief remove native images under directories
* @param[i] rootPaths paths to directories
* @param[i] count length of rootPaths
*/
-void removeNiUnderDirs(const std::string rootPaths[], int count);
+void removeNIUnderDirs(const std::string rootPaths[], int count);
/**
* @brief remove native images of a package
* @param[i] pkgId package ID
* @return ni_error_e
*/
-ni_error_e removeNiUnderPkgRoot(const std::string& pkgId);
+ni_error_e removeNIUnderPkgRoot(const std::string& pkgId);
/**
* @brief regenerate native images of all installed applications
std::string concatPath(const std::string& path1, const std::string& path2);
/**
- * @brief get absolute Path
+ * @brief get canonicalized absolute Path
* @param[in] source path
* return std::string result path
*/
-std::string absolutePath(const std::string& path);
+std::string getAbsolutePath(const std::string& path);
/**
* @brief get the directory of file
* @param[in] source path
* return std::string result path
*/
-std::string baseName(const std::string& path);
+std::string getBaseName(const std::string& path);
/**
* @brief replaces all matching substrings of the regular expression with a given replacement
void splitPath(const std::string& path, std::vector<std::string>& out);
/**
- * @brief check file is exist
+ * @brief check file exists
* @param[in] source path
* @return bool
*/
-bool isFileExist(const std::string& path);
+bool isFile(const std::string& path);
/**
- * @brief check directory is exist
+ * @brief check directory exists
* @param[in] source path
* @return bool
*/
-bool isDirectoryExist(const std::string& path);
+bool isDirectory(const std::string& path);
/**
* @brief get file size
}
if (mdValue) {
- NiCommonOption option = {std::string(), std::string(), std::string()};
+ NICommonOption option = {std::string(), std::string(), std::string()};
if (initNICommon(&option) < 0) {
_ERR("Fail to initialize NI Common");
return -1;
}
- if (createNiUnderPkgRoot(pkgId, 0) != NI_ERROR_NONE) {
+ if (createNIUnderPkgRoot(pkgId, 0) != NI_ERROR_NONE) {
_ERR("Failed to get root path from [%s]", pkgId);
return -1;
} else {
std::string symPath = symlinkAssembly.path().string();
if (!isNativeImage(symPath)) {
std::string originPath = bf::read_symlink(symPath).string();
- std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
- if (!bf::exists(originNiPath)) {
- if(createNiDllUnderPkgRoot(pkgId, originPath, 0) != NI_ERROR_NONE) {
+ std::string originNIPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
+ if (!bf::exists(originNIPath)) {
+ if(createNIDllUnderPkgRoot(pkgId, originPath, 0) != NI_ERROR_NONE) {
_ERR("Failed to create NI file [%s]", originPath.c_str());
return -1;
}
}
- std::string setNiPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
- if (!bf::exists(setNiPath)) {
- bf::create_symlink(originNiPath, setNiPath);
- _INFO("%s symbolic link file generated successfully.", setNiPath.c_str());
- if (lchown(setNiPath.c_str(), g_uid, g_gid)) {
- _ERR("Failed to change owner of: %s", setNiPath.c_str());
+ std::string setNIPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
+ if (!bf::exists(setNIPath)) {
+ bf::create_symlink(originNIPath, setNIPath);
+ _INFO("%s symbolic link file generated successfully.", setNIPath.c_str());
+ if (lchown(setNIPath.c_str(), g_uid, g_gid)) {
+ _ERR("Failed to change owner of: %s", setNIPath.c_str());
return -1;
}
}
argc--;
argv++;
} else if (arg == "--additionalprobingpath" && argc > 1) {
- additionalProbingPath = absolutePath(argv[1]);
+ additionalProbingPath = getAbsolutePath(argv[1]);
argc--;
argv++;
} else if (arg == "--globalizationinvariant") {
DisplayUsage();
return -1;
} else if (isManagedAssembly(arg) || isNativeImage(arg)) {
- if (!isFileExist(arg)) {
+ if (!isFile(arg)) {
fprintf(stderr, "The specified file does not exist.\n");
return -1;
}
} else {
managedAssemblyPath = toolDllsPath + "/dotnet-" + arg + ".dll";
- if (!isFileExist(managedAssemblyPath)) {
+ if (!isFile(managedAssemblyPath)) {
fprintf(stderr,
"Could not execute because dotnet-%s does not exist.\n"
"Go to https://developer.samsung.com/tizen to learn how to install tools.\n\n", argv[0]);
argv++;
}
- std::string currentExeAbsolutePath = absolutePath("/proc/self/exe");
+ std::string currentExeAbsolutePath = getAbsolutePath("/proc/self/exe");
if (currentExeAbsolutePath.empty()) {
fprintf(stderr, "Failed to get the current executable's absolute path.\n");
return -1;
}
- std::string clrFilesAbsolutePath = absolutePath(clrFilesPath);
+ std::string clrFilesAbsolutePath = getAbsolutePath(clrFilesPath);
if (clrFilesAbsolutePath.empty()) {
fprintf(stderr, "Failed to resolve the full path to the CLR files.\n");
return -1;
}
- std::string managedAssemblyAbsolutePath = absolutePath(managedAssemblyPath);
+ std::string managedAssemblyAbsolutePath = getAbsolutePath(managedAssemblyPath);
if (managedAssemblyAbsolutePath.empty()) {
fprintf(stderr, "Failed to get the managed assembly's absolute path.\n");
return -1;
}
std::string coreclrLibPath(clrFilesAbsolutePath + "/libcoreclr.so");
- std::string appPath = baseName(managedAssemblyAbsolutePath);
+ std::string appPath = getBaseName(managedAssemblyAbsolutePath);
std::string nativeDllSearchDirs(appPath);
nativeDllSearchDirs += ":" + additionalProbingPath;
nativeDllSearchDirs += ":" + clrFilesAbsolutePath;
return -1;
}
- if (!isFileExist(path)) {
+ if (!isFile(path)) {
_ERR("File not exist : %s", path);
return -1;
}
return -1;
}
- NiCommonOption option = {std::string(), std::string(), std::string()};
+ NICommonOption option = {std::string(), std::string(), std::string()};
if (initNICommon(&option) != NI_ERROR_NONE) {
return -1;
}
it = args.erase(it);
std::string ibcFilePath = std::string(*it);
- if (!isDirectoryExist(ibcFilePath)) {
+ if (!isDirectory(ibcFilePath)) {
fprintf(stderr, "IBC path is missing or not exist\n");
return -1;
}
//sh-3.2# dotnettool --ni-system
if (cmd == "--ni-system") {
- int ret = createNiPlatform(flags);
+ int ret = createNIPlatform(flags);
if (ret != NI_ERROR_NONE) {
fprintf(stderr, "Failed to generate system NI\n");
}
}
while (it != args.end()) {
std::string dll = std::string(*it);
- int ret = createNiDll(dll, flags);
+ int ret = createNIDll(dll, flags);
if (ret != NI_ERROR_NONE) {
fprintf(stderr, "Failed to generate NI file [%s]\n", dll.c_str());
break;
while (it != args.end()) {
std::string pkg = std::string(*it);
// if there is AOTed dlls under package root, that is skiped.
- int ret = createNiUnderPkgRoot(pkg, flags);
+ int ret = createNIUnderPkgRoot(pkg, flags);
if (ret != NI_ERROR_NONE) {
fprintf(stderr, "Failed to generate NI file [%s]\n", pkg.c_str());
break;
it = args.erase(it);
while (it != args.end()) {
std::string dll = std::string(*it);
- int ret = createNiDllUnderPkgRoot(pkg, dll, flags);
+ int ret = createNIDllUnderPkgRoot(pkg, dll, flags);
if (ret != NI_ERROR_NONE) {
fprintf(stderr, "Failed to generate NI file [%s]\n", dll.c_str());
break;
}
while (it != args.end()) {
const std::string dir[] = {std::string(*it)};
- int ret = createNiUnderDirs(dir, 1, flags);
+ int ret = createNIUnderDirs(dir, 1, flags);
if (ret != NI_ERROR_NONE) {
fprintf(stderr, "Failed to generate NI directory\n");
break;
}
//sh-3.2# dotnettool --ni-reset-system
else if (cmd == "--ni-reset-system") {
- removeNiPlatform();
+ removeNIPlatform();
}
//sh-3.2# dotnettool --ni-reset-pkg [pkgId] [pkgId] ...
else if (cmd == "--ni-reset-pkg") {
}
while (it != args.end()) {
std::string pkg = std::string(*it);
- int ret = removeNiUnderPkgRoot(pkg);
+ int ret = removeNIUnderPkgRoot(pkg);
if (ret != NI_ERROR_NONE) {
fprintf(stderr, "Failed to remove dlls for given package [%s]\n", pkg.c_str());
break;
}
while (it != args.end()) {
const std::string dir[] = {std::string(*it)};
- removeNiUnderDirs(dir, 1);
+ removeNIUnderDirs(dir, 1);
it = args.erase(it);
}
}
}
}
-static std::string getNiFilePath(const std::string& dllPath)
+static std::string getNIFilePath(const std::string& dllPath)
{
size_t index = dllPath.find_last_of(".");
if (index == std::string::npos) {
niDirPath = concatPath(prevPath, APP_NI_SUB_DIR);
- if (!isFileExist(niDirPath)) {
+ if (!isFile(niDirPath)) {
if (mkdir(niDirPath.c_str(), 0755) == 0) {
copySmackAndOwnership(prevPath, niDirPath);
} else {
return concatPath(niDirPath, fileName);
}
-static bool niExist(const std::string& path)
+static bool checkNIExistence(const std::string& path)
{
- std::string f = getNiFilePath(path);
+ std::string f = getNIFilePath(path);
if (f.empty()) {
return false;
}
- if (isFileExist(f)) {
+ if (isFile(f)) {
return true;
}
// original file to support new coreclr
if (path.find("System.Private.CoreLib.dll") != std::string::npos) {
std::string coreLibBackup = path + ".Backup";
- if (isFileExist(coreLibBackup)) {
+ if (isFile(coreLibBackup)) {
return true;
}
}
{
uintptr_t baseAddr = 0;
- if (!isFileExist(__SYSTEM_BASE_FILE)) {
+ if (!isFile(__SYSTEM_BASE_FILE)) {
// This is the starting address for all default base addresses
baseAddr = DEFAULT_BASE_ADDR_START;
} else {
}
// Save base address of system ni image to file
-static void updateBaseAddrFile(const std::string &absNiPath, uintptr_t baseAddr)
+static void updateBaseAddrFile(const std::string &absNIPath, uintptr_t baseAddr)
{
- uintptr_t niSize = getFileSize(absNiPath);
+ uintptr_t niSize = getFileSize(absNIPath);
if (niSize == 0) {
- fprintf(stderr, "File %s doesn't exist\n", absNiPath.c_str());
+ fprintf(stderr, "File %s doesn't exist\n", absNIPath.c_str());
return;
}
// check if dll is listed in TPA
static bool isTPADll(const std::string &dllPath)
{
- std::string absDllPath = absolutePath(dllPath);
+ std::string absDllPath = getAbsolutePath(dllPath);
if (__tpa.find(absDllPath) != std::string::npos) {
return true;
// baseAddr should be checked in file before getting here
static ni_error_e crossgen(const std::string& dllPath, const std::string& appPath, DWORD flags)
{
- if (!isFileExist(dllPath)) {
+ if (!isFile(dllPath)) {
fprintf(stderr, "dll file is not exist : %s\n", dllPath.c_str());
return NI_ERROR_NO_SUCH_FILE;
}
return NI_ERROR_INVALID_PARAMETER;
}
- if (niExist(dllPath)) {
+ if (checkNIExistence(dllPath)) {
fprintf(stderr, "Already ni file is exist for %s\n", dllPath.c_str());
return NI_ERROR_ALREADY_EXIST;
}
- std::string absDllPath = absolutePath(dllPath);
- std::string absNiPath = getNiFilePath(dllPath);
+ std::string absDllPath = getAbsolutePath(dllPath);
+ std::string absNIPath = getNIFilePath(dllPath);
- if (absNiPath.empty()) {
+ if (absNIPath.empty()) {
fprintf(stderr, "Fail to get ni file name\n");
return NI_ERROR_UNKNOWN;
}
bool isAppNI = flags & NI_FLAGS_APPNI;
- if (isAppNI && strstr(absNiPath.c_str(), __DOTNET_DIR) == NULL) {
- absNiPath = getAppNIPath(absNiPath);
+ if (isAppNI && strstr(absNIPath.c_str(), __DOTNET_DIR) == NULL) {
+ absNIPath = getAppNIPath(absNIPath);
}
#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
int status;
waitpid(pid, &status, 0);
if (WIFEXITED(status)) {
- // Do not use niExist() function to check whether ni file created or not.
- // niEixst() return false for System.Private.Corelib.dll
- if (isFileExist(absNiPath)) {
- copySmackAndOwnership(absDllPath, absNiPath);
+ // Do not use checkNIExistence() function to check whether ni file created or not.
+ // checkNIExistence() return false for System.Private.Corelib.dll
+ if (isFile(absNIPath)) {
+ copySmackAndOwnership(absDllPath, absNIPath);
std::string absPdbPath = replaceAll(absDllPath, ".dll", ".pdb");
- std::string pdbFilePath = replaceAll(absNiPath, ".ni.dll", ".pdb");
- if (isFileExist(absPdbPath) && (absPdbPath != pdbFilePath)) {
+ std::string pdbFilePath = replaceAll(absNIPath, ".ni.dll", ".pdb");
+ if (isFile(absPdbPath) && (absPdbPath != pdbFilePath)) {
if (!copyFile(absPdbPath, pdbFilePath)) {
fprintf(stderr, "Failed to copy a .pdb file\n");
} else {
}
#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
if (baseAddr != 0) {
- updateBaseAddrFile(absNiPath, baseAddr);
+ updateBaseAddrFile(absNIPath, baseAddr);
}
#endif
return NI_ERROR_NONE;
if (!appPath.empty()) {
absAppPath = appPath;
} else {
- absAppPath = baseName(absDllPath);
+ absAppPath = getBaseName(absDllPath);
}
argv.push_back(absAppPath.c_str());
argv.push_back("/out");
- argv.push_back(absNiPath.c_str());
+ argv.push_back(absNIPath.c_str());
argv.push_back(absDllPath.c_str());
argv.push_back(nullptr);
return -1;
}
- if (removeNiUnderPkgRoot(pkgId) != NI_ERROR_NONE) {
+ if (removeNIUnderPkgRoot(pkgId) != NI_ERROR_NONE) {
fprintf(stderr, "Failed to remove previous dlls from [%s]\n", pkgId);
return -1;
}
}
// Regenerate ni files with R2R mode forcibiliy. (there is no way to now which option is used)
- if (createNiUnderPkgRoot(pkgId, *pFlags) != NI_ERROR_NONE) {
+ if (createNIUnderPkgRoot(pkgId, *pFlags) != NI_ERROR_NONE) {
fprintf(stderr, "Failed to generate NI file [%s]\n", pkgId);
return -1;
} else {
}
std::string coreLibBackup = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll.Backup");
- if (isFileExist(coreLibBackup)) {
+ if (isFile(coreLibBackup)) {
return true;
} else {
fprintf(stderr, "The native image of System.Private.CoreLib does not exist\n"
std::string niCoreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.ni.dll");
std::string coreLibBackup = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll.Backup");
- if (!isFileExist(coreLibBackup)) {
+ if (!isFile(coreLibBackup)) {
if (!crossgen(coreLib, std::string(), flags)) {
if (rename(coreLib.c_str(), coreLibBackup.c_str())) {
fprintf(stderr, "Failed to rename System.Private.CoreLib.dll\n");
return NI_ERROR_NONE;
}
-ni_error_e initNICommon(NiCommonOption* option)
+ni_error_e initNICommon(NICommonOption* option)
{
#if defined(__arm__)
// get interval value
}
-ni_error_e createNiPlatform(DWORD flags)
+ni_error_e createNIPlatform(DWORD flags)
{
if (createCoreLibNI(flags) != NI_ERROR_NONE) {
return NI_ERROR_CORE_NI_FILE;
}
const std::string platformDirs[] = {getRuntimeDir(), getTizenFXDir()};
- return createNiUnderDirs(platformDirs, 2, flags);
+ return createNIUnderDirs(platformDirs, 2, flags);
}
-ni_error_e createNiDll(const std::string& dllPath, DWORD flags)
+ni_error_e createNIDll(const std::string& dllPath, DWORD flags)
{
if (dllPath.find("System.Private.CoreLib.dll") != std::string::npos) {
return createCoreLibNI(flags);
return crossgen(dllPath, std::string(), flags);
}
-void createNiUnderTAC(std::vector<std::string> nugets, DWORD flags)
+void createNIUnderTAC(std::vector<std::string> nugets, DWORD flags)
{
std::string appPaths;
for (auto& nuget : nugets) {
if (bf::is_symlink(symPath)) {
if (!isNativeImage(symPath)) {
std::string originPath = bf::read_symlink(symPath).string();
- std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
- if (!bf::exists(originNiPath)) {
+ std::string originNIPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
+ if (!bf::exists(originNIPath)) {
flags |= NI_FLAGS_APPNI;
if(crossgen(originPath, paths, flags) != NI_ERROR_NONE) {
fprintf(stderr, "Failed to create NI file [%s]\n", originPath.c_str());
}
std::string symNIPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
if (!bf::exists(symNIPath)) {
- bf::create_symlink(originNiPath, symNIPath);
+ bf::create_symlink(originNIPath, symNIPath);
fprintf(stdout, "%s symbolic link file generated successfully.\n", symNIPath.c_str());
copySmackAndOwnership(tacDir.c_str(), symNIPath.c_str(), true);
return NI_ERROR_NONE;
}
-ni_error_e createNiUnderDirs(const std::string rootPaths[], int count, DWORD flags)
+ni_error_e createNIUnderDirs(const std::string rootPaths[], int count, DWORD flags)
{
if (!isCoreLibPrepared(flags)) {
return NI_ERROR_CORE_NI_FILE;
return NI_ERROR_NONE;
}
-ni_error_e createNiUnderPkgRoot(const std::string& pkgId, DWORD flags)
+ni_error_e createNIUnderPkgRoot(const std::string& pkgId, DWORD flags)
{
std::string pkgRoot;
if (getRootPath(pkgId, pkgRoot) < 0) {
std::string paths[] = {binDir, libDir, tacDir};
flags |= NI_FLAGS_APPNI;
- return createNiUnderDirs(paths, 3, flags);
+ return createNIUnderDirs(paths, 3, flags);
}
-ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, DWORD flags)
+ni_error_e createNIDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, DWORD flags)
{
if (!isCoreLibPrepared(flags)) {
return NI_ERROR_CORE_NI_FILE;
if (bf::exists(tacDir)) {
if (!isNativeImage(dllPath)) {
std::string originPath = bf::read_symlink(dllPath).string();
- std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
- if (!bf::exists(originNiPath)) {
+ std::string originNIPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
+ if (!bf::exists(originNIPath)) {
flags |= NI_FLAGS_APPNI;
if(crossgen(originPath, paths, flags) != NI_ERROR_NONE) {
fprintf(stderr, "Failed to create NI file [%s]\n", originPath.c_str());
return NI_ERROR_UNKNOWN;
}
}
- std::string setNiPath = dllPath.substr(0, dllPath.rfind(".dll")) + ".ni.dll";
- if (!bf::exists(setNiPath)) {
- bf::create_symlink(originNiPath, setNiPath);
- fprintf(stdout, "%s symbolic link file generated successfully.\n", setNiPath.c_str());
- copySmackAndOwnership(tacDir.c_str(), setNiPath.c_str(), true);
+ std::string setNIPath = dllPath.substr(0, dllPath.rfind(".dll")) + ".ni.dll";
+ if (!bf::exists(setNIPath)) {
+ bf::create_symlink(originNIPath, setNIPath);
+ fprintf(stdout, "%s symbolic link file generated successfully.\n", setNIPath.c_str());
+ copySmackAndOwnership(tacDir.c_str(), setNIPath.c_str(), true);
}
- std::string niFileName = setNiPath.substr(setNiPath.rfind('/') + 1);
+ std::string niFileName = setNIPath.substr(setNIPath.rfind('/') + 1);
if (!removeFile(concatPath(binNIDir, niFileName))) {
fprintf(stderr, "Failed to remove of %s\n", concatPath(binNIDir, niFileName).c_str());
}
}
}
-void removeNiPlatform()
+void removeNIPlatform()
{
std::string coreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll");
std::string coreLibBackup = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll.Backup");
- if (!isFileExist(coreLibBackup)) {
+ if (!isFile(coreLibBackup)) {
return;
}
#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
- if (isFileExist(__SYSTEM_BASE_FILE)) {
+ if (isFile(__SYSTEM_BASE_FILE)) {
if (remove(__SYSTEM_BASE_FILE)) {
fprintf(stderr, "Failed to remove %s\n", __SYSTEM_BASE_FILE);
}
const std::string platformDirs[] = {getRuntimeDir(), getTizenFXDir()};
- removeNiUnderDirs(platformDirs, 2);
+ removeNIUnderDirs(platformDirs, 2);
}
-void removeNiUnderDirs(const std::string rootPaths[], int count)
+void removeNIUnderDirs(const std::string rootPaths[], int count)
{
auto convert = [](const std::string& path, const std::string& filename) {
if (isNativeImage(path)) {
}
}
-ni_error_e removeNiUnderPkgRoot(const std::string& pkgId)
+ni_error_e removeNIUnderPkgRoot(const std::string& pkgId)
{
std::string pkgRoot;
if (getRootPath(pkgId, pkgRoot) < 0) {
std::string libDir = concatPath(pkgRoot, "lib");
std::string paths[] = {binDir, libDir};
- removeNiUnderDirs(paths, 2);
+ removeNIUnderDirs(paths, 2);
std::string binNIDir = concatPath(binDir, APP_NI_SUB_DIR);
- if (isFileExist(binNIDir)) {
+ if (isFile(binNIDir)) {
if (!removeAll(binNIDir.c_str())) {
fprintf(stderr, "Failed to remove app ni dir [%s]\n", binNIDir.c_str());
}
}
std::string libNIDir = concatPath(libDir, APP_NI_SUB_DIR);
- if (isFileExist(libNIDir)) {
+ if (isFile(libNIDir)) {
if (!removeAll(libNIDir.c_str())) {
fprintf(stderr, "Failed to remove app ni dir [%s]\n", libNIDir.c_str());
}
tac_db = NULL;
}
- createNiUnderTAC(nugets, *pFlags);
+ createNIUnderTAC(nugets, *pFlags);
return 0;
}
}
const std::string tacDir[] = {__DOTNET_DIR};
- removeNiUnderDirs(tacDir, 1);
+ removeNIUnderDirs(tacDir, 1);
pkgmgrinfo_appinfo_metadata_filter_h handle;
int ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
bool rmPkgMode = false;
bool pkgDllMode = false;
- NiCommonOption option = {std::string(), std::string(), std::string()};
+ NICommonOption option = {std::string(), std::string(), std::string()};
if (initNICommon(&option) != NI_ERROR_NONE) {
return -1;
}
help(argv[0]);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--system")) {
- createNiPlatform(flags);
+ createNIPlatform(flags);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--dll")) {
dllMode = true;
} else if (cmdOptionExists(argv, argv+argc, "--dir")) {
dirMode = true;
} else if (cmdOptionExists(argv, argv+argc, "--reset-system")) {
- removeNiPlatform();
+ removeNIPlatform();
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--reset-pkg")) {
rmPkgMode = true;
if (pkgMode) {
for (const std::string pkg : args) {
// if there is AOTed dlls under package root, that is skiped.
- int ret = createNiUnderPkgRoot(pkg, flags);
+ int ret = createNIUnderPkgRoot(pkg, flags);
if (ret == NI_ERROR_INVALID_PACKAGE) {
fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
return -1;
}
}
} else if (pkgDllMode) {
- int ret = createNiDllUnderPkgRoot(args[0], args[1], flags);
+ int ret = createNIDllUnderPkgRoot(args[0], args[1], flags);
if (ret == NI_ERROR_INVALID_PACKAGE) {
fprintf(stderr, "Failed to get root path from [%s]\n", args[0].c_str());
return -1;
}
} else if (rmPkgMode) {
for (const std::string pkg : args) {
- int ret = removeNiUnderPkgRoot(pkg);
+ int ret = removeNIUnderPkgRoot(pkg);
if (ret == NI_ERROR_INVALID_PACKAGE) {
fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
return -1;
// donot return error code for generation failure.
// we have to run crossgen for all input dlls.
for (const std::string dll : args) {
- int ret = createNiDll(dll, flags);
+ int ret = createNIDll(dll, flags);
if (ret == NI_ERROR_ALREADY_EXIST) {
// skip for already exist case
} else if (ret != NI_ERROR_NONE) {
}
}
} else if (dirMode) {
- createNiUnderDirs(args.data(), args.size(), flags);
+ createNIUnderDirs(args.data(), args.size(), flags);
}
return 0;
}
if (!runtimeDir.empty()) {
- __dllPath->runtime_dir = absolutePath(runtimeDir);
+ __dllPath->runtime_dir = getAbsolutePath(runtimeDir);
} else {
- __dllPath->runtime_dir = absolutePath(__RUNTIME_DIR);
+ __dllPath->runtime_dir = getAbsolutePath(__RUNTIME_DIR);
}
if (!tizenFXDir.empty()) {
- __dllPath->tizenfx_dir = absolutePath(tizenFXDir);
+ __dllPath->tizenfx_dir = getAbsolutePath(tizenFXDir);
} else {
char* tmp = vconf_get_str(__TIZEN_API_PATH_KEY);
if (tmp) {
_DBG("Device API Directory is set by vconf : %s", tmp);
free(tmp);
} else {
- __dllPath->tizenfx_dir = absolutePath(__DEVICE_API_DIR);
+ __dllPath->tizenfx_dir = getAbsolutePath(__DEVICE_API_DIR);
}
}
{
std::string platform_tpa;
- if (isFileExist(PLATFORM_TPA_CACHE)) {
+ if (isFile(PLATFORM_TPA_CACHE)) {
_INFO("platform tpa cache found.");
std::ifstream cacheFile;
cacheFile.open(PLATFORM_TPA_CACHE);
return 0;
}
- if (isFileExist(PLUGIN_PATH)) {
+ if (isFile(PLUGIN_PATH)) {
__pluginLib = dlopen(PLUGIN_PATH, RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE);
if (__pluginLib) {
__pluginFunc = (PluginFunc*)calloc(sizeof(PluginFunc), 1);
}
}
-std::string absolutePath(const std::string& path)
+std::string getAbsolutePath(const std::string& path)
{
std::string absPath;
char *realPath = realpath(path.c_str(), NULL);
return 0;
}
-std::string baseName(const std::string& path)
+std::string getBaseName(const std::string& path)
{
auto pos = path.find_last_of(PATH_SEPARATOR);
if (pos != std::string::npos)
return result;
}
-bool isFileExist(const std::string& path)
+bool isFile(const std::string& path)
{
struct stat sb;
return stat(path.c_str(), &sb) == 0;
}
-bool isDirectoryExist(const std::string& path)
+bool isDirectory(const std::string& path)
{
struct stat sb;
if (stat(path.c_str(), &sb) != 0) {
// Update only if a native image is found in the same directory.
// For example, if we have two directories = { X, Y } where X contains A.dll and
// Y contains both A.dll and A.ni.dll, always A.dll in X will be used.
- if (baseName(assemPaths[assem]).compare(baseName(path)) == 0)
+ if (getBaseName(assemPaths[assem]).compare(getBaseName(path)) == 0)
assemPaths[assem] = path;
}
}