void file_put_contents(const char *path, StreamBuffer contents, bool append){ const UniqueFile file(::open(path, O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC))); if(!file){ DEBUG_THROW(SystemException); } for(;;){ char write_buf[4096]; const std::size_t bytes_to_write = contents.get(write_buf, sizeof(write_buf)); if(bytes_to_write == 0){ break; } if(::write(file.get(), write_buf, bytes_to_write) < static_cast< ::ssize_t>(bytes_to_write)){ DEBUG_THROW(SystemException); } } }
int getFd() const { return m_socket.get(); }
void CopyFile(UniqueFile p_dst, FileDescriptor src_fd) { FileDescriptor::WriteContent(Nonnull(p_dst.get()), Nonnull(src_fd)); }