You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/07/11 01:39:11 UTC

[25/50] mesos git commit: Windows: Updated `os::temp()` to use UTF-16 syscalls.

Windows: Updated `os::temp()` to use UTF-16 syscalls.

Review: https://reviews.apache.org/r/60318/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ffe2f2dc
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ffe2f2dc
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ffe2f2dc

Branch: refs/heads/master
Commit: ffe2f2dc04f7835525bd52aafff911fb3839b133
Parents: 6f30623
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Mon Jul 10 07:33:35 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:35 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/windows/temp.hpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ffe2f2dc/3rdparty/stout/include/stout/os/windows/temp.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/temp.hpp b/3rdparty/stout/include/stout/os/windows/temp.hpp
index 639f1aa..9cf467f 100644
--- a/3rdparty/stout/include/stout/os/windows/temp.hpp
+++ b/3rdparty/stout/include/stout/os/windows/temp.hpp
@@ -14,7 +14,9 @@
 #define __STOUT_OS_WINDOWS_TEMP_HPP__
 
 #include <string>
+#include <vector>
 
+#include <stout/stringify.hpp>
 #include <stout/windows.hpp>
 
 
@@ -27,15 +29,18 @@ namespace os {
 // where none of these are found, this function returns the current directory.
 inline std::string temp()
 {
-  char temp_folder[MAX_PATH + 2];
-  if (::GetTempPath(MAX_PATH + 2, temp_folder) == 0) {
-    if (::GetCurrentDirectory(MAX_PATH + 2, temp_folder) == 0) {
+  size_t size = static_cast<size_t>(MAX_PATH) + 2;
+  std::vector<wchar_t> buffer;
+  buffer.reserve(size);
+  if (::GetTempPathW(static_cast<DWORD>(size), buffer.data()) == 0) {
+    // Failed, use current directory.
+    if (::GetCurrentDirectoryW(static_cast<DWORD>(size), buffer.data()) == 0) {
       // Failed, use relative path.
       return ".";
     }
   }
 
-  return std::string(temp_folder);
+  return stringify(std::wstring(buffer.data()));
 }
 
 } // namespace os {