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 | d7b305f13ec1f53224c7eb8f4d3696eee5d10c40 (patch) | |
tree | 35fac930fd12836bc687950335a427e32603c596 /lib/Support/Unix | |
parent | 0dda5437f8044269a90acddad822866056a0c8b3 (diff) |
Support/FileSystem: Add create_hard_link implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120792 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r-- | lib/Support/Unix/PathV2.inc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index fc0d4a09a7..2bde7805f0 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -160,6 +160,19 @@ 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.toNullTerminatedStringRef(from_storage); + StringRef t = to.toNullTerminatedStringRef(to_storage); + + if (::link(t.begin(), f.begin()) == -1) + return error_code(errno, system_category()); + + return make_error_code(errc::success); +} + error_code exists(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toNullTerminatedStringRef(path_storage); |