Initia; coding of write. Sync

This commit is contained in:
Brad Arant committed 2024-07-18 16:34:11 -07:00
1 parent 15f7b08d68
commit a63b60bab7
3 files changed
+55

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
#include "__write.h"
#include "Exception.h"
#include "Expression.h"
#include <iostream>
namespace jet {
__write::__set(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
output = false;
processContainer(container);
if(!variableDefined("file"))
throw coreutils::Exception("write tag must have file defined.");
if(!variableDefined("expr") && variableDefined("value") && hasContainer)
throw coreutils::Exception("write tag cannot have both value and a container.");
if(variableDefined("expr") && !variableDefined("value") && hasContainer)
throw coreutils::Exception("write tag cannot have both expr and a container.");
if(variableDefined("expr") && variableDefined("value") && !hasContainer)
throw coreutils::Exception("write tag cannot have both expr and value.");
if(!variableDefined("expr") && !variableDefined("value") && !hasContainer)
throw coreutils::Exception("write tag must have a value, expr or a container.");
if(variableDefined("scope"))
throw coreutils::Exception("Cannot use scope with write tag.");
int fd = open(variables["file"], O_APPEND | O_TRUNC); // <--- options go here need to pick one
close(fd);
}
}