From 226ac347c51e21440d1740d85b5e9912d1ce08e5 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Mon, 6 Dec 2021 07:57:52 -0500 Subject: add upstream 11.15 --- zen/symlink_target.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'zen/symlink_target.h') diff --git a/zen/symlink_target.h b/zen/symlink_target.h index 32b1211d..60353292 100644 --- a/zen/symlink_target.h +++ b/zen/symlink_target.h @@ -9,6 +9,7 @@ #include "scope_guard.h" #include "file_error.h" +#include "file_path.h" #include #include //realpath @@ -58,11 +59,15 @@ zen::SymlinkRawContent getSymlinkRawContent_impl(const Zstring& linkPath) //thro Zstring getResolvedSymlinkPath_impl(const Zstring& linkPath) //throw FileError { using namespace zen; - char* targetPath = ::realpath(linkPath.c_str(), nullptr); - if (!targetPath) - THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot determine final path for %x."), L"%x", fmtPath(linkPath)), "realpath"); - ZEN_ON_SCOPE_EXIT(::free(targetPath)); - return targetPath; + try + { + char* targetPath = ::realpath(linkPath.c_str(), nullptr); + if (!targetPath) + THROW_LAST_SYS_ERROR("realpath"); + ZEN_ON_SCOPE_EXIT(::free(targetPath)); + return targetPath; + } + catch (const SysError& e) { throw FileError(replaceCpy(_("Cannot determine final path for %x."), L"%x", fmtPath(linkPath)), e.toString()); } } } -- cgit