Windows: Moved `os::chdir` to its own file, `stout/os/chdir.hpp`. Review: https://reviews.apache.org/r/39541
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ffb5105e Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ffb5105e Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ffb5105e Branch: refs/heads/master Commit: ffb5105e26748c4d04c19e6dc1b247157608e006 Parents: c1295c4 Author: Alex Clemmer <[email protected]> Authored: Wed Oct 28 15:54:18 2015 -0500 Committer: Joris Van Remoortere <[email protected]> Committed: Wed Oct 28 17:11:03 2015 -0500 ---------------------------------------------------------------------- .../3rdparty/stout/include/Makefile.am | 1 + .../3rdparty/stout/include/stout/os.hpp | 1 + .../3rdparty/stout/include/stout/os/chdir.hpp | 42 ++++++++++++++++++++ .../3rdparty/stout/include/stout/posix/os.hpp | 10 ----- .../3rdparty/stout/include/stout/windows.hpp | 7 ++++ .../3rdparty/stout/include/stout/windows/os.hpp | 6 --- 6 files changed, 51 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/ffb5105e/3rdparty/libprocess/3rdparty/stout/include/Makefile.am ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am index 79c9fe4..16db9a6 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am +++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am @@ -53,6 +53,7 @@ nobase_include_HEADERS = \ stout/option.hpp \ stout/os.hpp \ stout/os/bootid.hpp \ + stout/os/chdir.hpp \ stout/os/close.hpp \ stout/os/environment.hpp \ stout/os/exists.hpp \ http://git-wip-us.apache.org/repos/asf/mesos/blob/ffb5105e/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp index ad2e1b5..05b5845 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp @@ -75,6 +75,7 @@ #include <stout/version.hpp> #include <stout/os/bootid.hpp> +#include <stout/os/chdir.hpp> #include <stout/os/environment.hpp> #include <stout/os/fork.hpp> #include <stout/os/getcwd.hpp> http://git-wip-us.apache.org/repos/asf/mesos/blob/ffb5105e/3rdparty/libprocess/3rdparty/stout/include/stout/os/chdir.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/chdir.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/chdir.hpp new file mode 100644 index 0000000..a76c271 --- /dev/null +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/chdir.hpp @@ -0,0 +1,42 @@ +/** + * 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_CHDIR_HPP__ +#define __STOUT_OS_CHDIR_HPP__ + +#include <string> + +#include <stout/error.hpp> +#include <stout/nothing.hpp> +#include <stout/try.hpp> + +#ifdef __WINDOWS__ +#include <stout/windows.hpp> // To be certain we're using the right `chdir`. +#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/ffb5105e/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp index f4bf383..e26df59 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp @@ -286,16 +286,6 @@ inline Try<Nothing> chmod(const std::string& path, int mode) } -inline Try<Nothing> chdir(const std::string& directory) -{ - if (::chdir(directory.c_str()) < 0) { - return ErrnoError(); - } - - return Nothing(); -} - - inline Try<Nothing> chroot(const std::string& directory) { if (::chroot(directory.c_str()) < 0) { http://git-wip-us.apache.org/repos/asf/mesos/blob/ffb5105e/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp index aa2e16e..1a7037d 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp @@ -203,6 +203,13 @@ decltype(_close(fd)) } +inline auto chdir(const char* path) -> +decltype(_chdir(path)) +{ + return _chdir(path); +} + + inline auto getcwd(char* path, int maxlen) -> decltype(_getcwd(path, maxlen)) { http://git-wip-us.apache.org/repos/asf/mesos/blob/ffb5105e/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp index ecf0e14..edf17d5 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp @@ -126,12 +126,6 @@ inline Try<Nothing> chmod(const std::string& path, int mode) } -inline Try<Nothing> chdir(const std::string& directory) -{ - UNIMPLEMENTED; -} - - inline Try<Nothing> chroot(const std::string& directory) { UNIMPLEMENTED;
