Stout: Added `os::temp`. Review: https://reviews.apache.org/r/47470/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/39414107 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/39414107 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/39414107 Branch: refs/heads/master Commit: 3941410756f2f40e5861bbd69c7500fee8ae5368 Parents: 2bbd1b2 Author: Alex Clemmer <clemmer.alexan...@gmail.com> Authored: Mon May 30 20:36:55 2016 -0700 Committer: Joris Van Remoortere <joris.van.remoort...@gmail.com> Committed: Mon May 30 20:36:55 2016 -0700 ---------------------------------------------------------------------- 3rdparty/stout/include/stout/posix/os.hpp | 6 ++++++ 3rdparty/stout/include/stout/windows/os.hpp | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/39414107/3rdparty/stout/include/stout/posix/os.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/stout/include/stout/posix/os.hpp index 715ae34..a92da6f 100644 --- a/3rdparty/stout/include/stout/posix/os.hpp +++ b/3rdparty/stout/include/stout/posix/os.hpp @@ -447,6 +447,12 @@ inline Option<std::string> which(const std::string& command) } +inline std::string temp() +{ + return "/tmp"; +} + + // Create pipes for interprocess communication. inline Try<Nothing> pipe(int pipe_fd[2]) { http://git-wip-us.apache.org/repos/asf/mesos/blob/39414107/3rdparty/stout/include/stout/windows/os.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/stout/include/stout/windows/os.hpp b/3rdparty/stout/include/stout/windows/os.hpp index f7043f6..53bfd81 100644 --- a/3rdparty/stout/include/stout/windows/os.hpp +++ b/3rdparty/stout/include/stout/windows/os.hpp @@ -747,6 +747,22 @@ inline Try<Nothing> kill_job(pid_t pid) } +inline std::string temp() +{ + // Get temp folder for current user. + char temp_folder[MAX_PATH + 2]; + if (::GetTempPath(MAX_PATH + 2, temp_folder) == 0) { + // Failed, try current folder. + if (::GetCurrentDirectory(MAX_PATH + 2, temp_folder) == 0) { + // Failed, use relative path. + return "."; + } + } + + return std::string(temp_folder); +} + + // Create pipes for interprocess communication. Since the pipes cannot // be used directly by Posix `read/write' functions they are wrapped // in file descriptors, a process-local concept.