libscio/fdostream.cpp

29 lines
536 B
C++
Raw Normal View History

2020-02-14 18:17:17 +01:00
//
// fdostream.cpp
// libscio
//
// Created by Bob Polis at 2020-02-14
// Copyright (c) 2020 SwiftCoder. All rights reserved.
//
#include "fdostream.hpp"
#ifdef _MSC_VER
#include <io.h>
#else
#include <unistd.h>
#endif
std::streambuf::int_type sc::io::fdoutbuf::overflow(std::streambuf::int_type c) {
if (c != EOF) {
if (::write(_fd, &c, 1) != 1) {
return EOF;
}
}
return c;
}
std::streamsize sc::io::fdoutbuf::xsputn(const char* s, std::streamsize num) {
return ::write(_fd, s, num);
}