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

+1
View File
@@ -11,3 +11,4 @@ itself is not passwed to the output and will not appear in the output.
Skip Blank Lines options on containers will skip passing any blank
lines or line containing only whitespace to the output.
+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);
}
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef __write_h__
#define __write_h__
#include "Tag.h"
#include "ZString.h"
#include "MString.h"
#include <sstream>
namespace jet {
class __write : public Tag {
public:
__write(coreutils::ZString &in, coreutils::MString &parent, Global &global);
protected:
};
}
#endif