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/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 1de0e40..12d62a6 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -6239,8 +6239,26 @@
mkdir({name} [, {path} [, {prot}]])
Create directory {name}.
- If {path} is "p" then intermediate directories are created as
- necessary. Otherwise it must be "".
+ If {path} contains "p" then intermediate directories are
+ created as necessary. Otherwise it must be "".
+
+ If {path} contains "D" then {name} is deleted at the end of
+ the current function, as with: >
+ defer delete({name}, 'd')
+<
+ If {path} contains "R" then {name} is deleted recursively at
+ the end of the current function, as with: >
+ defer delete({name}, 'rf')
+< Note that when {name} has more than one part and "p" is used
+ some directories may already exist. Only the first one that
+ is created and what it contains is scheduled to be deleted.
+ E.g. when using: >
+ call mkdir('subdir/tmp/autoload', 'pR')
+< and "subdir" already exists then "subdir/tmp" will be
+ scheduled for deletion, like with: >
+ defer delete('subdir/tmp', 'rf')
+< Note that if scheduling the defer fails the directory is not
+ deleted. This should only happen when out of memory.
If {prot} is given it is used to set the protection bits of
the new directory. The default is 0o755 (rwxr-xr-x: r/w for