25 lines
363 B
C++
25 lines
363 B
C++
#pragma once
|
|
|
|
#include "outputstream.h"
|
|
#include "stub.h"
|
|
|
|
class IOStream : public OutputStream {
|
|
private:
|
|
IOStream(IOStream ©); // no copy
|
|
int fd;
|
|
|
|
public:
|
|
explicit IOStream(int sysfd = 0) : fd(sysfd) {}
|
|
|
|
~IOStream() {
|
|
if (pos > 0) {
|
|
sys_write(fd, buffer, pos);
|
|
}
|
|
}
|
|
|
|
void flush() override {
|
|
sys_write(fd, buffer, pos);
|
|
pos = 0;
|
|
}
|
|
};
|