From c079ea62115ba72454244cf6e4aca38ccabd0b04 Mon Sep 17 00:00:00 2001 From: Astatin Date: Sat, 19 Jul 2025 16:26:23 +0200 Subject: Add .INCLUDEBIN macro --- macros.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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) -- cgit v1.2.3-70-g09d2