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 2015/10/18 02:11:46 UTC
[11/12] mesos git commit: Windows: Moved `realpath` to its own file,
`stout/os/realpath.hpp`.
Windows: Moved `realpath` to its own file, `stout/os/realpath.hpp`.
Review: https://reviews.apache.org/r/39210
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b7f88463
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b7f88463
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b7f88463
Branch: refs/heads/master
Commit: b7f884636f8218900089e64e626335d7e4f9939f
Parents: c8eca6c
Author: Alex Clemmer <cl...@gmail.com>
Authored: Sat Oct 17 18:09:53 2015 -0400
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Sat Oct 17 20:11:13 2015 -0400
----------------------------------------------------------------------
.../3rdparty/stout/include/Makefile.am | 1 +
.../3rdparty/stout/include/stout/os.hpp | 14 +------
.../stout/include/stout/os/realpath.hpp | 41 ++++++++++++++++++++
.../stout/include/stout/os/windows/exists.hpp | 14 +++----
4 files changed, 48 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b7f88463/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 32fa58f..b0d9f49 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -75,6 +75,7 @@ nobase_include_HEADERS = \
stout/os/osx.hpp \
stout/os/process.hpp \
stout/os/read.hpp \
+ stout/os/realpath.hpp \
stout/os/rename.hpp \
stout/os/sendfile.hpp \
stout/os/shell.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/b7f88463/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 5cbb39c..7e4820f 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -80,6 +80,7 @@
#include <stout/os/permissions.hpp>
#include <stout/os/os.hpp>
#include <stout/os/read.hpp>
+#include <stout/os/realpath.hpp>
#include <stout/os/rename.hpp>
#include <stout/os/sendfile.hpp>
#include <stout/os/shell.hpp>
@@ -186,19 +187,6 @@ inline Try<std::string> mktemp(const std::string& path = "/tmp/XXXXXX")
}
-inline Result<std::string> realpath(const std::string& path)
-{
- char temp[PATH_MAX];
- if (::realpath(path.c_str(), temp) == NULL) {
- if (errno == ENOENT || errno == ENOTDIR) {
- return None();
- }
- return ErrnoError();
- }
- return std::string(temp);
-}
-
-
inline Try<Nothing> mkdir(const std::string& directory, bool recursive = true)
{
if (!recursive) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/b7f88463/3rdparty/libprocess/3rdparty/stout/include/stout/os/realpath.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/realpath.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/realpath.hpp
new file mode 100644
index 0000000..075bdbb
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/realpath.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_REALPATH_HPP__
+#define __STOUT_OS_REALPATH_HPP__
+
+
+#include <stout/result.hpp>
+
+#ifdef __WINDOWS__
+#include <stout/windows.hpp>
+#endif
+
+
+namespace os {
+
+inline Result<std::string> realpath(const std::string& path)
+{
+ char temp[PATH_MAX];
+ if (::realpath(path.c_str(), temp) == NULL) {
+ if (errno == ENOENT || errno == ENOTDIR) {
+ return None();
+ }
+ return ErrnoError();
+ }
+ return std::string(temp);
+}
+
+} // namespace os {
+
+#endif // __STOUT_OS_REALPATH_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/b7f88463/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/exists.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/exists.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/exists.hpp
index ddcda7b..995b818 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/exists.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/exists.hpp
@@ -18,21 +18,17 @@
#include <stout/windows.hpp>
+#include <stout/os/realpath.hpp>
+
namespace os {
inline bool exists(const std::string& path)
{
- // TODO(hausdorff): (MESOS-3386) os.hpp is not yet fully ported to Windows,
- // but when it is, we should change this to use `os::realpath` instead,
- // rather than the raw `::realpath` API.
- //
- // NOTE: `::realpath` will correctly error out if path length is greater than
- // `PATH_MAX`.
- char absolutePath[PATH_MAX];
+ Result<std::string> absolutePath = os::realpath(path);
- if (::realpath(path.c_str(), absolutePath) == NULL) {
+ if (!absolutePath.isSome()) {
return false;
}
@@ -40,7 +36,7 @@ inline bool exists(const std::string& path)
// "documentation"[1] for why this is a check-if-file-exists idiom.
//
// [1] http://blogs.msdn.com/b/oldnewthing/archive/2007/10/23/5612082.aspx
- DWORD attributes = GetFileAttributes(absolutePath);
+ DWORD attributes = GetFileAttributes(absolutePath.get().c_str());
bool fileNotFound = GetLastError() == ERROR_FILE_NOT_FOUND;