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

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

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

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


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

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

----------------------------------------------------------------------
 3rdparty/stout/include/Makefile.am              |  2 +
 3rdparty/stout/include/stout/os/chdir.hpp       | 25 +++---------
 3rdparty/stout/include/stout/os/posix/chdir.hpp | 37 ++++++++++++++++++
 .../stout/include/stout/os/windows/chdir.hpp    | 41 ++++++++++++++++++++
 3rdparty/stout/include/stout/windows.hpp        |  7 ----
 5 files changed, 85 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d91e4bed/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/Makefile.am b/3rdparty/stout/include/Makefile.am
index 5c0f9f8..b0c28b2 100644
--- a/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/stout/include/Makefile.am
@@ -115,6 +115,7 @@ nobase_include_HEADERS =			\
   stout/os/write.hpp				\
   stout/os/xattr.hpp				\
   stout/os/posix/bootid.hpp			\
+  stout/os/posix/chdir.hpp			\
   stout/os/posix/chown.hpp			\
   stout/os/posix/chroot.hpp			\
   stout/os/posix/close.hpp			\
@@ -150,6 +151,7 @@ nobase_include_HEADERS =			\
   stout/os/raw/argv.hpp				\
   stout/os/raw/environment.hpp			\
   stout/os/windows/bootid.hpp			\
+  stout/os/windows/chdir.hpp			\
   stout/os/windows/chroot.hpp			\
   stout/os/windows/close.hpp			\
   stout/os/windows/dup.hpp			\

http://git-wip-us.apache.org/repos/asf/mesos/blob/d91e4bed/3rdparty/stout/include/stout/os/chdir.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/chdir.hpp b/3rdparty/stout/include/stout/os/chdir.hpp
index 4406076..30017bd 100644
--- a/3rdparty/stout/include/stout/os/chdir.hpp
+++ b/3rdparty/stout/include/stout/os/chdir.hpp
@@ -13,29 +13,14 @@
 #ifndef __STOUT_OS_CHDIR_HPP__
 #define __STOUT_OS_CHDIR_HPP__
 
-#include <string>
-
-#include <stout/error.hpp>
-#include <stout/nothing.hpp>
-#include <stout/try.hpp>
 
+// For readability, we minimize the number of #ifdef blocks in the code by
+// splitting platform specific system calls into separate directories.
 #ifdef __WINDOWS__
-#include <stout/windows.hpp> // To be certain we're using the right `chdir`.
+#include <stout/os/windows/chdir.hpp>
+#else
+#include <stout/os/posix/chdir.hpp>
 #endif // __WINDOWS__
 
 
-namespace os {
-
-inline Try<Nothing> chdir(const std::string& directory)
-{
-  if (::chdir(directory.c_str()) < 0) {
-    return ErrnoError();
-  }
-
-  return Nothing();
-}
-
-} // namespace os {
-
-
 #endif // __STOUT_OS_CHDIR_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/d91e4bed/3rdparty/stout/include/stout/os/posix/chdir.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/posix/chdir.hpp b/3rdparty/stout/include/stout/os/posix/chdir.hpp
new file mode 100644
index 0000000..8bb2b3b
--- /dev/null
+++ b/3rdparty/stout/include/stout/os/posix/chdir.hpp
@@ -0,0 +1,37 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_POSIX_CHDIR_HPP__
+#define __STOUT_OS_POSIX_CHDIR_HPP__
+
+#include <string>
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+
+namespace os {
+
+inline Try<Nothing> chdir(const std::string& directory)
+{
+  if (::chdir(directory.c_str()) < 0) {
+    return ErrnoError();
+  }
+
+  return Nothing();
+}
+
+} // namespace os {
+
+
+#endif // __STOUT_OS_POSIX_CHDIR_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/d91e4bed/3rdparty/stout/include/stout/os/windows/chdir.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/chdir.hpp b/3rdparty/stout/include/stout/os/windows/chdir.hpp
new file mode 100644
index 0000000..523c7f7
--- /dev/null
+++ b/3rdparty/stout/include/stout/os/windows/chdir.hpp
@@ -0,0 +1,41 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_WINDOWS_CHDIR_HPP__
+#define __STOUT_OS_WINDOWS_CHDIR_HPP__
+
+#include <string>
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+#include <stout/windows.hpp>
+
+#include <stout/internal/windows/longpath.hpp>
+
+
+namespace os {
+
+inline Try<Nothing> chdir(const std::string& directory)
+{
+  std::wstring longpath = ::internal::windows::longpath(directory);
+  if (::SetCurrentDirectoryW(longpath.data()) == 0) {
+    return WindowsError();
+  }
+
+  return Nothing();
+}
+
+} // namespace os {
+
+
+#endif // __STOUT_OS_WINDOWS_CHDIR_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/d91e4bed/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows.hpp b/3rdparty/stout/include/stout/windows.hpp
index a2b13c3..d70d436 100644
--- a/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/stout/include/stout/windows.hpp
@@ -345,13 +345,6 @@ decltype(strerror_s(buffer, length, errnum))
 // maintain the code. It is an explicit marker that we are using the compiler
 // to guarantee that the return type is identical to whatever is in the Windows
 // implementation of the standard.
-inline auto chdir(const char* path) ->
-decltype(_chdir(path))
-{
-  return _chdir(path);
-}
-
-
 inline auto mktemp(char* path) ->
 decltype(_mktemp(path))
 {