diff options
Diffstat (limited to 'lib/Support/Windows/PathV2.inc')
-rw-r--r-- | lib/Support/Windows/PathV2.inc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc index a93ac224a3..4adbda3cab 100644 --- a/lib/Support/Windows/PathV2.inc +++ b/lib/Support/Windows/PathV2.inc @@ -181,6 +181,26 @@ error_code copy_file(const Twine &from, const Twine &to, copy_option copt) { return make_error_code(errc::success); } +error_code create_directory(const Twine &path, bool &existed) { + SmallString<128> path_storage; + SmallVector<wchar_t, 128> path_utf16; + + if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage), + path_utf16)) + return ec; + + if (!::CreateDirectoryW(path_utf16.begin(), NULL)) { + error_code ec = make_error_code(windows_error(::GetLastError())); + if (ec == make_error_code(windows_error::already_exists)) + existed = true; + else + return ec; + } else + existed = false; + + return make_error_code(errc::success); +} + error_code exists(const Twine &path, bool &result) { SmallString<128> path_storage; SmallVector<wchar_t, 128> path_utf16; |