From 7d89e7fd88af561f315b9b390a27f48a1c150a07 Mon Sep 17 00:00:00 2001 From: David de Hilster Date: Wed, 14 Oct 2026 23:10:03 -0400 Subject: [PATCH] Help: mkdir makes parents, works the same on every platform, returns false on failure (engine 4.2.31, #323) Co-Authored-By: Claude Opus 5.5 --- Help/markdown/mkdir.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Help/markdown/mkdir.md b/Help/markdown/mkdir.md index 4306bbe..28c03d2 100644 --- a/Help/markdown/mkdir.md +++ b/Help/markdown/mkdir.md @@ -20,18 +20,26 @@ directoryStr- type: str ## Returns -True if successful execution of command. +True (1) if the directory exists afterwards, whether **mkdir** made it or it was already there. False (0) if it could not be made, for example because the path has a character the file system does not allow. ## Remarks -Mkdir depends on the machine or operating system in use.  Recommended to create one "level" of a directory path at a time, to assure that the code is portable. +**mkdir** makes any missing parent directories too, the same way on Windows, Linux and macOS. Forward slashes work on every platform. Spaces in the path need no quoting. + +From 4.2.31, **mkdir** creates the directory directly. Before 4.2.31 it ran the operating system's `mkdir` command, which caused these problems: + +- On Windows a path with forward slashes, such as `G("$apppath") + "/output"`, made nothing. +- A path with spaces broke. +- Characters such as `&` in the path were run as commands. +- It returned true even when nothing was made. ## Example ``` @CODE -mkdir("c:\abc\myfolder"); # This will work on Windows OS even if abc doesn't exist. +if (!mkdir(G("$apppath") + "/output/by date")) + "output.txt" << "Could not make the output directory\n"; @@CODE ```