diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 17:53:55 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 17:53:55 +0000 |
commit | a50b98c517cc90e6c8929b721049c9a589682e6d (patch) | |
tree | 113c2cdb52415cbce1f69c8947f947db64a1e90f /lib/Support/Unix/PathV2.inc | |
parent | 106aa731bf86c632a6362497742c6df7bce61a07 (diff) |
Support/FileSystem: Add rename implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120818 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 e6972f8336..8ecf2a4222 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -200,6 +200,19 @@ error_code remove(const Twine &path, bool &existed) { return make_error_code(errc::success); } +error_code rename(const Twine &from, const Twine &to) { + // Get arguments. + SmallString<128> from_storage; + SmallString<128> to_storage; + StringRef f = from.toNullTerminatedStringRef(from_storage); + StringRef t = to.toNullTerminatedStringRef(to_storage); + + if (::rename(f.begin(), t.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); |