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/Unix/PathV2.inc | |
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/Unix/PathV2.inc')
-rw-r--r-- | llvm/lib/Support/Unix/PathV2.inc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/PathV2.inc b/llvm/lib/Support/Unix/PathV2.inc index fc0d4a09a73..2bde7805f09 100644 --- a/llvm/lib/Support/Unix/PathV2.inc +++ b/llvm/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); |