diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 07:41:25 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 07:41:25 +0000 |
commit | 9b391c513e0051289c7013dd9917eb6176724920 (patch) | |
tree | f4ee43d525bf4aa5c03dcdc6ea6d421d2b162634 /lib/Support/Unix/PathV2.inc | |
parent | d7b305f13ec1f53224c7eb8f4d3696eee5d10c40 (diff) |
Support/FileSystem: Add create_symlink implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120800 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix/PathV2.inc')
-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 2bde7805f0..985dde7426 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -173,6 +173,19 @@ error_code create_hard_link(const Twine &to, const Twine &from) { return make_error_code(errc::success); } +error_code create_symlink(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 (::symlink(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); |