22 lines
606 B
C++
22 lines
606 B
C++
#include "__read.h"
|
|
#include "Exception.h"
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
|
|
namespace jet {
|
|
|
|
__read::__read(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
|
if(!variableDefined(coreutils::ZString("file")))
|
|
throw coreutils::Exception("file keyword must be specified.");
|
|
if(hasContainer)
|
|
throw coreutils::Exception("read tag does not have a container.");
|
|
fd = open(variables["file"], O_RDONLY);
|
|
while(len = read(fd, &buffer, sizeof(buffer - 1))) {
|
|
buffer[len] = 0;
|
|
out << buffer;
|
|
}
|
|
close(fd);
|
|
}
|
|
|
|
}
|