Apache Mesos
attributes.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 
13 #ifndef __STOUT_INTERNAL_WINDOWS_ATTRIBUTES_HPP__
14 #define __STOUT_INTERNAL_WINDOWS_ATTRIBUTES_HPP__
15 
16 #include <string>
17 
18 #include <stout/error.hpp>
19 #include <stout/stringify.hpp>
20 #include <stout/try.hpp>
21 #include <stout/windows.hpp>
22 
23 
24 namespace internal {
25 namespace windows {
26 
27 inline Try<DWORD> get_file_attributes(const std::wstring& path) {
28  const DWORD attributes = ::GetFileAttributesW(path.data());
29  if (attributes == INVALID_FILE_ATTRIBUTES) {
30  return WindowsError(
31  "Failed to get attributes for file '" + stringify(path) + "'");
32  }
33  return attributes;
34 }
35 
36 } // namespace windows {
37 } // namespace internal {
38 
39 #endif // __STOUT_INTERNAL_WINDOWS_ATTRIBUTES_HPP__
Definition: path.hpp:29
Definition: check.hpp:33
Try< DWORD > get_file_attributes(const std::wstring &path)
Definition: attributes.hpp:27
Definition: error.hpp:108
Definition: attributes.hpp:24
std::string stringify(int flags)