[llvm] [llvm][support] Refactor symlink handling and add readlink (PR #184256)
Michael Spencer via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 20:05:55 PDT 2026
================
@@ -338,8 +338,52 @@ std::error_code create_directory(const Twine &path, bool IgnoreExisting,
return std::error_code();
}
-// We can't use symbolic links for windows.
+std::error_code create_symlink(const Twine &to, const Twine &from) {
+ SmallVector<wchar_t, 128> wide_from;
+ SmallVector<wchar_t, 128> wide_to;
+ if (std::error_code ec = widenPath(from, wide_from))
+ return ec;
+ if (std::error_code ec = widenPath(to, wide_to))
+ return ec;
+
+ // The Win32 API normally allows forward slashes, but under some cases it does
+ // not correctly handle them in the target of a symlink.
+ for (wchar_t &C : wide_to)
+ if (C == L'/')
+ C = L'\\';
----------------
Bigcheese wrote:
This needs to work on the wide version of the path.
https://github.com/llvm/llvm-project/pull/184256
More information about the llvm-commits
mailing list