summaryrefslogtreecommitdiff
path: root/lib/Support/Windows
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2013-08-16 17:53:28 +0000
committerAaron Ballman <aaron@aaronballman.com>2013-08-16 17:53:28 +0000
commit5e485a528168e883075d7c3c74e9010f0552a9f7 (patch)
tree2a76a5afb7415cd1ffb141f73f4ee05e02afb53f /lib/Support/Windows
parent0009850524f72183c49b506f3eb4c3bdc5f3a0d4 (diff)
downloadllvm-5e485a528168e883075d7c3c74e9010f0552a9f7.tar.gz
llvm-5e485a528168e883075d7c3c74e9010f0552a9f7.tar.bz2
llvm-5e485a528168e883075d7c3c74e9010f0552a9f7.tar.xz
Switching to using a helper function instead of manually converting the string to UTF-8.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188566 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Windows')
-rw-r--r--lib/Support/Windows/Path.inc25
1 files changed, 1 insertions, 24 deletions
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index 1694cb28b2..093f374a29 100644
--- a/lib/Support/Windows/Path.inc
+++ b/lib/Support/Windows/Path.inc
@@ -310,30 +310,7 @@ retry_cur_dir:
}
cur_path.set_size(len);
- // cur_path now holds the current directory in utf-16. Convert to utf-8.
-
- // Find out how much space we need. Sadly, this function doesn't return the
- // size needed unless you tell it the result size is 0, which means you
- // _always_ have to call it twice.
- len = ::WideCharToMultiByte(CP_UTF8, 0,
- cur_path.data(), cur_path.size(),
- result.data(), 0,
- NULL, NULL);
-
- if (len == 0)
- return make_error_code(windows_error(::GetLastError()));
-
- result.reserve(len);
- result.set_size(len);
- // Now do the actual conversion.
- len = ::WideCharToMultiByte(CP_UTF8, 0,
- cur_path.data(), cur_path.size(),
- result.data(), result.size(),
- NULL, NULL);
- if (len == 0)
- return windows_error(::GetLastError());
-
- return error_code::success();
+ return UTF16ToUTF8(cur_path.begin(), cur_path.size(), result);
}
error_code create_directory(const Twine &path, bool &existed) {