diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 05:58:41 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 05:58:41 +0000 |
commit | e0c4560b50b1b89649a8b06c1b138bf1d3bb8c99 (patch) | |
tree | 5e14de58e2c3078364f66b74d930e124734bf10f /llvm/lib/Support/Windows | |
parent | 73e60d029c0ff0406d4e185f48183c30b83daa49 (diff) | |
download | bcm5719-llvm-e0c4560b50b1b89649a8b06c1b138bf1d3bb8c99.tar.gz bcm5719-llvm-e0c4560b50b1b89649a8b06c1b138bf1d3bb8c99.zip |
Support/FileSystem: Add create_hard_link implementation.
llvm-svn: 120792
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r-- | llvm/lib/Support/Windows/PathV2.inc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/PathV2.inc b/llvm/lib/Support/Windows/PathV2.inc index 4adbda3cab1..d374dccdeb6 100644 --- a/llvm/lib/Support/Windows/PathV2.inc +++ b/llvm/lib/Support/Windows/PathV2.inc @@ -201,6 +201,25 @@ error_code create_directory(const Twine &path, bool &existed) { return make_error_code(errc::success); } +error_code create_hard_link(const Twine &to, const Twine &from) { + // Get arguments. + SmallString<128> from_storage; + SmallString<128> to_storage; + StringRef f = from.toStringRef(from_storage); + StringRef t = to.toStringRef(to_storage); + + // Convert to utf-16. + SmallVector<wchar_t, 128> wide_from; + SmallVector<wchar_t, 128> wide_to; + if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec; + if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec; + + if (!::CreateHardLinkW(wide_from.begin(), wide_to.begin(), NULL)) + return make_error_code(windows_error(::GetLastError())); + + return make_error_code(errc::success); +} + error_code exists(const Twine &path, bool &result) { SmallString<128> path_storage; SmallVector<wchar_t, 128> path_utf16; |