13 #ifndef __STOUT_OS_WINDOWS_OPEN_HPP__ 14 #define __STOUT_OS_WINDOWS_OPEN_HPP__ 63 const DWORD
write = (oflag & O_APPEND) ? FILE_APPEND_DATA : GENERIC_WRITE;
66 switch (oflag & (O_RDONLY | O_WRONLY | O_RDWR)) {
68 access = GENERIC_READ;
76 access = GENERIC_READ |
write;
80 return Error(
"Access mode not specified.");
86 switch (oflag & (O_CREAT | O_EXCL | O_TRUNC)) {
92 case O_CREAT | O_EXCL:
93 case O_CREAT | O_EXCL | O_TRUNC: {
99 case O_CREAT | O_TRUNC: {
101 create = CREATE_ALWAYS;
105 case O_EXCL | O_TRUNC: {
106 return Error(
"`O_EXCL` is undefined without `O_CREAT`.");
110 create = TRUNCATE_EXISTING;
115 create = OPEN_EXISTING;
120 const HANDLE handle = ::CreateFileW(
124 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
128 FILE_ATTRIBUTE_NORMAL,
132 if (handle == INVALID_HANDLE_VALUE) {
141 #endif // __STOUT_OS_WINDOWS_OPEN_HPP__
constexpr int O_NONBLOCK
Definition: open.hpp:31
Definition: errorbase.hpp:36
ssize_t write(const int_fd &fd, const void *data, size_t size)
Definition: write.hpp:72
constexpr int O_SYNC
Definition: open.hpp:37
Try< int_fd > open(const std::string &path, int oflag, mode_t mode=0)
Definition: open.hpp:35
Definition: error.hpp:108
Definition: posix_signalhandler.hpp:23
Try< bool > access(const std::string &path, int how)
Definition: access.hpp:28
int mode_t
Definition: windows.hpp:177
constexpr int O_CLOEXEC
Definition: open.hpp:41
constexpr Handle HANDLE
Definition: ingress.hpp:37
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
Try< Nothing > create(const std::string &hierarchy, const std::string &cgroup, bool recursive=false)