13 #ifndef __STOUT_OS_WINDOWS_STAT_HPP__ 14 #define __STOUT_OS_WINDOWS_STAT_HPP__ 17 #include <type_traits> 40 const std::string&
path,
56 return attributes.
get() & FILE_ATTRIBUTE_DIRECTORY;
63 BY_HANDLE_FILE_INFORMATION info;
64 const BOOL result = ::GetFileInformationByHandle(fd, &info);
65 if (result == FALSE) {
69 return info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
74 const std::string& path,
96 return !(attributes.
get() & FILE_ATTRIBUTE_DIRECTORY);
100 inline bool islink(
const std::string& path)
113 const std::string& path,
120 return Error(
"Error obtaining handle to file: " + handle.
error());
123 LARGE_INTEGER file_size;
125 if (::GetFileSizeEx(handle->
get_handle(), &file_size) == 0) {
129 return Bytes(file_size.QuadPart);
135 LARGE_INTEGER file_size;
137 if (::GetFileSizeEx(fd, &file_size) == 0) {
141 return Bytes(file_size.QuadPart);
146 const std::string& path,
151 "Requested mtime for '" + path +
152 "', but symbolic links don't have an mtime on Windows");
166 ::GetFileTime(handle->
get_handle(),
nullptr,
nullptr, &filetime);
167 if (result == FALSE) {
175 return static_cast<long>(unixtime);
183 const std::string& path,
188 const std::string& path,
193 const std::string& path,
199 #endif // __STOUT_OS_WINDOWS_STAT_HPP__
Try< SharedHandle > get_handle_no_follow(const std::string &absolute_path)
Definition: reparsepoint.hpp:215
bool isfile(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:108
Definition: errorbase.hpp:36
Try< Bytes > size(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:130
T & get()&
Definition: try.hpp:80
HANDLE get_handle() const
Definition: windows.hpp:90
bool islink(const std::string &path)
Definition: stat.hpp:80
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:65
Definition: error.hpp:108
Try< long > mtime(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:155
Definition: posix_signalhandler.hpp:23
Try< ino_t > inode(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:211
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:181
double windows_to_unix_epoch(const FILETIME &filetime)
Definition: os.hpp:87
bool isSome() const
Definition: try.hpp:77
Try< struct::stat > stat(const int_fd fd)
Definition: stat.hpp:68
static Try error(const E &e)
Definition: try.hpp:43
Try< SharedHandle > get_handle_follow(const std::string &absolute_path)
Definition: reparsepoint.hpp:155
bool isError() const
Definition: try.hpp:78
bool isdir(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:91
Try< mode_t > mode(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:168
std::wstring longpath(const std::string &path)
Definition: longpath.hpp:38
int int_fd
Definition: int_fd.hpp:35