[libcxx-commits] [PATCH] D91175: [19/N] [libcxx] Implement temp_directory_path using GetTempPath on windows
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Feb 5 12:48:08 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4f4e723d0b4: [libcxx] Implement temp_directory_path using GetTempPath on windows (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91175/new/
https://reviews.llvm.org/D91175
Files:
libcxx/src/filesystem/operations.cpp
Index: libcxx/src/filesystem/operations.cpp
===================================================================
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -1347,6 +1347,19 @@
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 @@
ret = "/tmp";
path p(ret);
+#endif
error_code m_ec;
file_status st = detail::posix_stat(p, &m_ec);
if (!status_known(st))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91175.321853.patch
Type: text/x-patch
Size: 1033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210205/b197e28c/attachment.bin>
More information about the libcxx-commits
mailing list