summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Path.inc
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-11-18 02:12:53 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-11-18 02:12:53 +0000
commit8dc0e1095fc4e1afae27a3dd2bba816b47234c1d (patch)
tree85c5e4c909940e56ba0ddb0a43c0b2c44af92ba5 /llvm/lib/Support/Windows/Path.inc
parent041299e3ebad892e5d4f149e18e4530b770b8895 (diff)
downloadbcm5719-llvm-8dc0e1095fc4e1afae27a3dd2bba816b47234c1d.tar.gz
bcm5719-llvm-8dc0e1095fc4e1afae27a3dd2bba816b47234c1d.zip
Reorder static functions. NFC.
llvm-svn: 318584
Diffstat (limited to 'llvm/lib/Support/Windows/Path.inc')
-rw-r--r--llvm/lib/Support/Windows/Path.inc73
1 files changed, 35 insertions, 38 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index b025cb830af..df39ac7e757 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -345,7 +345,41 @@ std::error_code is_local(const Twine &path, bool &result) {
}
static std::error_code realPathFromHandle(HANDLE H,
- SmallVectorImpl<wchar_t> &Buffer);
+ SmallVectorImpl<wchar_t> &Buffer) {
+ DWORD CountChars = ::GetFinalPathNameByHandleW(
+ H, Buffer.begin(), Buffer.capacity() - 1, FILE_NAME_NORMALIZED);
+ if (CountChars > Buffer.capacity()) {
+ // The buffer wasn't big enough, try again. In this case the return value
+ // *does* indicate the size of the null terminator.
+ Buffer.reserve(CountChars);
+ CountChars = ::GetFinalPathNameByHandleW(
+ H, Buffer.data(), Buffer.capacity() - 1, FILE_NAME_NORMALIZED);
+ }
+ if (CountChars == 0)
+ return mapWindowsError(GetLastError());
+ Buffer.set_size(CountChars);
+ return std::error_code();
+}
+
+static std::error_code realPathFromHandle(HANDLE H,
+ SmallVectorImpl<char> &RealPath) {
+ RealPath.clear();
+ SmallVector<wchar_t, MAX_PATH> Buffer;
+ if (std::error_code EC = realPathFromHandle(H, Buffer))
+ return EC;
+
+ const wchar_t *Data = Buffer.data();
+ DWORD CountChars = Buffer.size();
+ if (CountChars >= 4) {
+ if (0 == ::memcmp(Data, L"\\\\?\\", 8)) {
+ CountChars -= 4;
+ Data += 4;
+ }
+ }
+
+ // Convert the result from UTF-16 to UTF-8.
+ return UTF16ToUTF8(Data, CountChars, RealPath);
+}
std::error_code is_local(int FD, bool &Result) {
SmallVector<wchar_t, 128> FinalPath;
@@ -911,43 +945,6 @@ ErrorOr<basic_file_status> directory_entry::status() const {
return Status;
}
-static std::error_code realPathFromHandle(HANDLE H,
- SmallVectorImpl<wchar_t> &Buffer) {
- DWORD CountChars = ::GetFinalPathNameByHandleW(
- H, Buffer.begin(), Buffer.capacity() - 1, FILE_NAME_NORMALIZED);
- if (CountChars > Buffer.capacity()) {
- // The buffer wasn't big enough, try again. In this case the return value
- // *does* indicate the size of the null terminator.
- Buffer.reserve(CountChars);
- CountChars = ::GetFinalPathNameByHandleW(
- H, Buffer.data(), Buffer.capacity() - 1, FILE_NAME_NORMALIZED);
- }
- if (CountChars == 0)
- return mapWindowsError(GetLastError());
- Buffer.set_size(CountChars);
- return std::error_code();
-}
-
-static std::error_code realPathFromHandle(HANDLE H,
- SmallVectorImpl<char> &RealPath) {
- RealPath.clear();
- SmallVector<wchar_t, MAX_PATH> Buffer;
- if (std::error_code EC = realPathFromHandle(H, Buffer))
- return EC;
-
- const wchar_t *Data = Buffer.data();
- DWORD CountChars = Buffer.size();
- if (CountChars >= 4) {
- if (0 == ::memcmp(Data, L"\\\\?\\", 8)) {
- CountChars -= 4;
- Data += 4;
- }
- }
-
- // Convert the result from UTF-16 to UTF-8.
- return UTF16ToUTF8(Data, CountChars, RealPath);
-}
-
static std::error_code directoryRealPath(const Twine &Name,
SmallVectorImpl<char> &RealPath) {
SmallVector<wchar_t, 128> PathUTF16;
OpenPOWER on IntegriCloud