summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows
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/Windows
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/Windows')
-rw-r--r--llvm/lib/Support/Windows/PathV2.inc19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/PathV2.inc b/llvm/lib/Support/Windows/PathV2.inc
index c86c24e811e..c97ba5df593 100644
--- a/llvm/lib/Support/Windows/PathV2.inc
+++ b/llvm/lib/Support/Windows/PathV2.inc
@@ -271,6 +271,25 @@ 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.toStringRef(from_storage);
+ StringRef t = to.toStringRef(to_storage);
+
+ // Convert to utf-16.
+ SmallVector<wchar_t, 128> wide_from;
+ SmallVector<wchar_t, 128> wide_to;
+ if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec;
+ if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec;
+
+ if (!::MoveFileW(wide_from.begin(), wide_to.begin()))
+ return make_error_code(windows_error(::GetLastError()));
+
+ return make_error_code(errc::success);
+}
+
error_code exists(const Twine &path, bool &result) {
SmallString<128> path_storage;
SmallVector<wchar_t, 128> path_utf16;
OpenPOWER on IntegriCloud