23 lines
629 B
C++
23 lines
629 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(!variableDefined("name"))
|
|
throw coreutils::Exception("stream tag must have a file name to stream.");
|
|
global.outputHeaders();
|
|
int len;
|
|
char buffer[1024];
|
|
int fd = open(variables["name"].c_str(), O_RDONLY);
|
|
do {
|
|
len = read(fd, &buffer, 1024);
|
|
std::cout << buffer;
|
|
} while (len > 0);
|
|
}
|
|
}
|
|
|