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:56 UTC

[10/50] mesos git commit: Windows: Added `get_file_attributes()` helper.

Windows: Added `get_file_attributes()` helper.

This wraps `::GetFileAttributesW()` into a `Try<DWORD>`, with error
handling, for easy reuse.

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


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

Branch: refs/heads/master
Commit: 4c939b6dd5c53e3df3454781761d34983e424370
Parents: cabb647
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Tue Jun 27 17:21:58 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:32 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/Makefile.am              |  1 +
 .../stout/internal/windows/attributes.hpp       | 39 ++++++++++++++++++++
 2 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4c939b6d/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/Makefile.am b/3rdparty/stout/include/Makefile.am
index 8e1799b..d5d209b 100644
--- a/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/stout/include/Makefile.am
@@ -39,6 +39,7 @@ nobase_include_HEADERS =			\
   stout/gzip.hpp				\
   stout/hashmap.hpp				\
   stout/hashset.hpp				\
+  stout/internal/windows/attributes.hpp		\
   stout/internal/windows/dirent.hpp		\
   stout/internal/windows/grp.hpp		\
   stout/internal/windows/longpath.hpp		\

http://git-wip-us.apache.org/repos/asf/mesos/blob/4c939b6d/3rdparty/stout/include/stout/internal/windows/attributes.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/internal/windows/attributes.hpp b/3rdparty/stout/include/stout/internal/windows/attributes.hpp
new file mode 100644
index 0000000..673b744
--- /dev/null
+++ b/3rdparty/stout/include/stout/internal/windows/attributes.hpp
@@ -0,0 +1,39 @@
+// 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_INTERNAL_WINDOWS_ATTRIBUTES_HPP__
+#define __STOUT_INTERNAL_WINDOWS_ATTRIBUTES_HPP__
+
+#include <string>
+
+#include <stout/error.hpp>
+#include <stout/stringify.hpp>
+#include <stout/try.hpp>
+#include <stout/windows.hpp>
+
+
+namespace internal {
+namespace windows {
+
+inline Try<DWORD> get_file_attributes(const std::wstring& path) {
+  const DWORD attributes = ::GetFileAttributesW(path.data());
+  if (attributes == INVALID_FILE_ATTRIBUTES) {
+    return WindowsError(
+        "Failed to get attributes for file '" + stringify(path) + "'");
+  }
+  return attributes;
+}
+
+} // namespace windows {
+} // namespace internal {
+
+#endif // __STOUT_INTERNAL_WINDOWS_ATTRIBUTES_HPP__