diff options
author | Astatin <[email protected]> | 2025-07-19 16:26:23 +0200 |
---|---|---|
committer | Astatin <[email protected]> | 2025-07-19 16:26:23 +0200 |
commit | c079ea62115ba72454244cf6e4aca38ccabd0b04 (patch) | |
tree | ec36a2f02b8067651d73deee995a091a995b6188 | |
parent | 9adada8eee304dbd665f97b9c5ca2726473f8212 (diff) |
Add .INCLUDEBIN macro
-rw-r--r-- | macros.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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) |