ref: 3df1fd41a90bcd4e751adad72e9cde9ff02124c0
parent: 64dbbe0f4dbd1354374b926eae6b03201b1ad161
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Jan 5 22:34:53 EST 2025
add delete-file This is only for file and _empty_ directories for now. References: https://todo.sr.ht/~ft/femtolisp/38
--- a/builtins.c
+++ b/builtins.c
@@ -379,8 +379,17 @@
BUILTIN("path-exists?", path_existsp)
{
argcount(nargs, 1);
- char *path = tostring(args[0]);
+ const char *path = tostring(args[0]);
return access(path, F_OK) == 0 ? FL_t : FL_f;
+}
+
+BUILTIN("delete-file", delete_file)
+{
+ argcount(nargs, 1);
+ const char *path = tostring(args[0]);
+ if(remove(path) != 0)
+ lerrorf(FL_IOError, "could not remove %s", path);
+ return FL_void;
}
BUILTIN("os-getenv", os_getenv)