36 lines
540 B
C++
36 lines
540 B
C++
//
|
|
// fdistream.cpp
|
|
// libscio
|
|
//
|
|
// Created by Bob Polis at 2020-02-14
|
|
// Copyright (c) 2020 SwiftCoder. All rights reserved.
|
|
//
|
|
|
|
#include "libscio.hpp"
|
|
|
|
#ifdef _MSC_VER
|
|
#include <io.h>
|
|
#else
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
using namespace sc::io;
|
|
|
|
std::streambuf::int_type fdinbuf::uflow() {
|
|
return _ch;
|
|
}
|
|
|
|
std::streambuf::int_type fdinbuf::underflow() {
|
|
char c;
|
|
int num = read(_fd, &c, 1);
|
|
if (num <= 0) {
|
|
_ch = EOF;
|
|
}
|
|
_ch = c;
|
|
return _ch;
|
|
}
|
|
|
|
std::streamsize fdinbuf::xsgetn(char* s, std::streamsize n) {
|
|
return read(_fd, s, n);
|
|
}
|