12 #ifndef __STOUT_OS_WINDOWS_RM_HPP__
13 #define __STOUT_OS_WINDOWS_RM_HPP__
41 for (
int i = 0; i < 10; ++i) {
43 const DWORD attributes =
45 CHECK_EQ(attributes, INVALID_FILE_ATTRIBUTES);
46 const DWORD
error = ::GetLastError();
48 if (error == ERROR_ACCESS_DENIED) {
49 LOG(WARNING) <<
"Waiting for file " << path <<
" to be deleted";
51 }
else if (error == ERROR_FILE_NOT_FOUND) {
59 return Error(
"Timed out when waiting for file " + path +
" to be deleted");
86 ? ::RemoveDirectoryW(longpath.data())
87 : ::DeleteFileW(longpath.data());
100 return Error(
"wait_on_delete failed " + deleted.
error());
108 #endif // __STOUT_OS_WINDOWS_RM_HPP__
Definition: nothing.hpp:16
Definition: errorbase.hpp:35
Try< Nothing > rm(const std::string &path)
Definition: rm.hpp:26
Try< Nothing > sleep(const Duration &duration)
Definition: os.hpp:234
Definition: error.hpp:106
Try< Nothing > wait_on_delete(const std::string &path)
Definition: rm.hpp:38
Definition: duration.hpp:245
static Try error(const E &e)
Definition: try.hpp:42
bool isError() const
Definition: try.hpp:71
std::string error(const std::string &msg, uint32_t code)
bool isdir(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:78
std::wstring longpath(const std::string &path)
Definition: longpath.hpp:38