summaryrefslogtreecommitdiff
path: root/zen/symlink_target.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-12-06 07:57:52 -0500
committerB. Stack <bgstack15@gmail.com>2021-12-06 07:57:52 -0500
commit226ac347c51e21440d1740d85b5e9912d1ce08e5 (patch)
tree2999df8f80b28d0f7f60a84b7f75d613e280bba1 /zen/symlink_target.h
parentMerge branch 'b11.14' into 'master' (diff)
downloadFreeFileSync-226ac347c51e21440d1740d85b5e9912d1ce08e5.tar.gz
FreeFileSync-226ac347c51e21440d1740d85b5e9912d1ce08e5.tar.bz2
FreeFileSync-226ac347c51e21440d1740d85b5e9912d1ce08e5.zip
add upstream 11.15
Diffstat (limited to 'zen/symlink_target.h')
-rw-r--r--zen/symlink_target.h15
1 files changed, 10 insertions, 5 deletions
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 <unistd.h>
#include <stdlib.h> //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()); }
}
}
bgstack15