summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/PathV2.inc
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 17:53:55 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 17:53:55 +0000
commit409f556a2fc8443aadf36616245358dc5c312bc0 (patch)
treebad0628c8b3600dd0cf13d79aa7dadfeb645302c /llvm/lib/Support/Unix/PathV2.inc
parent6e74e11c85cb75b0bad6fd39153bc4200358701d (diff)
downloadbcm5719-llvm-409f556a2fc8443aadf36616245358dc5c312bc0.tar.gz
bcm5719-llvm-409f556a2fc8443aadf36616245358dc5c312bc0.zip
Support/FileSystem: Add rename implementation.
llvm-svn: 120818
Diffstat (limited to 'llvm/lib/Support/Unix/PathV2.inc')
-rw-r--r--llvm/lib/Support/Unix/PathV2.inc13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/PathV2.inc b/llvm/lib/Support/Unix/PathV2.inc
index e6972f83363..8ecf2a4222d 100644
--- a/llvm/lib/Support/Unix/PathV2.inc
+++ b/llvm/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);
OpenPOWER on IntegriCloud