// // fdostream.cpp // libscio // // Created by Bob Polis at 2020-02-14 // Copyright (c) 2020 SwiftCoder. All rights reserved. // #include "libscio.hpp" #ifdef _MSC_VER #include #else #include #endif std::streambuf::int_type sc::io::fdoutbuf::overflow(std::streambuf::int_type c) { if (c != EOF) { int res; if ((res = ::write(_fd, &c, 1)) != 1) { return EOF; } else { std::cerr << "write result = " << res << ", errno = " << errno << '\n'; } } return c; } std::streamsize sc::io::fdoutbuf::xsputn(const char* s, std::streamsize num) { int res = ::write(_fd, s, num); if (res != num) { std::cerr << "write result = " << res << ", errno = " << errno << '\n'; return EOF; } return res; }