This fixes linking against a DLL of libc++ while using the common headers (generated from the static version of the library, but which work for both shared and static versions) when calling e.g. std::filesystem::u8path.
54 lines
1.9 KiB
Diff
54 lines
1.9 KiB
Diff
From 3474a416fef709f218ff5897842819d379495cad Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
|
|
Date: Thu, 29 Oct 2020 12:10:26 +0200
|
|
Subject: [PATCH 11/25] [libcxx] Implement temp_directory_path using
|
|
GetTempPath on windows
|
|
|
|
This does roughly the same as the manual implementation, but checks
|
|
a slightly different set of environment variables and has a more
|
|
appropriate fallback if no environment variables are available
|
|
(/tmp isn't a very useful fallback on windows).
|
|
|
|
Differential Revision: https://reviews.llvm.org/D91175
|
|
|
|
(cherry picked from commit d4f4e723d0b4f09d72880f1679c02d586bf8abfa)
|
|
---
|
|
libcxx/src/filesystem/operations.cpp | 14 ++++++++++++++
|
|
1 file changed, 14 insertions(+)
|
|
|
|
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
|
|
index dccec9378531..674f19154e6f 100644
|
|
--- a/libcxx/src/filesystem/operations.cpp
|
|
+++ b/libcxx/src/filesystem/operations.cpp
|
|
@@ -1347,6 +1347,19 @@ file_status __symlink_status(const path& p, error_code* ec) {
|
|
path __temp_directory_path(error_code* ec) {
|
|
ErrorHandler<path> err("temp_directory_path", ec);
|
|
|
|
+#if defined(_LIBCPP_WIN32API)
|
|
+ wchar_t buf[MAX_PATH];
|
|
+ DWORD retval = GetTempPathW(MAX_PATH, buf);
|
|
+ if (!retval)
|
|
+ return err.report(detail::make_windows_error(GetLastError()));
|
|
+ if (retval > MAX_PATH)
|
|
+ return err.report(errc::filename_too_long);
|
|
+ // GetTempPathW returns a path with a trailing slash, which we
|
|
+ // shouldn't include for consistency.
|
|
+ if (buf[retval-1] == L'\\')
|
|
+ buf[retval-1] = L'\0';
|
|
+ path p(buf);
|
|
+#else
|
|
const char* env_paths[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
|
|
const char* ret = nullptr;
|
|
|
|
@@ -1357,6 +1370,7 @@ path __temp_directory_path(error_code* ec) {
|
|
ret = "/tmp";
|
|
|
|
path p(ret);
|
|
+#endif
|
|
error_code m_ec;
|
|
file_status st = detail::posix_stat(p, &m_ec);
|
|
if (!status_known(st))
|
|
--
|
|
2.25.1
|
|
|