shithub: femtolisp

Download patch

ref: ab283cbf3a865048614eb4f790e3639f70b77f5d
parent: 3f23591b324cee2aff71267745dc699cd6567948
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Dec 24 12:21:20 EST 2024

add io-set-filename!

--- a/iostream.c
+++ b/iostream.c
@@ -347,6 +347,16 @@
 	return string_from_cstr(toiostream(args[0])->loc.filename);
 }
 
+BUILTIN("io-set-filename!", io_set_filename)
+{
+	argcount(nargs, 2);
+	ios_t *s = toiostream(args[0]);
+	char *f = tostring(args[1]);
+	MEM_FREE(s->loc.filename);
+	s->loc.filename = MEM_STRDUP(f);
+	return args[1];
+}
+
 BUILTIN("io-line", io_line)
 {
 	argcount(nargs, 1);