13 #ifndef __STOUT_OS_WRITE_HPP__ 14 #define __STOUT_OS_WRITE_HPP__ 36 namespace signal_safe {
42 while (offset < count) {
51 int error = ::GetLastError();
73 return write_impl(fd, message, std::strlen(message));
79 return write_impl(fd, message.data(), message.length());
83 template <
typename T,
typename... Args>
91 return write(fd, args...);
106 #endif // __WINDOWS__ 116 const std::string&
path,
117 const std::string& message,
122 O_WRONLY | O_CREAT | O_TRUNC |
O_CLOEXEC,
131 if (sync && write.isSome()) {
141 if (write.isSome() && close.isError()) {
154 const std::string& message,
157 return write(std::string(path), message, sync);
163 #endif // __STOUT_OS_WRITE_HPP__ SSIZE_T ssize_t
Definition: windows.hpp:186
Definition: nothing.hpp:16
Definition: errorbase.hpp:36
const mode_t S_IRGRP
Definition: windows.hpp:313
T & get()&
Definition: try.hpp:80
ssize_t write(const int_fd &fd, const void *data, size_t size)
Definition: write.hpp:72
const mode_t S_IWUSR
Definition: windows.hpp:306
Try< int_fd > open(const std::string &path, int oflag, mode_t mode=0)
Definition: open.hpp:35
Definition: error.hpp:108
Definition: errorbase.hpp:50
Definition: posix_signalhandler.hpp:23
const mode_t S_IRUSR
Definition: windows.hpp:305
bool is_restartable_error(int error)
Definition: socket.hpp:65
constexpr int O_CLOEXEC
Definition: open.hpp:41
Try< Nothing > close(int fd)
Definition: close.hpp:24
static Try error(const E &e)
Definition: try.hpp:43
Try< Nothing > fsync(int fd)
Definition: fsync.hpp:29
ssize_t write_impl(int_fd fd, const char *buffer, size_t count)
Definition: write.hpp:38
bool isError() const
Definition: try.hpp:78
std::string error(const std::string &msg, uint32_t code)
int int_fd
Definition: int_fd.hpp:35
std::string stringify(int flags)
const mode_t S_IROTH
Definition: windows.hpp:321
ssize_t write(int_fd fd, const char *message)
Definition: write.hpp:70