JetCore/__stream.cpp

23 lines
627 B
C++

#include "__stream.h"
#include "Exception.h"
#include <unistd.h>
#include <fcntl.h>
namespace jet {
__stream::__stream(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
output = false;
if(!keywordDefined("name"))
throw coreutils::Exception("stream tag must have a file name to stream.");
global.outputHeaders();
int len;
char buffer[1024];
int fd = open(keywords["name"].c_str(), O_RDONLY);
do {
len = read(fd, &buffer, 1024);
std::cout << buffer;
} while (len > 0);
}
}