13 #ifndef __STOUT_OS_WINDOWS_STAT_HPP__
14 #define __STOUT_OS_WINDOWS_STAT_HPP__
28 #ifdef _USE_32BIT_TIME_T
29 #error "Implementation of `os::stat::mtime` assumes 64-bit `time_t`."
30 #endif // _USE_32BIT_TIME_T
37 inline bool islink(
const std::string& path);
40 const std::string& path,
56 return attributes.
get() & FILE_ATTRIBUTE_DIRECTORY;
61 const std::string& path,
83 return !(attributes.
get() & FILE_ATTRIBUTE_DIRECTORY);
87 inline bool islink(
const std::string& path)
100 const std::string& path,
107 return Error(
"Error obtaining handle to file: " + handle.
error());
110 LARGE_INTEGER file_size;
112 if (::GetFileSizeEx(handle->
get_handle(), &file_size) == 0) {
116 return Bytes(file_size.QuadPart);
122 const std::string& path,
131 "Requested mtime for '" + path +
132 "', but symbolic links don't have an mtime on Windows");
138 if (::_stat(path.c_str(), &s) < 0) {
139 return ErrnoError(
"Error invoking stat for '" + path +
"'");
147 std::is_same<__int64, __time64_t>::value,
148 "Mesos assumes `__time64_t` is represented as `__int64`");
149 return static_cast<long>(s.st_mtime);
155 const std::string& path,
161 return Error(
"lstat not supported for symlink '" + path +
"'");
164 if (::_stat(path.c_str(), &s) < 0) {
165 return ErrnoError(
"Error invoking stat for '" + path +
"'");
174 const std::string& path,
180 return Error(
"lstat not supported for symlink '" + path +
"'");
183 if (::_stat(path.c_str(), &s) < 0) {
184 return ErrnoError(
"Error invoking stat for '" + path +
"'");
193 const std::string& path,
199 return Error(
"Non-following stat not supported for '" + path +
"'");
202 if (::_stat(path.c_str(), &s) < 0) {
203 return ErrnoError(
"Error invoking stat for '" + path +
"'");
212 #endif // __STOUT_OS_WINDOWS_STAT_HPP__
Try< SharedHandle > get_handle_no_follow(const std::string &absolute_path)
Definition: reparsepoint.hpp:212
bool isfile(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:87
Definition: errorbase.hpp:35
Try< Bytes > size(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:100
HANDLE get_handle() const
Definition: windows.hpp:96
bool islink(const std::string &path)
Definition: stat.hpp:67
Try< DWORD > get_file_attributes(const std::wstring &path)
Definition: attributes.hpp:27
Try< Nothing > symlink(const std::string &original, const std::string &link)
Definition: fs.hpp:54
Definition: error.hpp:106
Definition: errorbase.hpp:49
Try< long > mtime(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:113
Try< ino_t > inode(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:169
FollowSymlink
Definition: reparsepoint.hpp:35
Try< SymbolicLink > query_symbolic_link_data(const std::string &path)
Definition: symlink.hpp:79
Try< dev_t > dev(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:139
bool isSome() const
Definition: try.hpp:70
Try< hashmap< std::string, uint64_t > > stat(const std::string &hierarchy, const std::string &cgroup, const std::string &file)
static Try error(const E &e)
Definition: try.hpp:42
Try< SharedHandle > get_handle_follow(const std::string &absolute_path)
Definition: reparsepoint.hpp:155
bool isError() const
Definition: try.hpp:71
bool isdir(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:78
Try< mode_t > mode(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:126
std::wstring longpath(const std::string &path)
Definition: longpath.hpp:38
const T & get() const
Definition: try.hpp:73