patch 9.0.0411: only created files can be cleaned up with one call
Problem: Only created files can be cleaned up with one call.
Solution: Add flags to mkdir() to delete with a deferred function.
Expand the writefile() name to a full path to handle changing
directory.
diff --git a/src/userfunc.c b/src/userfunc.c
index fea5b79..7b6034a 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -5650,6 +5650,21 @@
}
/*
+ * Return TRUE if currently inside a function call.
+ * Give an error message and return FALSE when not.
+ */
+ int
+can_add_defer(void)
+{
+ if (!in_def_function() && get_current_funccal() == NULL)
+ {
+ semsg(_(e_str_not_inside_function), "defer");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
* Add a deferred call for "name" with arguments "argvars[argcount]".
* Consumes "argvars[]".
* Caller must check that in_def_function() returns TRUE or current_funccal is