13 #ifndef __STOUT_WINDOWS_FS_HPP__ 14 #define __STOUT_WINDOWS_FS_HPP__ 37 "Failed to get realpath for '" +
path+
"': " +
38 (real_path.
isError() ? real_path.
error() :
"No such directory"));
41 ULARGE_INTEGER free_bytes, total_bytes, total_free_bytes;
42 if (::GetDiskFreeSpaceExW(
46 &total_free_bytes) == 0) {
48 "Error invoking 'GetDiskFreeSpaceEx' on '" +
path +
"'");
51 return Bytes(total_bytes.QuadPart);
62 "Failed to get realpath for '" +
path +
"': " +
63 (real_path.
isError() ? real_path.
error() :
"No such directory"));
66 ULARGE_INTEGER free_bytes, total_bytes, total_free_bytes;
67 if (::GetDiskFreeSpaceExW(
71 &total_free_bytes) == 0) {
73 "Error invoking 'GetDiskFreeSpaceEx' on '" +
path +
"'");
76 double used =
static_cast<double>(total_bytes.QuadPart - free_bytes.QuadPart);
77 return used / total_bytes.QuadPart;
82 const std::string& original,
83 const std::string& link)
95 const std::string dirname(
Path(pattern).dirname());
96 std::list<std::string> found_files;
97 WIN32_FIND_DATAW found;
99 ::FindFirstFileW(wide_stringify(pattern).data(), &found),
102 if (search_handle.get() == INVALID_HANDLE_VALUE) {
105 const DWORD
error = ::GetLastError();
106 if (error == ERROR_FILE_NOT_FOUND || error == ERROR_PATH_NOT_FOUND) {
114 const std::wstring current_file(found.cFileName);
117 if (current_file.compare(L
".") != 0 && current_file.compare(L
"..") != 0) {
120 }
while (::FindNextFileW(search_handle.get(), &found));
122 const DWORD error = ::GetLastError();
123 if (error != ERROR_NO_MORE_FILES) {
132 #endif // __STOUT_WINDOWS_FS_HPP__
Definition: errorbase.hpp:36
Definition: windows.hpp:72
Result< std::string > realpath(const std::string &path)
Definition: realpath.hpp:24
static Result< T > error(const std::string &message)
Definition: result.hpp:54
Try< Nothing > symlink(const std::string &original, const std::string &link)
Definition: fs.hpp:65
Definition: error.hpp:108
std::string join(const std::string &path1, const std::string &path2, const char _separator=os::PATH_SEPARATOR)
Definition: path.hpp:116
Try< Bytes > size(const std::string &path="/")
Definition: fs.hpp:32
Try< std::list< std::string > > list(const std::string &pattern)
Definition: fs.hpp:86
Try< Bytes > used(const std::string &path="/")
Definition: fs.hpp:43
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:212
Try< double > usage(const std::string &path="/")
Definition: fs.hpp:55
std::string error(const std::string &msg, uint32_t code)
T & get()&
Definition: result.hpp:116
bool isSome() const
Definition: result.hpp:112
bool isError() const
Definition: result.hpp:114
std::wstring longpath(const std::string &path)
Definition: longpath.hpp:38
std::string stringify(int flags)
Try< Nothing > create_symbolic_link(const std::string &target, const std::string &reparse_point)
Definition: reparsepoint.hpp:321