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:02 UTC
[16/50] mesos git commit: Windows: Refactored
`reparse_point_attribute_set()`.
Windows: Refactored `reparse_point_attribute_set()`.
It now takes a `std::wstring` and uses `get_file_attributes()`.
Review: https://reviews.apache.org/r/60305/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/28fd2104
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/28fd2104
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/28fd2104
Branch: refs/heads/master
Commit: 28fd210467b64df8797343ae9d2b397c5c1dc0a2
Parents: 0cbc033
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Jul 5 16:53:24 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:33 2017 -0700
----------------------------------------------------------------------
.../stout/internal/windows/reparsepoint.hpp | 21 +++++++++++---------
.../include/stout/internal/windows/symlink.hpp | 5 +++--
2 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/28fd2104/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 a922843..61c4084 100644
--- a/3rdparty/stout/include/stout/internal/windows/reparsepoint.hpp
+++ b/3rdparty/stout/include/stout/internal/windows/reparsepoint.hpp
@@ -24,6 +24,9 @@
#include <stout/os/mkdir.hpp>
#include <stout/os/realpath.hpp>
+#include <stout/internal/windows/attributes.hpp>
+#include <stout/internal/windows/longpath.hpp>
+
// We pass this struct to `DeviceIoControl` to get information about a reparse
// point (including things like whether it's a symlink). It is normally part of
// the Device Driver Kit (DDK), specifically `nitfs.h`, but rather than taking
@@ -112,15 +115,14 @@ struct SymbolicLink
// Checks file/folder attributes for a path to see if the reparse point
// attribute is set; this indicates whether the path points at a reparse point,
// rather than a "normal" file or folder.
-inline Try<bool> reparse_point_attribute_set(const std::string& absolute_path)
+inline Try<bool> reparse_point_attribute_set(const std::wstring& absolute_path)
{
- const DWORD attributes = ::GetFileAttributes(absolute_path.c_str());
- if (attributes == INVALID_FILE_ATTRIBUTES) {
- return WindowsError(
- "Failed to get attributes for file '" + absolute_path + "'");
+ const Try<DWORD> attributes = get_file_attributes(absolute_path.data());
+ if (attributes.isError()) {
+ return Error(attributes.error());
}
- return (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
+ return (attributes.get() & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
}
@@ -192,8 +194,8 @@ inline Try<SharedHandle> get_handle_no_follow(const std::string& absolute_path)
? (FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS)
: FILE_FLAG_OPEN_REPARSE_POINT;
- const HANDLE handle = ::CreateFile(
- absolute_path.c_str(),
+ const HANDLE handle = ::CreateFileW(
+ longpath(absolute_path).data(),
GENERIC_READ, // Open the file for reading only.
FILE_SHARE_READ, // Just reading this file, allow others to do the same.
nullptr, // Ignored.
@@ -307,7 +309,8 @@ inline Try<Nothing> create_symbolic_link(
const bool target_is_folder = S_ISDIR(absolute_target_path_stat.st_mode);
// Bail out if target is already a reparse point.
- Try<bool> attribute_set = reparse_point_attribute_set(absolute_target_path);
+ 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 +
http://git-wip-us.apache.org/repos/asf/mesos/blob/28fd2104/3rdparty/stout/include/stout/internal/windows/symlink.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/internal/windows/symlink.hpp b/3rdparty/stout/include/stout/internal/windows/symlink.hpp
index 5dc022b..b9cf122 100644
--- a/3rdparty/stout/include/stout/internal/windows/symlink.hpp
+++ b/3rdparty/stout/include/stout/internal/windows/symlink.hpp
@@ -18,6 +18,7 @@
#include <stout/try.hpp>
#include <stout/windows.hpp>
+#include <stout/internal/windows/longpath.hpp>
#include <stout/internal/windows/reparsepoint.hpp>
#include <stout/os/realpath.hpp>
@@ -59,8 +60,8 @@ inline Try<SymbolicLink> query_symbolic_link_data(const std::string& path)
// Windows has no built-in way to tell whether a path points at a symbolic
// link; but, we know that symbolic links are implemented with reparse
// points, so we begin by checking that.
- Try<bool> is_reparse_point =
- reparse_point_attribute_set(absolute_path.get());
+ Try<bool> is_reparse_point = reparse_point_attribute_set(
+ ::internal::windows::longpath(absolute_path.get()));
if (is_reparse_point.isError()) {
return Error(is_reparse_point.error());