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:05 UTC

[19/50] mesos git commit: Windows: Updated `os::open()` to support long paths.

Windows: Updated `os::open()` to support long paths.

The CRT library can support long paths on Windows, if the Unicode
versions of the APIs are used, and the long path prefix is prepended to
the path.

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


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

Branch: refs/heads/master
Commit: 7367901d53db0fe6430db93b0a8d3c90598e3228
Parents: e1abdf9
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Sat Jul 8 19:22:07 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:34 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/open.hpp | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7367901d/3rdparty/stout/include/stout/os/open.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/open.hpp b/3rdparty/stout/include/stout/os/open.hpp
index ceff89f..c9346c6 100644
--- a/3rdparty/stout/include/stout/os/open.hpp
+++ b/3rdparty/stout/include/stout/os/open.hpp
@@ -25,6 +25,11 @@
 #include <stout/os/close.hpp>
 #include <stout/os/int_fd.hpp>
 
+#ifdef __WINDOWS__
+#include <stout/windows.hpp>
+#include <stout/internal/windows/longpath.hpp>
+#endif // __WINDOWS__
+
 // For old systems that do not support O_CLOEXEC, we still want
 // os::open to accept that flag so that we can simplify the code.
 #ifndef O_CLOEXEC
@@ -70,7 +75,12 @@ inline Try<int_fd> open(const std::string& path, int oflag, mode_t mode = 0)
   }
 #endif
 
+#ifdef __WINDOWS__
+  std::wstring longpath = ::internal::windows::longpath(path);
+  int_fd fd = ::_wopen(longpath.data(), oflag, mode);
+#else
   int_fd fd = ::open(path.c_str(), oflag, mode);
+#endif // __WINDOWS__
   if (fd < 0) {
     return ErrnoError();
   }