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:38:57 UTC

[11/50] mesos git commit: Windows: Replaced use of `_stat()` in `reparsepoint.hpp`.

Windows: Replaced use of `_stat()` in `reparsepoint.hpp`.

This reworks some code which did not support long paths.

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


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

Branch: refs/heads/master
Commit: 06162f6a29f7d056cc6343151c5eb3b8f7128e38
Parents: 7fdd28d
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Fri Jul 7 14:06:41 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:33 2017 -0700

----------------------------------------------------------------------
 .../stout/internal/windows/reparsepoint.hpp     | 24 ++++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/06162f6a/3rdparty/stout/include/stout/internal/windows/reparsepoint.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/internal/windows/reparsepoint.hpp b/3rdparty/stout/include/stout/internal/windows/reparsepoint.hpp
index dcadfed..066c192 100644
--- a/3rdparty/stout/include/stout/internal/windows/reparsepoint.hpp
+++ b/3rdparty/stout/include/stout/internal/windows/reparsepoint.hpp
@@ -179,14 +179,15 @@ inline Try<SymbolicLink> build_symbolic_link(const REPARSE_DATA_BUFFER& data)
 // refer to the symlink rather than the file or folder the symlink points at.
 inline Try<SharedHandle> get_handle_no_follow(const std::string& absolute_path)
 {
-  struct _stat absolute_path_stat;
-  bool resolved_path_is_directory = false;
-  if (::_stat(absolute_path.c_str(), &absolute_path_stat) == 0) {
-    resolved_path_is_directory = S_ISDIR(absolute_path_stat.st_mode);
-  } else {
-    return ErrnoError("'_stat' failed on path '" + absolute_path + "'");
+  const Try<DWORD> attributes = ::internal::windows::get_file_attributes(
+      wide_stringify(absolute_path));
+
+  if (attributes.isError()) {
+    return Error(attributes.error());
   }
 
+  bool resolved_path_is_directory = attributes.get() & FILE_ATTRIBUTE_DIRECTORY;
+
   // NOTE: According to the `CreateFile` documentation[1], the `OPEN_EXISTING`
   // and `FILE_FLAG_OPEN_REPARSE_POINT` flags need to be used when getting a
   // handle for the symlink.
@@ -319,16 +320,19 @@ inline Try<Nothing> create_symbolic_link(
 
   // Determine if target is a folder or a file. This makes a difference
   // in the way we call `create_symbolic_link`.
-  struct _stat absolute_target_path_stat;
-  if (::_stat(absolute_target_path.c_str(), &absolute_target_path_stat) != 0) {
-    return ErrnoError("'_stat' failed on path '" + absolute_target_path + "'");
+  const Try<DWORD> attributes = ::internal::windows::get_file_attributes(
+      wide_stringify(absolute_target_path));
+
+  if (attributes.isError()) {
+    return Error(attributes.error());
   }
 
-  const bool target_is_folder = S_ISDIR(absolute_target_path_stat.st_mode);
+  const bool target_is_folder = attributes.get() & FILE_ATTRIBUTE_DIRECTORY;
 
   // Bail out if target is already a reparse point.
   Try<bool> attribute_set = reparse_point_attribute_set(
       longpath(absolute_target_path));
+
   if (!attribute_set.isSome()) {
     return Error(
         "Could not get reparse point attribute for '" + absolute_target_path +