This commit is contained in:
Brad Arant committed 2024-12-02 15:46:49 -08:00
1 parent ae57e06778
commit 90540d3c44
8 files changed
+493 -13

No files matched your search

+11 -5
View File
@@ -1,16 +1,22 @@
#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.");
// TODO: Output headers that have been written so far.
// TODO: Open file with fairly small buffer size and write to end to cout and not the out buffers.
// TODO: Force no further output from jet-2.0 at end of 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);
}
}