From 496b90a68043ed4639a387d15c53e72a092290a2 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Mon, 11 Nov 2024 09:57:14 -0800 Subject: [PATCH] Upgraded write tag to use resolution keyword method. --- __write.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/__write.cpp b/__write.cpp index 4c894e0..fb2095a 100644 --- a/__write.cpp +++ b/__write.cpp @@ -14,6 +14,7 @@ namespace jet { processContainer(container); if(!variableDefined("file")) throw coreutils::Exception("write tag must have file defined."); + resolveKeyword("file"); if(!variableDefined("expr") && variableDefined("value") && hasContainer) throw coreutils::Exception("write tag cannot have both value and a container."); if(variableDefined("expr") && !variableDefined("value") && hasContainer) @@ -22,17 +23,16 @@ namespace jet { 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."); if(!variableDefined("mode")) throw coreutils::Exception("write tag must have a mode keyword."); + resolveKeyword("mode"); if(variables["mode"] == "append") mode = O_APPEND; else if(variables["mode"] == "overwrite") mode = O_TRUNC; else throw coreutils::Exception("mode keyword must be 'overwrite' or 'append'."); - int fd = open(variables["file"].c_str(), mode, 0644); // Need to add O_CREAT and AUTH flags. + int fd = open(variables["file"].c_str(), mode, 0644); // TODO: Need to add O_CREAT and AUTH flags. if(hasContainer && !evaluate) len = write(fd, container.getData(), container.getLength()); else if(hasContainer && evaluate)