aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAstatin <[email protected]>2025-07-19 16:26:23 +0200
committerAstatin <[email protected]>2025-07-19 16:26:23 +0200
commitc079ea62115ba72454244cf6e4aca38ccabd0b04 (patch)
treeec36a2f02b8067651d73deee995a091a995b6188
parent9adada8eee304dbd665f97b9c5ca2726473f8212 (diff)
Add .INCLUDEBIN macro
-rw-r--r--macros.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/macros.go b/macros.go
index a923082..83b70e4 100644
--- a/macros.go
+++ b/macros.go
@@ -165,6 +165,20 @@ func MacroParse(
}
*result = append(*result, included...)
}
+ } else if macroName == ".INCLUDEBIN" && !state.IsMacro {
+ filePath := strings.Trim(strings.TrimSpace(strings.TrimPrefix(line, ".INCLUDEBIN")), "\"'")
+
+ input_file, err := os.Open(filePath)
+ if err != nil {
+ return fmt.Errorf("Error while opening file %s", filePath)
+ }
+
+ input, err := io.ReadAll(input_file)
+ if err != nil {
+ return fmt.Errorf("Error while reading file %s", filePath)
+ }
+
+ *result = append(*result, input...)
} else if macroName == ".DEFINE" && !state.IsMacro {
if len(words) != 3 {
return fmt.Errorf(".DEFINE must have 2 arguments (%v)", words)