*/
bool isFile(const std::string& path);
+/**
+ * @brief check symlink file
+ * @param[in] source path
+ * @return bool
+ */
+bool isSymlinkFile(const std::string& path);
+
/**
* @brief check directory exists
* @param[in] source path
break;
}
}
- bf::create_symlink(concatPath(tac_version_dir, assembly), concatPath(tacDir, assembly));
+ bs::error_code error;
+ bf::create_symlink(concatPath(tac_version_dir, assembly), concatPath(tacDir, assembly), error);
+ if (error) {
+ _ERR("Failed to create symlink %s file", concatPath(tacDir, assembly).c_str());
+ nuget_restoration = true;
+ break;
+ }
copySmackAndOwnership(tacDir, concatPath(tacDir, assembly), true);
if (!removeFile(concatPath(binPath, assembly))) {
}
continue;
}
- bf::create_symlink(concatPath(tlcDir, fileSha), library);
+ bs::error_code error;
+ bf::create_symlink(concatPath(tlcDir, fileSha), library, error);
+ if (error) {
+ _ERR("Failed to create symlink %s file", library.c_str());
+ copyFile(concatPath(tlcDir, fileSha), library);
+ copySmackAndOwnership(getBaseName(library), library);
+ if (fileCopied) {
+ removeFile(concatPath(tlcDir, fileSha));
+ }
+ continue;
+ }
copySmackAndOwnership(getBaseName(library), library, true);
char *sql = sqlite3_mprintf("INSERT INTO TLC (PKGID, LIBRARY) VALUES (%Q, %Q);", pkgId, fileSha.c_str());
_INFO("TAC name : %s", tac_name.c_str());
_INFO("TAC version : %s", tac_version.c_str());
+ bs::error_code error;
std::string tac_version_dir = concatPath(__DOTNET_DIR, np);
std::string sha256_info = concatPath(tac_version_dir, TAC_SHA_256_INFO);
if (!exist(tac_version_dir)) {
return -1;
}
createDirectories.push_back(tac_version_dir);
- if (!bf::is_symlink(sha256_info)) {
+ if (!isSymlinkFile(sha256_info)) {
createSHA256Info(sha256_info, np);
} else {
_ERR("Failed to create sha256_info. Symbolic link is detected");
sqlite3_free(sql);
} else {
_INFO("Exists tac_version_dir [%s]", tac_version_dir.c_str());
- if (!bf::is_symlink(sha256_info)) {
+ if (!isSymlinkFile(sha256_info)) {
if (compareSHA256Info(sha256_info, np)) {
if (copyAssemblyCreateSymlink(binPath, tac_dir, np, false)) {
_ERR("Failed to create symlink");
_INFO("TAC name : %s", tac_name.c_str());
_INFO("TAC version : %s", tac_version.c_str());
+ bs::error_code error;
std::string tac_version_dir = concatPath(__DOTNET_DIR, np);
std::string sha256_info = concatPath(tac_version_dir, TAC_SHA_256_INFO);
if (!exist(tac_version_dir)) {
return -1;
}
createDirectories.push_back(tac_version_dir);
- if (!bf::is_symlink(sha256_info)) {
+ if (!isSymlinkFile(sha256_info)) {
createSHA256Info(sha256_info, np);
} else {
_ERR("Failed to create sha256_info. Symbolic link is detected");
}
} else {
_INFO("Exists tac_version_dir [%s]", tac_version_dir.c_str());
- if (!bf::is_symlink(sha256_info)) {
+ if (!isSymlinkFile(sha256_info)) {
if (compareSHA256Info(sha256_info, np)) {
if (copyAssemblyCreateSymlink(binPath, tac_dir, np, false)) {
_ERR("Failed to create symlink");
try {
for (auto& path : bf::recursive_directory_iterator(runtimesDir)) {
std::string symPath = path.path().string();
- if (isDirectory(symPath) || !bf::is_symlink(symPath))
+ if (isDirectory(symPath) || !isSymlinkFile(symPath))
continue;
std::string targetDir = symPath.substr(symPath.rfind("/runtimes/") + 10);
if (!std::regex_match(targetDir.substr(0, targetDir.find('/')), pattern))
for (auto& symlinkAssembly : bf::recursive_directory_iterator(tacDir)) {
std::string symPath = symlinkAssembly.path().string();
std::string fileName = symlinkAssembly.path().filename().string();
- if (bf::is_symlink(symPath)) {
+ if (isSymlinkFile(symPath)) {
std::string originPath = bf::read_symlink(symPath).string();
if (!isNativeImage(symPath)) {
std::string dllPath = concatPath(binDir, fileName);
}
}
+ bs::error_code error;
for (auto& originPath : enableNuget) {
if (exist(originPath)) {
std::string fileName = originPath.substr(originPath.rfind('/') + 1);
if (exist(binNIDir)) {
std::string originNIPath = changeExtension(originPath, "dll", "ni.dll");
if (exist(originNIPath)) {
- bf::create_symlink(originNIPath, concatPath(tacDir, NIFileName));
+ bf::create_symlink(originNIPath, concatPath(tacDir, NIFileName), error);
+ if (error) {
+ _SERR("Failed to create symlink %s file", concatPath(tacDir, NIFileName).c_str());
+ return TAC_ERROR_UNKNOWN;
+ }
_SOUT("%s symbolic link file generated successfully.", concatPath(tacDir, NIFileName).c_str());
copySmackAndOwnership(tacDir.c_str(), concatPath(tacDir, NIFileName).c_str(), true);
}
}
}
- bf::create_symlink(originPath, concatPath(tacDir, fileName));
+ bf::create_symlink(originPath, concatPath(tacDir, fileName), error);
+ if (error) {
+ _SERR("Failed to create symlink %s file", concatPath(tacDir, fileName).c_str());
+ return TAC_ERROR_UNKNOWN;
+ }
_SOUT("%s symbolic link file generated successfully.", concatPath(tacDir, fileName).c_str());
copySmackAndOwnership(tacDir.c_str(), concatPath(tacDir, fileName).c_str(), true);
std::string tpaList;
addAssembliesFromDirectories(__pm->getPlatformAssembliesPaths(), tpaList);
- if (!bf::is_symlink(PLATFORM_TPA_CACHE)) {
+ if (!isSymlinkFile(PLATFORM_TPA_CACHE)) {
std::ofstream out(PLATFORM_TPA_CACHE);
out << tpaList;
out.close();
return lstat(path.c_str(), &sb) == 0;
}
-bool isDirectory(const std::string& path)
+bool isSymlinkFile(const std::string& path)
{
struct stat sb;
- if (stat(path.c_str(), &sb) != 0) {
+ if (lstat(path.c_str(), &sb) != 0) {
return false;
}
- if (sb.st_mode & S_IFDIR) {
- return true;
- } else {
+ return (sb.st_mode & S_IFMT) == S_IFLNK;
+}
+
+bool isDirectory(const std::string& path)
+{
+ struct stat sb;
+ if (stat(path.c_str(), &sb) != 0) {
return false;
}
+ return (sb.st_mode & S_IFMT) == S_IFDIR;
}
std::string getAssemblyNameFromPath(const std::string& path)
_ERR("Failed to copy ownership and permissions from %s to %s", path.c_str(), path2.c_str());
return false;
}
- bf::perms permissions = bf::status(path).permissions();
+ bs::error_code error;
+ bf::perms permissions = bf::status(path, error).permissions();
+ if (error) {
+ _ERR("Failed to copy ownership and permissions : %s", error.message().c_str());
+ return false;
+ }
struct stat stats;
if (stat(path.c_str(), &stats) != 0) {
return false;
}
// Iterate through the source directory
- for (bf::directory_iterator file(path1); file != bf::directory_iterator(); ++file) {
- try {
+ try {
+ for (bf::directory_iterator file(path1); file != bf::directory_iterator(); ++file) {
bf::path current(file->path());
bf::path target = path2 / current.filename();
- if (bf::is_symlink(symlink_status(current))) {
+ if (bf::is_symlink(bf::symlink_status(current))) {
if ((flags & (FS_MERGE_SKIP | FS_MERGE_OVERWRITE)) && exist(target)) {
continue;
}
bf::rename(destination, target);
}
}
- } catch (const bf::filesystem_error& error) {
- _ERR("Failed to copy directory: %s", error.what());
- return false;
}
+ } catch (const bf::filesystem_error& error) {
+ _ERR("Failed to copy directory: %s", error.what());
+ return false;
}
+
return true;
}