JetCore/__read.cpp
2024-07-11 15:25:48 -07:00

22 lines
662 B
C++

#include "__read.h"
#include "Exception.h"
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
namespace jet {
__read::__read(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
if(!variableDefined("file"))
throw coreutils::Exception("file keyword must be specified.");
if(!variableDefined("name"))
throw coreutils::Exception("name keyword must be specified.");
if(hasContainer)
throw coreutils::Exception("read tag does not have a container.");
fd = open(variables["file"].c_str(), O_RDONLY);
global.variables[variables["name"]].read(fd);
close(fd);
}
}