13 #ifndef __STOUT_OS_WINDOWS_WRITE_HPP__ 14 #define __STOUT_OS_WINDOWS_WRITE_HPP__ 35 OVERLAPPED* overlapped)
37 CHECK_LE(size, UINT_MAX);
43 ::WriteFile(fd, data, static_cast<DWORD>(size), &bytes, overlapped);
49 std::is_same<OVERLAPPED, WSAOVERLAPPED>::value,
50 "Expected `WSAOVERLAPPED` to be of type `OVERLAPPED`.");
56 static_cast<u_long
>(
size),
57 static_cast<char*>(const_cast<void*>(data))
62 ::WSASend(fd, &buf, 1, &bytes, 0, overlapped,
nullptr);
74 CHECK_LE(size, INT_MAX);
80 if (!fd.is_overlapped()) {
83 ::WriteFile(fd, data, static_cast<DWORD>(size), &bytes,
nullptr);
85 if (result == FALSE) {
90 return static_cast<ssize_t>(bytes);
102 OVERLAPPED overlapped = overlapped_.
get();
115 const BOOL wait_success =
116 ::GetOverlappedResult(fd, &overlapped, &bytes, TRUE);
118 if (wait_success == FALSE) {
122 return static_cast<ssize_t>(bytes);
125 return ::send(fd, (
const char*)data, static_cast<int>(size), 0);
135 #endif // __STOUT_OS_WINDOWS_WRITE_HPP__ SSIZE_T ssize_t
Definition: windows.hpp:186
Try< Bytes > size(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:130
T & get()&
Definition: try.hpp:80
ssize_t write(const int_fd &fd, const void *data, size_t size)
Definition: write.hpp:72
Try< OVERLAPPED > init_overlapped_for_sync_io()
Definition: overlapped.hpp:30
Result< size_t > process_async_io_result(bool successful_return_code, size_t bytes_transfered)
Definition: overlapped.hpp:71
Definition: posix_signalhandler.hpp:23
Result< size_t > write_async(const int_fd &fd, const void *data, size_t size, OVERLAPPED *overlapped)
Definition: write.hpp:31
#define UNREACHABLE()
Definition: unreachable.hpp:22
bool isError() const
Definition: try.hpp:78
T & get()&
Definition: result.hpp:116
bool isSome() const
Definition: result.hpp:112
bool isError() const
Definition: result.hpp:114
int int_fd
Definition: int_fd.hpp:35
Future< size_t > send(const int_fd &fd, const void *buf, size_t size)